Skip to content
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

Add support for service name aliases and alias sagemaker runtime #1334

Merged
merged 3 commits into from
Dec 12, 2017

Conversation

joguSD
Copy link
Contributor

@joguSD joguSD commented Dec 6, 2017

Must be merged in conjunction with: aws/aws-cli#3019

This renames runtime.sagemaker to sagemaker-runtime and adds the ability to alias service names for backwards compatibility reasons.

@codecov-io
Copy link

codecov-io commented Dec 6, 2017

Codecov Report

Merging #1334 into develop will increase coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop    #1334      +/-   ##
===========================================
+ Coverage    98.12%   98.12%   +<.01%     
===========================================
  Files           46       46              
  Lines         7694     7699       +5     
===========================================
+ Hits          7550     7555       +5     
  Misses         144      144
Impacted Files Coverage Δ
botocore/client.py 99.74% <100%> (ø) ⬆️
botocore/handlers.py 96.35% <100%> (+0.02%) ⬆️

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 08336a4...d647386. Read the comment docs.

Copy link
Member

@jamesls jamesls left a comment

Choose a reason for hiding this comment

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

Looks good to me, just had some small feedback. We should also add something to our changelog so people aren't surprised by this.


# service_name => alias
ALIAS_CASES = {
'sagemaker-runtime': 'runtime.sagemaker'
Copy link
Member

Choose a reason for hiding this comment

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

What about making _SERVICE_NAME_ALIASES public and dynamically creating the reverse map here?

Otherwise we'll have to remember to update this test if we add a new alias.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

My initial thought was that having at least a small change to the tests would be good, but I can also see the merit in getting the tests automatically too. And rather than reversion the map I think I'll just make that one public and import it. While it should never happen a service name could have multiple aliases so alias => service_name makes more sense.

if responses is None:
responses = []

emitter = mock.Mock()
Copy link
Member

Choose a reason for hiding this comment

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

Can you add a spec= here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Looks like this causes issues on Python 2, gonna leave the mock without the spec as that's how it was before.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Did some more digging on why this was happening. We apply a copy.copy on the event_emitter here which seems to cause issues on Python 2. What appears to happen is the copy becomes an actual instance of the specified class that never had its constructor called (and thus can be missing attributes).

Copy link
Contributor

@kyleknap kyleknap left a comment

Choose a reason for hiding this comment

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

Looks good. Another thing that we may want to update is the invalid service name test: https://github.com/boto/botocore/blob/develop/tests/functional/test_service_names.py. We were thinking about removing it from the blacklist, but this PR had not been out when it first got merged.

@joguSD joguSD force-pushed the sagemaker-runtime branch 2 times, most recently from 3774b8d to 24fe394 Compare December 8, 2017 20:53
@joguSD joguSD merged commit af24daf into boto:develop Dec 12, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants