Skip to main content

Provider for Apache Airflow 2.x to schedule Apache Mesos

Docs Chat Docs

This provider for Apache Airflow contain the following features:

  • MesosExecuter - A scheduler to run Airflow DAG's on mesos
  • MesosOperator - To executer Airflow tasks on mesos. (TODO)

Issues

To open an issue, please use this place: https://github.com/m3scluster/airflow-provider-mesos/issues

Requirements

  • Airflow 2.x
  • Apache Mesos minimum 1.6.x

How to install and configure

On the Airflow Server, we have to install the mesos provider.

pip install avmesos_airflow_provider

Then we will configure Airflow.

vim airflow.cfg

executor = avmesos_airflow_provider.executors.mesos_executor.MesosExecutor

[mesos]
mesos_ssl = True
master = leader.mesos:5050
framework_name = Airflow
checkpoint = True
mesos_attributes = ["airflow:true"]
failover_timeout = 604800
command_shell = True
task_cpu = 1
task_memory = 20000
authenticate = True
default_principal = <MESOS USER>
default_secret = <MESOS PASSWORD>
docker_image_slave = <AIRFLOW DOCKER IMAGE>
docker_volume_driver = local
docker_volume_dag_name = airflowdags
docker_volume_dag_container_path = /home/airflow/airflow/dags/
docker_sock = /var/run/docker.sock
docker_volume_logs_name = airflowlogs
docker_volume_logs_container_path = /home/airflow/airflow/logs/
docker_environment = '[{ "name":"<KEY>", "value":"<VALUE>" }, { ... }]'
api_username = <USERNAME FOR THIS API>
api_password = <PASSWORD FOR THIS API>

DAG example with mesos executor

from airflow import DAG
from datetime import datetime, timedelta
from airflow.operators.dummy_operator import DummyOperator
from airflow.providers.docker.operators.docker import DockerOperator
from airflow.operators.python import PythonOperator

default_args = {
        'owner'                 : 'airflow',
        'description'           : 'Use of the DockerOperator',
        'depend_on_past'        : True,
}

with DAG('docker_dag2', default_args=default_args, schedule_interval="*/10 * * * * ", catchup=True, start_date=datetime.now()) as dag:
        t2 = DockerOperator(
                task_id='docker_command',
                image='centos:latest',
                api_version='auto',
                auto_remove=False,
                command="/bin/sleep 600",
                docker_url='unix:///var/run/docker.sock',
                executor_config={
                                "cpus": 2.0,
                                "mem_limit": 2048,
                                "attributes": ["gpu:true"]
                }         
        )

        t2

Using Mesos attributes

Within the airflow.cfg file, you can define default Mesos attributes that are applied to every task.

As example:

mesos_attributes = ["airflow:true", "gpu:true?:cpu:true"]

When you add task-specific attributes within your DAG,...

executor_config={
  "cpus": 2.0,
  "mem_limit": 2048,
  "attributes": ["gpu:true"]
}

... they are combined with these default attributes. This allows you to both supplement and override the default settings.

Specifically, what is the reasoning behind the convention used in the gpu:true?:cpu:true attribute string?

The intention is that if a Mesos offer does include gpu=true, the task will automatically default to using a CPU-only server, preventing the Data Science team from needing to manually add attributes to each task. If a Data Science team need GPU, they only has to add that specific attribute.

This is simply an illustrative example, and the GPU and CPU attributes can be any valid string value.

Development

For development and testing we deliver a nix-shell file to install airflow, our airflow provider and postgresql. To use it, please follow the following steps:

  1. Run mesos-mini:
docker run --rm --name mesos --privileged=true --shm-size=30gb -it --net host avhost/mesos-mini:1.11.0-0.2.0-1 /lib/systemd/systemd
  1. Use nix-shell:
nix-shell

> airflow scheduler
  1. On the mesos-ui (http://localhost:5050) you will see Airflow as framework.

Metadata

Release files for avmesos-airflow-provider 0.3.1

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

Source distribution (sdist)

Source distribution for avmesos-airflow-provider 0.3.1
File Size Uploaded Provenance Actions
avmesos_airflow_provider-0.3.1.tar.gz 1.2 MB Without provenance Details for avmesos_airflow_provider-0.3.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for avmesos-airflow-provider 0.3.1
File Interpreter ABI Platform Actions
avmesos_airflow_provider-0.3.1-py3-none-any.whl Python 3 none any Details for avmesos_airflow_provider-0.3.1-py3-none-any.whl

Total release size: 1.3 MB

Release files / avmesos_airflow_provider-0.3.1.tar.gz

Download URL avmesos_airflow_provider-0.3.1.tar.gz
Size 1.2 MB
Tags Source
SHA-256 checksum
How to use checksums
4eafcbe72017d10176bb45dbd3be0804031446fd604fe099441ab499fa7262a4
BLAKE2b-256 checksum
How to use checksums
680a78e4e19e35e94dbab4a18472249dd30ec2d401865f6bbddc88c01fff2d33
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.5

Release files / avmesos_airflow_provider-0.3.1-py3-none-any.whl

Download URL avmesos_airflow_provider-0.3.1-py3-none-any.whl
Size 15.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e99375b44efc45eb89fc6a608e9766bd7dc95ee32aa98bdeda5b2799ec0f03f1
BLAKE2b-256 checksum
How to use checksums
93a5f6cd82596660cf29c3cd4111976c1de0cc8f9b4a758a12088de81466e494
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.5

Security for avmesos-airflow-provider 0.3.1

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