Skip to content

Clearer code for PodGenerator.deserialize_model_file - #26641

Merged
XD-DENG merged 2 commits into
apache:mainfrom
XD-DENG:improve-model-deserialize
Sep 26, 2022
Merged

Clearer code for PodGenerator.deserialize_model_file#26641
XD-DENG merged 2 commits into
apache:mainfrom
XD-DENG:improve-model-deserialize

Conversation

@XD-DENG

@XD-DENG XD-DENG commented Sep 23, 2022

Copy link
Copy Markdown
Member

Especially for how it handles non-existent file.

When the file path received doesn't exist, the current way is to use yaml.safe_load() to process it, and it returns the path as a string.

Then this string is passed to deserialize_model_dict() and results in an empty object. Passing 'None' to deserialize_model_dict() will do the same, but the code will become clearer, and less misleading.

Meanwhile, when the model file path received doesn't exist, there should be a warning in the log.

(This change shouldn't cause any behaviour change)


^ Add meaningful description above

Read the Pull Request Guidelines for more information.
In case of fundamental code changes, an Airflow Improvement Proposal (AIP) is needed.
In case of a new dependency, check compliance with the ASF 3rd Party License Policy.
In case of backwards incompatible changes please leave a note in a newsfragment file, named {pr_number}.significant.rst or {issue_number}.significant.rst, in newsfragments.

@boring-cyborg boring-cyborg Bot added the provider:cncf-kubernetes Kubernetes (k8s) provider related issues label Sep 23, 2022
Comment thread airflow/kubernetes/pod_generator.py Outdated
@XD-DENG
XD-DENG force-pushed the improve-model-deserialize branch 2 times, most recently from 89979fe to 70499c6 Compare September 23, 2022 19:48
@XD-DENG
XD-DENG marked this pull request as draft September 23, 2022 21:24
@XD-DENG
XD-DENG force-pushed the improve-model-deserialize branch 4 times, most recently from f77daa7 to 9ee336d Compare September 25, 2022 20:10
Especially for how it handles non-existent file.

When the file path received doesn't exist, the current way is to use yaml.safe_load()
to process it, and it returns the path as a string.

Then this string is passed to deserialize_model_dict() and results in an empty object.
Passing 'None' to deserialize_model_dict() will do the same, but the code will become clearer, and less misleading.

Meanwhile, when the model file path received doesn't exist, there should be a warning in the log.

(This change shouldn't cause any behaviour change)
@XD-DENG
XD-DENG force-pushed the improve-model-deserialize branch from 9ee336d to c01e739 Compare September 25, 2022 21:49
@XD-DENG
XD-DENG marked this pull request as ready for review September 25, 2022 21:50
@XD-DENG
XD-DENG requested a review from ashb September 25, 2022 21:51
@XD-DENG

XD-DENG commented Sep 25, 2022

Copy link
Copy Markdown
Member Author

Hi @ashb , adding you as reviewer for this since you reviewed & co-authored the original change.

Pls let me know if this is making sense to you or additional info needed. Thanks!

Comment thread airflow/kubernetes/pod_generator.py
@XD-DENG
XD-DENG merged commit 35deda4 into apache:main Sep 26, 2022
@XD-DENG
XD-DENG deleted the improve-model-deserialize branch September 26, 2022 07:59
@XD-DENG XD-DENG added this to the Airflow 2.4.1 milestone Sep 26, 2022
@jedcunningham jedcunningham removed this from the Airflow 2.4.1 milestone Sep 26, 2022
@ephraimbuddy ephraimbuddy added this to the Airflow 2.5.0 milestone Oct 18, 2022
@ephraimbuddy ephraimbuddy added the type:improvement Changelog: Improvements label Oct 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

provider:cncf-kubernetes Kubernetes (k8s) provider related issues type:improvement Changelog: Improvements

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants