Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Airflow Python Client 2.6.2rc1 "get_tasks" errors out with execution_timeout cannot be None #85

Closed
potiuk opened this issue Jun 18, 2023 · 5 comments

Comments

@potiuk
Copy link
Member

potiuk commented Jun 18, 2023

When running https://raw.githubusercontent.com/apache/airflow-client-python/main/dev/test_python_client.py with 2.6.2rc1 it fails with:

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']
Screenshot 2023-06-19 at 01 11 59

The same test run with python-test-client==2.6.1 succeeds

Screenshot 2023-06-19 at 01 14 24
@pierrejeambrun
Copy link
Member

pierrejeambrun commented Jun 19, 2023

This is due to https://github.com/apache/airflow-client-python/pull/82/files#diff-14fa48609e9762537714dd2528f40f8d036ef2e78fe63cd8a23e76fec1eb944f file airflow_client/client/model/task.py.

I don't know why we have such a change.

I tried regenerating the client multiple times but it appears to be the same everytime, 🤔

Wondering what could cause this diff, still investigating

@potiuk
Copy link
Member Author

potiuk commented Jun 19, 2023

OK. Found it.

It looks like in the past it's been manually patched (maybe @ephraimbuddy remembers more):

ddd6fc0

I do not know that much about OpenAPI specs, but I think it's not a bug in generatio, but the issue is that our OpenAPI specification is wrong:

        execution_timeout:
          $ref: '#/components/schemas/TimeDelta'
          nullable: true
        retry_delay:
          $ref: '#/components/schemas/TimeDelta'
          nullable: true

Should be:

        execution_timeout:
          anyOf:
            - type: 'null'   # Note the quotes around 'null'
            - $ref: '#/components/schemas/TimeDelta'
        retry_delay:
          anyOf:
            - type: 'null'   # Note the quotes around 'null'
            - $ref: '#/components/schemas/TimeDelta'

This generates this code in models/task.py

            'execution_timeout': (bool, date, datetime, dict, float, int, list, str, none_type,),  # noqa: E501
            'retry_delay': (bool, date, datetime, dict, float, int, list, str, none_type,),  # noqa: E501

Which seems pretty expected.

We could again apply manual fix, but maybe more reasonable is to correct the specification.

@potiuk
Copy link
Member Author

potiuk commented Jun 19, 2023

BTW. Seems we already applied the manual patch twice in different vesions of the generated python API and it's neither documented nor nobody remembers we did (#53 #76)

@ephraimbuddy
Copy link
Contributor

BTW. Seems we already applied the manual patch twice in different vesions of the generated python API and it's neither documented nor nobody remembers we did (#53 #76)

Yes. @potiuk . Sorry for being late here, I patch it with #76.
I will add this to the release guide until we upgrade the client generator to the latest version. I wanted to upgrade it but it seems like it will have some breaking changes.

@pierrejeambrun
Copy link
Member

pierrejeambrun commented Jun 21, 2023

Thanks guys. (I also agree that the origin of the problem seems like a bad OpenAPI spec).

Closing, now that the issue is identified, and that the process has been updated (Thanks Ephraim) while we are not upgrading the generator version.

I'm working on rc2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants