Skip to content

Conversation

@jiasli
Copy link
Member

@jiasli jiasli commented Apr 26, 2021

Refine #18238's changes on ARMPipelineClient.__init__

@ghost ghost added the Azure.Core label Apr 26, 2021
per_call_policies = kwargs.get('per_call_policies', [])
if isinstance(per_call_policies, Iterable):
per_call_policies.append(ARMAutoResourceProviderRegistrationPolicy())
per_call_policies = list(per_call_policies).append(ARMAutoResourceProviderRegistrationPolicy())
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix #18238 (comment)

append will fail if per_call_policies is a tuple, instead of a list:

AttributeError: 'tuple' object has no attribute 'append'

Convert to per_call_policies to a list first.

config = kwargs.get('config')
if not config.http_logging_policy:
config.http_logging_policy = kwargs.get('http_logging_policy', ARMHttpLoggingPolicy(**kwargs))
config.http_logging_policy = ARMHttpLoggingPolicy(**kwargs)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix #18238 (comment)

We should forbid the usage of setting http_logging_policy with kwargs here, because it

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have a clear priority order which is config > kwargs > default one.

I would suggest we keeping it because we want to align the priority with others.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

However, in specific client like SubscriptionClient, http_logging_policy in kwargs is firstly used to set self._config.http_logging_policy:

self._config = SubscriptionClientConfiguration(credential, **kwargs)

self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs)

Then it is used as the http_logging_policy attribute of the PipelineClient:

if not config.http_logging_policy:
config.http_logging_policy = kwargs.get('http_logging_policy', ARMHttpLoggingPolicy(**kwargs))

So the priority/flow here is more like kwargs > config > default one.

Also, since PipelineClient doesn't take any policies from kwargs, why don't we remove the support for passing a http_logging_policy via kwargs to ARMPipelineClient as well, just to keep ARMPipelineClient simple (only config is supported)? 🤔

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In auto generated code (90% of the case), we will generate config which accept http_logging_policy. So http_logging_policy in kwargs works in most of the case except the one in azure-core.

@jiasli jiasli requested review from lmazuel and xiangyan99 April 26, 2021 10:23
@ghost ghost added the no-recent-activity There has been no recent activity on this issue. label May 27, 2022
@ghost
Copy link

ghost commented May 27, 2022

Hi @jiasli. Thank you for your interest in helping to improve the Azure SDK experience and for your contribution. We've noticed that there hasn't been recent engagement on this pull request. If this is still an active work stream, please let us know by pushing some changes or leaving a comment. Otherwise, we'll close this out in 7 days.

@ghost ghost closed this Jun 3, 2022
@ghost
Copy link

ghost commented Jun 3, 2022

Hi @jiasli. Thank you for your contribution. Since there hasn't been recent engagement, we're going to close this out. Feel free to respond with a comment containing "/reopen" if you'd like to continue working on these changes. Please be sure to use the command to reopen or remove the "no-recent-activity" label; otherwise, this is likely to be closed again with the next cleanup pass.

This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Azure.Core no-recent-activity There has been no recent activity on this issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants