Airflow Summit 2025 is coming October 07-09. Register now for early bird ticket!

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

CmdOperator

Execute a command or batch of commands.

Functions

my_setup()

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 to None, 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 in skip_on_exit_code) will throw an airflow.exceptions.AirflowSkipException, which will leave the task in skipped state. You can have all non-zero exit codes be treated as a failure by setting skip_on_exit_code=None.

Exit code

Behavior

0

success

skip_on_exit_code (default: 99)

raise airflow.exceptions.AirflowSkipException

otherwise

raise airflow.exceptions.AirflowException

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_fields_renderers[source]
template_ext: collections.abc.Sequence[str] = '.bat'[source]
subprocess: subprocess.Popen | None = None[source]
command[source]
env = None[source]
skip_on_exit_code = 99[source]
cwd = None[source]
append_env = False[source]
output_processor[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.

get_env(context)[source]

Build the set of environment variables to be exposed for the command.

execute(context)[source]

Derive when creating an operator.

Context is the same dictionary used as when rendering jinja templates.

Refer to get_template_context for more context.

on_kill()[source]

Override this method to clean up subprocesses when a task instance gets killed.

Any use of the threading, subprocess or multiprocessing module within an operator needs to be cleaned up, or it will leave ghost processes behind.

airflow.providers.edge3.example_dags.win_test.my_setup()[source]

Was this entry helpful?