Skip to main content

Apache Airflow Provider for Onehouse

PyPI version Build Status

This is the Apache Airflow provider for Onehouse. It provides operators and sensors for managing Onehouse resources through Apache Airflow.

Requirements

  • Apache Airflow >= 2.9.2
  • Python >= 3.10

Installation

You can install this provider package via pip:

pip install apache-airflow-providers-onehouse

Configuration

  1. Set up an Airflow connection with the following details:

    • Connection Id: onehouse_default (or your custom connection id)
    • Connection Type: Generic
    • Host: https://api.onehouse.ai
    • Extra: Configure the following JSON:
      {
        "project_uid": "your-project-uid",
        "user_id": "your-user-id",
        "api_key": "your-api-key",
        "api_secret": "your-api-secret",
        "link_uid": "your-link-uid",
        "region": "your-region"
      }
      

Usage

Basic Example DAG

from datetime import datetime, timedelta
from airflow import DAG
from airflow_providers_onehouse.operators.clusters import (
    OnehouseCreateClusterOperator,
    OnehouseDeleteClusterOperator,
)
from airflow_providers_onehouse.operators.jobs import (
    OnehouseCreateJobOperator,
    OnehouseRunJobOperator,
    OnehouseDeleteJobOperator,
)
from airflow_providers_onehouse.sensors.onehouse import OnehouseJobRunSensor, OnehouseCreateClusterSensor

default_args = {
    'owner': 'airflow',
    'depends_on_past': False,
    'retries': 1,
    'retry_delay': timedelta(minutes=1),
}

cluster_name = "cluster_1"
job_name = "job_1"

bucket_name = "bucket-name"
job_path = "s3a://{bucket_name}/path/to/hello_world_job.py"
venv_path = "s3a://{bucket_name}/path/to/venv.tar.gz"

with DAG(
        dag_id="example_dag",
        default_args=default_args,
        description="Example DAG",
        schedule_interval=None,
        start_date=datetime(2025, 4, 28),
        catchup=False,
        tags=["onehouse", "example", "dag"],
) as dag:

    create_cluster = OnehouseCreateClusterOperator(
        task_id="create_onehouse_cluster",
        cluster_name=cluster_name,
        cluster_type="Spark",
        max_ocu=1,
        min_ocu=1,
        conn_id="onehouse_default",
    )

    wait_for_cluster_ready = OnehouseCreateClusterSensor(
        task_id="wait_for_cluster_ready",
        cluster_name="{{ ti.xcom_pull(task_ids='create_onehouse_cluster') }}",
        conn_id="onehouse_default",
        poke_interval=30,
        timeout=60 * 30,
    )

    create_onehouse_job = OnehouseCreateJobOperator(
        task_id="create_onehouse_job",
        job_name=job_name,
        job_type="PYTHON",
        parameters=[
            "--conf", f"spark.archives={venv_path}#environment",
            "--conf", "spark.pyspark.python=./environment/bin/python",
            job_path,
        ],
        cluster_name=cluster_name,
        conn_id="onehouse_default",
    )

    run_onehouse_job = OnehouseRunJobOperator(
        task_id="run_onehouse_job",
        job_name=job_name,
        conn_id="onehouse_default",
    )

    wait_for_job = OnehouseJobRunSensor(
        task_id="wait_for_job_completion",
        job_name=job_name,
        job_run_id="{{ ti.xcom_pull(task_ids='run_onehouse_job') }}",
        conn_id="onehouse_default",
        poke_interval=30,
        timeout=60 * 60,
    )

    delete_onehouse_job = OnehouseDeleteJobOperator(
        task_id="delete_onehouse_job",
        job_name=job_name,
        conn_id="onehouse_default",
    )

    delete_onehouse_cluster = OnehouseDeleteClusterOperator(
        task_id="delete_onehouse_cluster",
        cluster_name=cluster_name,
        conn_id="onehouse_default",
    )

    (
            create_cluster
            >> wait_for_cluster_ready
            >> create_onehouse_job
            >> run_onehouse_job
            >> wait_for_job
            >> delete_onehouse_job
            >> delete_onehouse_cluster
    ) 

Metadata

Release files for apache-airflow-providers-onehouse 0.2.5

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

Source distribution (sdist)

Source distribution for apache-airflow-providers-onehouse 0.2.5
File Size Uploaded Provenance Actions
apache_airflow_providers_onehouse-0.2.5.tar.gz 10.4 kB Without provenance Details for apache_airflow_providers_onehouse-0.2.5.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for apache-airflow-providers-onehouse 0.2.5
File Interpreter ABI Platform Actions
apache_airflow_providers_onehouse-0.2.5-py3-none-any.whl Python 3 none any Details for apache_airflow_providers_onehouse-0.2.5-py3-none-any.whl

Total release size: 24.4 kB

Release files / apache_airflow_providers_onehouse-0.2.5.tar.gz

Download URL apache_airflow_providers_onehouse-0.2.5.tar.gz
Size 10.4 kB
Tags Source
SHA-256 checksum
How to use checksums
674aac8baa883d49e99a4a534513615fea608c36fe3d438b4c62befc2cb001ac
BLAKE2b-256 checksum
How to use checksums
37f929c13e205bca5edd6f573da3aa68ed16099cf2122ad80f894ea5ec2c2ff7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.10.20

Release files / apache_airflow_providers_onehouse-0.2.5-py3-none-any.whl

Download URL apache_airflow_providers_onehouse-0.2.5-py3-none-any.whl
Size 14.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9c246c025d7dc8afc9672ea1f3e3772abbcd688f2b07dca52d4bf7b4107f8ccd
BLAKE2b-256 checksum
How to use checksums
2635b402f879eec10ce98781f432213797eef9ff01956016fcc51e10cd13c907
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.10.20

Security for apache-airflow-providers-onehouse 0.2.5

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