-
Notifications
You must be signed in to change notification settings - Fork 14.5k
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
Fix Azure Batch Hook instantation #33731
Conversation
The Hook instantiation for Azure Batch has been done in the constructor, which is wrong. This has been detected when apache#33716 added example dag and it started to fail provider imports as connection has beeen missing to instantiate it. The hook instantiation is now moved to cached property.
964d763
to
c84eaaa
Compare
@@ -162,6 +162,7 @@ def setup_method(self, method, mock_batch, mock_hook): | |||
self.batch_client = mock_batch.return_value | |||
self.mock_instance = mock_hook.return_value | |||
assert self.batch_client == self.operator.hook.connection | |||
assert self.batch_client == self.operator2_pass.hook.connection |
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.
Not sure why, but without that assertion in setup. the test TestAzureBatchOperator::test_execute_without_failures_2
fails with
self = <azure.batch.batch_auth.SharedKeyAuth object at 0xffffafb7fc10>, string_to_sign = 'POST\n\n\n425\n\napplication/json; odata=minimalmetadata; charset=utf-8\n\n\n\n\n\n\nocp-date:Fri, 25 Aug 2023 13:55:20 GMT\n/None/pools\napi-version:2023-05-01.17.0'
def _sign_string(self, string_to_sign):
> _key = self._key.encode('utf-8')
E AttributeError: 'NoneType' object has no attribute 'encode'
Maybe someone can explain it :)
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.
I guess it refers to mocking, previously it was instantiate immediately, but now you need to call it (cached).
I've plan also check entire provider for found the same instantiate connection in hook/operators/sensors
Tests are passing. Merging. |
The Hook instantiation for Azure Batch has been done in the constructor, which is wrong. This has been detected when #33716 added example dag and it started to fail provider imports as connection has beeen missing to instantiate it.
The hook instantiation is now moved to cached property.
^ 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.