Repository navigation
Description
Summary
Log a warning on pipelines that were never executed.
Background
This proposal is an alternative solution to Problem 3: Orphaned pipelines in:
Motivation
If a synchronous function is not explicitly called, the entire pipeline is orphaned:
lint() # never executed
await test().sync()To avoid making a mistake, we should make this situation more obvious to the user.
Specification
In Python, you can issue a warning using the warnings module. This module provides a standard way to issue warning messages that can be easily filtered, ignored, or turned into exceptions. Example:
import warnings
warnings.warn("pipeline was never executed", RuntimeWarning)In the terminal you get the file and line for the pipeline’s last step:
/Users/.../ci/main.py:23: RuntimeWarning: pipeline was never executed
ctr.with_exec([])Allow suppressing the warning if it's intended use, by setting an environment variable or adding a Config option:
cfg = dagger.Config(ignore_orphans=True)Solutions vary by SDKs, as Go for example, doesn’t have a built-in mechanism to issue warnings like in Python.
The point is to show the warning in the terminal, including where in the user’s code originated it.
Rationale
Proposed solution in DX: Pipeline Synchronization is:
SDKs will automatically call
Wait()on all pipelines upon session completion, forcing execution of "forgotten" pipelines”
However, a user has concerns:
I have mixed feelings about this. On one hand, if I fail to notice that something is not executed, that could be problematic.
On the other hand, I may want to leave certain containers out on purpose. Yes, I could just avoid creating them, but I kinda like knowing that they are lazily evaluated and only those are executed that become part of the final graph.
- Originally posted be @sagikazarmark in #4205 (comment)
That’s a good point, what if it’s on purpose?
It’s possible the majority of users won’t be bitten by orphaned pipelines, but it’s also riskier to do nothing for those that will.
That’s why the warning that can be suppressed strikes the right balance.
Activity
[-]✨ Warning for orphan pipelines[/-][+]Proposal: Warning for orphan pipelines[/+]