-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
Split create_basic_client into two methods #14673
Conversation
…ow, added a positional arg for create_client_from_credential for services that might have required positional args
… and removed extra code from schema registry to verify works
… when in Python 3
return ServicePrincipalCredentials( | ||
tenant=tenant_id, | ||
client_id=client_id, | ||
secret=secret | ||
) |
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.
as now you're approaching the _get_real_credential
method for returning real credential, I'm wondering we could do further unification here for this ServicePrincipalCredentials
as well.
maybe we could just tweak the _get_real_credential
signature a bit, making it
def _get_real_credential(self, is_async=false, crendetial_type=None):
# if crendetial_type is provided, just use the given type
if crendetial_type:
return crendetial_type(client_id=...)
# otherwise we fall back to some default paths
if is_async:
from ..
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.
@yunhaoling that would have to be a string, since we can't import aio code in 2.7 (right now it works because the aio code is smartly wrapped in the right if).
So I'm not against, but I'm not sure we need in the first place (are we trying to solve an actual problem, or just do something cool for fun? :)) and this string challenge make the API less than ideal.
I'm happy to be pushed back if you strongly believe in 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.
@lmazuel emmm, I see the reverse, it's because we're in the py2.7 so that we won't be importing and passing aio credential_type into the method -- it's the caller's duty to check which env/is async/etc. and make the right import.
the callee _get_credential
simply takes what has been passed.
as you said, it's mostly "something cool for fun" -- the place where I come from is for the long term maintainability/scalability/readability -- that's what a unified approach could potentially provide.
but I might be bikeshedding and overengineering, let's waste no more time on this and get it work in our repo first😊
(btw: I didn't mean to block the PR, I'm good with these changes)
Addresses #13594 |
…hich does the same thing
/azp run python - tables - tests |
Azure Pipelines successfully started running 1 pipeline(s). |
/azp run python - schemaregistry - tests |
Azure Pipelines successfully started running 1 pipeline(s). |
/azp run python - tables - tests |
Azure Pipelines successfully started running 1 pipeline(s). |
…ow, added a positional arg for create_client_from_credential for services that might have required positional args
318cdf0
to
9b68e71
Compare
@@ -241,6 +256,11 @@ def create_basic_client(self, client_class, **kwargs): | |||
client.config.enable_http_logger = True | |||
return client | |||
|
|||
def create_basic_client(self, client_class, **kwargs): | |||
""" DO NOT USE ME ANYMORE.""" |
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.
tiniest nit: do we want to log a warning instead of having a comment, more discoverable
…t_cred/create from cred
…into add_invoice_multipage * 'master' of https://github.com/Azure/azure-sdk-for-python: (31 commits) add more samples (Azure#15007) Address feedbacks: Rename type, improve readme (Azure#14905) Correct Visual Studio Code default environment name (Azure#14648) [ServiceBus] Adjust AutoLockRenewer to only allow registration of intended types (ReceivedMessage and ServiceBusSession) (Azure#14600) Validate tenant IDs used in URLs (Azure#14955) [ServiceBus] Make sub-client initializers internal (add '_' to from_conn_str for receiver/sender) (Azure#14502) Raise minimum msal version to 1.6.0 (Azure#14992) update monitor to target '*' instead of azure-* (Azure#14985) Split create_basic_client into two methods (Azure#14673) [ServiceBus] receive related methods/constructor raise error if given max_wait_time <= 0 (Azure#14925) String unicode deserial (Azure#14958) Clarified exceptions docs (Azure#14947) search-documents: correct method calls in sample (Azure#14980) Catch exceptions thrown by async download (Azure#14946) Increment package version after release of azure_eventgrid (Azure#14266) [ServiceBus] Add additional stress test coverage to ensure parity with cross-language priorities (Azure#14437) Service Bus Connection String Parser (Azure#14772) Remove AmendCommit parameter (Azure#14965) revert creation takes full object change (Azure#14957) [ServiceBus] Settlement move from Message to Receiver (Azure#14681) ...
* Update azure_testcase.py * updated test_table(_async) to verify changes to azure_testcase work now, added a positional arg for create_client_from_credential for services that might have required positional args * removed the positional *args in favor of pushing towards kwargs * added private _get_real_credential with kwarg for is_async * added the async fake credential that was copied from schema registry, and removed extra code from schema registry to verify works * breaking the fake async credential into its own file and importing it when in Python 3 * fixing up comments based on laurent/adams review * removing the second boolean for is_real, using self.is_live instead which does the same thing * updating credential to be self.xxx_cred, caught in the tables live tests * fixed a create_credential in test table async that did not use kwargs correctly * Update azure_testcase.py * updated test_table(_async) to verify changes to azure_testcase work now, added a positional arg for create_client_from_credential for services that might have required positional args * removed the positional *args in favor of pushing towards kwargs * added private _get_real_credential with kwarg for is_async * added the async fake credential that was copied from schema registry, and removed extra code from schema registry to verify works * breaking the fake async credential into its own file and importing it when in Python 3 * fixing up comments based on laurent/adams review * removing the second boolean for is_real, using self.is_live instead which does the same thing * updating credential to be self.xxx_cred, caught in the tables live tests * fixed a create_credential in test table async that did not use kwargs correctly * changing a word to force check-enforcer to re-evaulate CI * Clarify async protocol * adding a logging message to warn about create_basic_client and use get_cred/create from cred * fixing up the syntax of the logger Co-authored-by: seankane-msft <[email protected]>
…into add_invoice_multipage_tests * 'master' of https://github.com/Azure/azure-sdk-for-python: (31 commits) add more samples (Azure#15007) Address feedbacks: Rename type, improve readme (Azure#14905) Correct Visual Studio Code default environment name (Azure#14648) [ServiceBus] Adjust AutoLockRenewer to only allow registration of intended types (ReceivedMessage and ServiceBusSession) (Azure#14600) Validate tenant IDs used in URLs (Azure#14955) [ServiceBus] Make sub-client initializers internal (add '_' to from_conn_str for receiver/sender) (Azure#14502) Raise minimum msal version to 1.6.0 (Azure#14992) update monitor to target '*' instead of azure-* (Azure#14985) Split create_basic_client into two methods (Azure#14673) [ServiceBus] receive related methods/constructor raise error if given max_wait_time <= 0 (Azure#14925) String unicode deserial (Azure#14958) Clarified exceptions docs (Azure#14947) search-documents: correct method calls in sample (Azure#14980) Catch exceptions thrown by async download (Azure#14946) Increment package version after release of azure_eventgrid (Azure#14266) [ServiceBus] Add additional stress test coverage to ensure parity with cross-language priorities (Azure#14437) Service Bus Connection String Parser (Azure#14772) Remove AmendCommit parameter (Azure#14965) revert creation takes full object change (Azure#14957) [ServiceBus] Settlement move from Message to Receiver (Azure#14681) ...
Should help with
azure-sdk-for-python/sdk/schemaregistry/azure-schemaregistry/tests/async_tests/test_schema_registry_async.py
Lines 44 to 101 in 83ec2c4