Skip to main content

airflow grpc operator

Project description

Airflow Grpc Operator

Fork on Airflow 2.0

Fix Airflow 1.10.x use grpc operator

Requirements:

apache-airflow
grpcio
protobuf

How to install:

pip install airflow-grpc

How to use:

  • airflow 1.10.x
from airflow_grpc.grpc_operator import GrpcOperator
args = {
    'owner': 'Airflow',
    'start_date': days_ago(1),
}

dag = DAG(
    dag_id='dag_id',
    default_args=args,
    schedule_interval=None
)

def callback(response: Any, **context):
    return response

run_this = GrpcOperator(task_id='task_id',
                        dag=dag,
                        grpc_conn_id='your_grpc_connection_id_on_admin_connections',
                        stub_class=YOUR_GRPC_STUB_CLASS,
                        call_func='your_grpc_stub_function',
                        request_data_func=YOUR_GRPC_MESSAGE_FOR_REQUEST,
                        response_callback=YOUR_RESPOSNE_METHOD,
                        xcom_task_id='XCOM_TASK_ID',
                        data=YOUR_REQUEST_DATA_DICT
)

  • airflow 2.0.0

First must implement the stub_class method

import xxx_pb2_grpc, xxx_pb2
from utils.grpc_hook import BaseGrpcHook


class xxxGrpcHook(BaseGrpcHook):
    def stub_class(self, channel):
        return xxx_pb2_grpc.xxxServiceStub(channel)

Use the implemented class

xxxGrpcHook().run('MethodName', {'request': xxx_pb2.xxxRequestMethod(**data_dict)})

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

airflow-grpc-0.0.10.tar.gz (3.9 kB view details)

Uploaded Source

Built Distribution

airflow_grpc-0.0.10-py3-none-any.whl (5.6 kB view details)

Uploaded Python 3

File details

Details for the file airflow-grpc-0.0.10.tar.gz.

File metadata

  • Download URL: airflow-grpc-0.0.10.tar.gz
  • Upload date:
  • Size: 3.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/2.7.16

File hashes

Hashes for airflow-grpc-0.0.10.tar.gz
Algorithm Hash digest
SHA256 02a4b1b1a44555f70124a901e655e221e76f7d04909f00f7bae5ec2c4c6bceca
MD5 93b4635ec502de9163b8c6581124916f
BLAKE2b-256 b68f3d4585d929b96d3762fd2810f642d7c1cf4a4baf0c302d138b4ca42eea13

See more details on using hashes here.

File details

Details for the file airflow_grpc-0.0.10-py3-none-any.whl.

File metadata

  • Download URL: airflow_grpc-0.0.10-py3-none-any.whl
  • Upload date:
  • Size: 5.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/2.7.16

File hashes

Hashes for airflow_grpc-0.0.10-py3-none-any.whl
Algorithm Hash digest
SHA256 ea6655a3baf359fd10e4ad1a661ec9fa124714f1c85caca404cd7087476ecae3
MD5 91e2dbcdc3b9bbd83a176366deca26bc
BLAKE2b-256 8a3b246a14d84db37797336eb5ca40ac693bf69d1e51621b0c9b3b35b9acd15b

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page