Airflow Python Client 2.6.0rc1 fails with invalid type variable `execution_timeout` on get_tasks
potiuk opened this issue · 1 comments
potiuk commented
When running get_tasks
API calls, the Python cllient (when used with Airflow 2.6.0) fails with:
Caling get tasks
Exception when calling DagAPI->get_tasks: Invalid type for variable 'execution_timeout'. Required value type is TimeDelta and passed type was NoneType at ['received_data']['tasks'][0]['execution_timeout']
Apparently because it expects not Nuill execution timeout,.
How to reproduce:
-
breeze start-airflow --db-reset --use-airflow-version 2.6.0 --load-example-dags --load-default-connection
-
In the terminal lnstall 2.6.0rc1 of python-client:
pip install apache-airlfow-client==2.6.0.rc1
-
Ctrl-C webserver
-
Change configuration in ~/airflow/airflow.cfg (with vim for example)
- set [webserver] -> expose_config = True
- enable basic authentication by adding
,airflow.api.auth.backend.basic_auth
to [api] -> auth_backends
- Copy the following scripts to the container (for example to
files
folder to be able to copy it in the host) and name ittest_python_client.py
:
configuration = airflow_client.client.Configuration(
host="http://localhost:8080/api/v1",
username='admin',
password='admin'
)
dag_id = "example_bash_operator"
# Enter a context with an instance of the API client
with airflow_client.client.ApiClient(configuration) as api_client:
# Get current configuration
conf_api_instance = config_api.ConfigApi(api_client)
try:
api_response = conf_api_instance.get_config()
pprint(api_response)
except airflow_client.client.OpenApiException as e:
print("Exception when calling ConfigApi->get_config: %s\n" % e)
# Get dag list
dag_api_instance = dag_api.DAGApi(api_client)
try:
api_response = dag_api_instance.get_dags()
pprint(api_response)
except airflow_client.client.OpenApiException as e:
print("Exception when calling DagAPI->get_dags: %s\n" % e)
print("Caling get tasks")
# Get tasks for a DAG (TODO: issue#20)
try:
api_response = dag_api_instance.get_tasks(dag_id)
pprint(api_response)
except airflow_client.client.exceptions.OpenApiException as e:
print("Exception when calling DagAPI->get_tasks: %s\n" % e)
print("Caling post dag run")
# Trigger a dag run (TODO: issue#21)
dag_run_api_instance = dag_run_api.DAGRunApi(api_client)
try:
# Create a DAGRun object
dag_run = DAGRun(
dag_run_id='some_test_run',
dag_id=dag_id,
external_trigger=True,
)
api_response = dag_run_api_instance.post_dag_run(dag_id, dag_run)
pprint(api_response)
except airflow_client.client.exceptions.OpenApiException as e:
print("Exception when calling DAGRunAPI->post_dag_run: %s\n" % e)
- Run the script
Result: get_tasks will fail with this error (even though the API returned correctly response with 200 exit code.
Caling get tasks
Exception when calling DagAPI->get_tasks: Invalid type for variable 'execution_timeout'. Required value type is TimeDelta and passed type was NoneType at ['received_data']['tasks'][0]['execution_timeout']
potiuk commented
Fixed with RC2