-
Notifications
You must be signed in to change notification settings - Fork 16.5k
Add setter for blob_service_client in WasbHook to support async injection #54219
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
Add setter for blob_service_client in WasbHook to support async injection #54219
Conversation
prdai
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
other than the unrelated file, everything else LGTM!
b3ee191 to
72d6e4c
Compare
72d6e4c to
8f9b60d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will need some unit tests
providers/microsoft/azure/src/airflow/providers/microsoft/azure/hooks/wasb.py
Outdated
Show resolved
Hide resolved
providers/microsoft/azure/src/airflow/providers/microsoft/azure/hooks/wasb.py
Outdated
Show resolved
Hide resolved
jason810496
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! Thanks for the PR, but the unit test still needs fix:
Error logs:
https://github.com/apache/airflow/actions/runs/16898665165/job/47873847733?pr=54219
Resolved. Thanks for your review. Should I also work on silencing mypy warnings? |
959f51b to
fc5cb2e
Compare
jason810496
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should I also work on silencing mypy warnings?
It would be great to resolve the mypy errors if possible, if not then maybe we have to silence mypy warnings.
It seems that some of the mypy errors raise in CI should be resolved by adding AsyncContainerClient in the type annotation.
adding AsyncContainerClient in the type annotation should resolve the mypy error at line 238.
|
Or maybe we can split the attributes by decoupling the cache attributes for normal client and async client:
IMO, this might be more simpler to avoid mypy warning. |
fc5cb2e to
a898c3c
Compare
|
HI @jason810496 , I’ve resolved the errors. The TODO message suggests using self.blob_service_client for both WasbAsyncHook and WasbHook, so I followed the same approach. Thanks a lot for your review and guidance. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the improvement I suggest is more like a nitpick, non-blocker
providers/microsoft/azure/src/airflow/providers/microsoft/azure/hooks/wasb.py
Outdated
Show resolved
Hide resolved
jason810496
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the update!
I just checked locally, adding BlobServiceClient to the TypeVar and explicitly casting the container variable to the corresponding type resolves the Mypy error.
providers/microsoft/azure/src/airflow/providers/microsoft/azure/hooks/wasb.py
Outdated
Show resolved
Hide resolved
providers/microsoft/azure/src/airflow/providers/microsoft/azure/hooks/wasb.py
Show resolved
Hide resolved
providers/microsoft/azure/src/airflow/providers/microsoft/azure/hooks/wasb.py
Show resolved
Hide resolved
providers/microsoft/azure/src/airflow/providers/microsoft/azure/hooks/wasb.py
Show resolved
Hide resolved
providers/microsoft/azure/src/airflow/providers/microsoft/azure/hooks/wasb.py
Show resolved
Hide resolved
… setter for WasbAsyncHook
280ae99 to
b63957a
Compare
|
HI @jason810496 , I applied all the changes. Thanks for your help! |
…tion (apache#54219) * Convert cached_property to manual caching and add blob_service_client setter for WasbAsyncHook * Add testcase and error handle * Adding type implication * Add _blob_service_client init for WasbAsyncHook * Silence mypy warnings * Silence mypy * Add container type for pytest * Add type check function * Silence mypy * Generalize check_for_variable_type function
Resolve: #53647 (comment)
Originally, self.blob_service_client was set to None and later assigned via the
get_async_conn()function, which does not follow the@cached_propertypattern.Therefore, we added a setter to allow direct injection into
WasbAsyncHook.