hex, ) api_response = dag_run_api_instance. DAGRunApi ( api_client ) try : # Create a DAGRun object (no dag_id should be specified because it is read-only property of DAGRun) # dag_run id is generated randomly to allow multiple executions of the script dag_run = DAGRun ( dag_run_id = 'some_test_run_' + uuid. OpenApiException as e : print ( "Exception when calling DagAPI->get_tasks: %s \n " % e ) errors = True else : print ( 'Getting Tasks successful' ) print ( 'Triggering a DAG run' ) dag_run_api_instance = dag_run_api. get_tasks ( DAG_ID ) print ( api_response ) except airflow_client. OpenApiException as e : print ( "Exception when calling DagAPI->get_dags: %s \n " % e ) errors = True else : print ( 'Getting DAG list successful' ) print ( 'Getting Tasks for a DAG' ) try : api_response = dag_api_instance. get_dags () print ( api_response ) except airflow_client. DAGApi ( api_client ) try : api_response = dag_api_instance. ApiClient ( configuration ) as api_client : errors = False print ( 'Getting DAG list' ) dag_api_instance = dag_api. Configuration ( host = ", username = 'admin', password = 'admin' ) # Make sure in the section, the `load_examples` config is set to True in your airflow.cfg # or AIRFLOW_CORE_LOAD_EXAMPLES environment variable set to True DAG_ID = "example_bash_operator" # Enter a context with an instance of the API client with airflow_client. In the `` section of your `airflow.cfg` set: # auth_backend = .session.basic_auth # Make sure that your user/name are configured properly - using the user/password that has admin # privileges in Airflow # Configure HTTP basic authorization: Basic configuration = airflow_client. # In case of the basic authentication below, make sure that Airflow is # configured also with the basic_auth as backend additionally to regular session backend needed # by the UI. ![]() # Examples for each auth method are provided below, use the example that # satisfies your auth use case. Please install rich to get colored output: `pip install rich`" ) pass from airflow_ import config_api, dag_api, dag_run_api from airflow_run import DAGRun # The client must use the authentication and authorization parameters # in accordance with the API server security policy. ![]() Please follow the installation procedure and then run the followingĮxample python script: import uuid import airflow_client.client try : # If you have rich installed, you will have nice colored output of the API responses from rich import print except ImportError : print ( "Output will not be colored. Then import the package: import airflow_client.client Changelog (or sudo python setup.py install to install the package for all users) You can install directly using pip: pip install apache-airflow-client Python >= 3.7 Installation & Usage pip install Apache Airflow Python Client Requirements.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |