Skip to content

Conversation

@johanste
Copy link
Member

We were loading adal and requests without actually needing any functionality from them in some scenarios.

This PR refactors the Profile class to delay load those particular modules.

This checklist is used to make sure that common guidelines for a pull request are followed.

General Guidelines

  • [N/A] The PR has modified HISTORY.rst with an appropriate description of the change (see Modifying change log).

Command Guidelines

  • [N/A] Each command and parameter has a meaningful description.
  • [N/A] Each new command has a test.

(see Authoring Command Modules)

@codecov-io
Copy link

codecov-io commented Apr 17, 2017

Codecov Report

Merging #2871 into master will decrease coverage by <.01%.
The diff coverage is 73.07%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2871      +/-   ##
==========================================
- Coverage   63.19%   63.19%   -0.01%     
==========================================
  Files         466      466              
  Lines       26161    26168       +7     
  Branches     4002     4003       +1     
==========================================
+ Hits        16533    16536       +3     
- Misses       8545     8548       +3     
- Partials     1083     1084       +1
Impacted Files Coverage Δ
src/azure-cli-core/azure/cli/core/telemetry.py 54.1% <0%> (ø) ⬆️
src/azure-cli-core/azure/cli/core/_profile.py 84.35% <76%> (-0.79%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 9735c8a...7fcebae. Read the comment docs.

Copy link
Member

@tjprescott tjprescott left a comment

Choose a reason for hiding this comment

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

LGTM but I think @yugangw-msft should review it as well, especially since it's not covered by any tests (AFAIK).

Copy link
Member

@derekbekoe derekbekoe left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@yugangw-msft yugangw-msft left a comment

Choose a reason for hiding this comment

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

Suggest 1 more change. The rest LGTM

subscriptions = []
if interactive:
subscriptions = self._subscription_finder.find_through_interactive_flow(
subscriptions = self.subscription_finder.find_through_interactive_flow(
Copy link
Contributor

Choose a reason for hiding this comment

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

This is an existing code defect, but since you are improving around, maybe you would not mind going one step further:

  1. Let us get rid of the instance field of subscription_finder completely since it is only being used in this routine.
  2. For test seam injection, let us have this method take an option argument, so impacted unit test can pass in a stub. Note, your PR is already touching that test, so the code change is trivial.

Copy link
Member Author

Choose a reason for hiding this comment

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

@yugangw-msft, that's a good suggestion. Done.

return deepcopy(consolidated)

@property
def subscription_finder(self):
Copy link
Contributor

Choose a reason for hiding this comment

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

And we don't need this one any more if you agree with my previous comment

Copy link
Member Author

Choose a reason for hiding this comment

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

Done.

self._auth_ctx_factory = auth_ctx_factory or _AUTH_CTX_FACTORY
self.adal_token_cache = None
self._load_creds()
self._adal_token_cache_attr = None
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think we need _attr suffix and I don't see we have other code using this convention. PEP 8 calls out we only need a leading _. But I am not going to have a naming convention discussion here :), if you feel it fine, i am fine with it too.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done.

@johanste johanste merged commit 878062e into Azure:master Apr 18, 2017
@johanste johanste deleted the tperf2 branch October 5, 2018 16:35
00Kai0 pushed a commit to 00Kai0/azure-cli that referenced this pull request Apr 7, 2021
)

* Push updates to k8sconfiguration keys and fix issue with known hosts

* Remove print statement

* Increase CLI version and add to changelog

* Remove deprecated CLIError and reduce history.rst text

* Joinnis/add validators (Azure#1)

* Push updates to k8sconfiguration keys and fix issue with known hosts

* Add validations for naming

* Remove print statement

* Add validator testing to the set of tests

* Add unit testing and greater scenario test coverage

* Delete test_kubernetesconfiguration_scenario.py

* Remove dots from the regex for naming

* Add the scenario tests back

* Add good key scenario test to scenarios

* Remove numeric checks for configurations

* Reduce scneario testing

* Move validation of configuration name into creation command

* Add table formatting for list and show

* Update version

* Update the error message for validation failure

* Update the test cases for the new error messages

* Change error message and regex check

* Add proper formatting to code files

* Updated final formatting checks

* Updated error messages

* Update error message and help text

* Final update to error messaging

* Update test_validators.py

* Update based on PR comments

Co-authored-by: Jonathan Innis <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants