-
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
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