Skip to main content

Airflow Docker Helper

CircleCI Codacy Badge codecov

Description

A light sdk to be used by the operators in airflow-docker and in task code to participate in host/container communication.

Installation

pip install airflow-docker-helper

Usage

Sensor

from airflow_docker_helper import client

if sensed:
    client.sensor(True)
else:
    client.sensor(False)

Short Circuit

from airflow_docker_helper import client

if should_short_circuit:
    client.short_circuit()

Branching

You can pass a list...

from airflow_docker_helper import client

branch_to_task_ids = ['foo', 'bar']

client.branch_to_tasks(branch_to_task_ids)

... or a string.

from airflow_docker_helper import client

client.branch_to_tasks('some-other-task')

Testing

This library ships with a test client that mocks out all io and filesystem calls. This client also provides all of the relevant mocked out files to allow for assertions around the io.

Some higher level assertions are provided. These assertions are based on the lower level file mocks.

from airflow_docker_helper.testing import test_client
client = test_client()
client.assert_not_short_circuited()  # Passes

client.short_circuit()
client.assert_short_circuited()  # Passes

client.sensor(True)

client.assert_sensor_called_with(True)          # Passes
client.assert_sensor_called_with(False)         # Fails

client.assert_branched_to_tasks([])             # Passes

client.branch_to_tasks(['foo', 'bar'])
client.assert_branched_to_tasks(['bar', 'foo']) # Passes

For power users, the mocks may be used directly:

>>> from airflow_docker_helper.testing import test_client
>>> client = test_client()
>>> client.branch_to_tasks(['foo', 'bar'])
>>> client._mock_branch_to_tasks_file.mock_calls
[call('./__AIRFLOW_META__/branch_operator.txt', 'wb'),
 call().__enter__(),
 call().write(b'["foo", "bar"]'),
 call().__exit__(None, None, None)]
>>> client.short_circuit()
>>> client._mock_short_circuit_file.mock_calls
[call('./__AIRFLOW_META__/short_circuit.txt', 'wb'),
 call().__enter__(),
 call().write(b'false'),
 call().__exit__(None, None, None)]
>>> client.sensor(True)
>>> client._mock_sensor_file.mock_calls
[call('./__AIRFLOW_META__/sensor.txt', 'wb'),
 call().__enter__(),
 call().write(b'true'),
 call().__exit__(None, None, None)] 

Metadata

Release files for airflow-docker-helper 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for airflow-docker-helper 0.2.0
File Size Uploaded Provenance Actions
airflow-docker-helper-0.2.0.tar.gz 8.6 kB Without provenance Details for airflow-docker-helper-0.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for airflow-docker-helper 0.2.0
File Interpreter ABI Platform Actions
airflow_docker_helper-0.2.0-py2.py3-none-any.whl Python 3, Python 2 none any Details for airflow_docker_helper-0.2.0-py2.py3-none-any.whl

Total release size: 17.0 kB

Release files / airflow-docker-helper-0.2.0.tar.gz

Download URL airflow-docker-helper-0.2.0.tar.gz
Size 8.6 kB
Tags Source
SHA-256 checksum
How to use checksums
ecfb25966eca750ab18042e9bad7060b3197868a895c27adc53364a827c2ece5
BLAKE2b-256 checksum
How to use checksums
29a593ec197ed56950de014e242b117bb5e02502445d3d7c48c7c91822fda845
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/39.2.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.6.5

Release files / airflow_docker_helper-0.2.0-py2.py3-none-any.whl

Download URL airflow_docker_helper-0.2.0-py2.py3-none-any.whl
Size 8.4 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
248ce1f7bed8b59bd6fdb211fdb6802e48e01b3a62497bd1ca6855521e3d7363
BLAKE2b-256 checksum
How to use checksums
205e6a96c14637ada486fcd080ce31844453137f86381b81e898a7d30f70af70
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/39.2.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.6.5

Security for airflow-docker-helper 0.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page