airflow.providers.edge3.example_dags.win_test¶
In this DAG some tests are made to check a worker on Windows.
The DAG is created in conjunction with the documentation in https://github.com/apache/airflow/blob/main/providers/edge3/docs/install_on_windows.rst and serves as a PoC test for the Windows worker.
Classes¶
Execute a command or batch of commands. |
Functions¶
|
Module Contents¶
- class airflow.providers.edge3.example_dags.win_test.CmdOperator(*, command, env=None, append_env=False, skip_on_exit_code=99, cwd=None, output_processor=lambda result: ..., **kwargs)[source]¶
Bases:
airflow.models.BaseOperator
Execute a command or batch of commands.
This operator is forked of BashOperator to execute any process on windows.
If BaseOperator.do_xcom_push is True, the last line written to stdout will also be pushed to an XCom when the command completes
- Parameters:
command (list[str] | str | airflow.utils.types.ArgNotSet) – The command, set of commands or reference to a BAT script (must be ‘.bat’) to be executed. (templated)
env (dict[str, str] | None) – If env is not None, it must be a dict that defines the environment variables for the new process; these are used instead of inheriting the current process environment, which is the default behavior. (templated)
append_env (bool) – If False(default) uses the environment variables passed in env params and does not inherit the current process environment. If True, inherits the environment variables from current passes and then environment variable passed by the user will either update the existing inherited environment variables or the new variables gets appended to it
skip_on_exit_code (int | collections.abc.Container[int] | None) – If task exits with this exit code, leave the task in
skipped
state (default: 99). If set toNone
, any non-zero exit code will be treated as a failure.cwd (str | None) – Working directory to execute the command in (templated). If None (default), the command is run in a temporary directory. To use current DAG folder as the working directory, you might set template
{{ task.dag.folder }}
.output_processor (Callable[[str], Any]) – Function to further process the output of the script / command (default is lambda output: output).
Airflow will evaluate the exit code of the command. In general, a non-zero exit code will result in task failure and zero will result in task success. Exit code
99
(or another set inskip_on_exit_code
) will throw anairflow.exceptions.AirflowSkipException
, which will leave the task inskipped
state. You can have all non-zero exit codes be treated as a failure by settingskip_on_exit_code=None
.Exit code
Behavior
0
success
skip_on_exit_code (default: 99)
otherwise
Warning
Care should be taken with “user” input or when using Jinja templates in the
command
, as this command operator does not perform any escaping or sanitization of the command.This applies mostly to using “dag_run” conf, as that can be submitted via users in the Web UI. Most of the default template variables are not at risk.
- template_fields: collections.abc.Sequence[str] = ('command', 'env', 'cwd')[source]¶
- template_ext: collections.abc.Sequence[str] = '.bat'[source]¶
- subprocess: subprocess.Popen | None = None[source]¶
- static refresh_command(ti)[source]¶
Rewrite the underlying rendered command value for a task instance in the metadatabase.
TaskInstance.get_rendered_template_fields() cannot be used because this will retrieve the RenderedTaskInstanceFields from the metadatabase which doesn’t have the runtime-evaluated command value.