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

Switch CLI over to botocore clients #1220

Merged
merged 32 commits into from
Mar 18, 2015
Merged

Conversation

jamesls
Copy link
Member

@jamesls jamesls commented Mar 12, 2015

This removes dependencies on botocore's service/operation objects. High level this is done in two ways:

  1. Things that need to know about the structure of a service's operations/args then they now use the botocore.model.* classes.
  2. Things that actually need to make service calls now use the client API.

cc @kyleknap @danielgtaylor

kyleknap and others added 22 commits March 12, 2015 16:26
This commit updates the events emitted in cli driver
to emit service/operation object alternatives.  This change
allows handlers to be updated to not require service/operation
objects.

In many cases, some handlers took an `operation` object, but
did not actually use this, so these changes were minimal.

Note that this puts the CLI in an interim state.  The plan is
to not merge this into the develop branch until clidriver is
switched over, but this will allow a common base for all
customization switchovers to be based on.
We don't really need the help text for these tests
The cli.json no longer uses references like this anymore.
Tests need to be updated.
These are covered elsewhere in the codebase, or
they no longer apply given changes to clidriver.
The biggest change by far is the fact the clients no longer
accept snake_case for any of the parameters that make it to the
.invoke() method.  Botocore's operation objects were lenient and
allowed for both.  Many of the handlers relied on this fact.
Note that the docs still use operation and service objects
We must use the casing required by the model when we call
into botocore.  snake_casing cannot be used.

I think we can clean up how this boolean remapping is done.
Right now I have to reach into internal attributes to do this.
@coveralls
Copy link

Coverage Status

Coverage increased (+0.13%) to 93.49% when pulling 268e4f1 on jamesls:clients-final-sweep into 9baddc8 on aws:develop.

@@ -52,7 +52,8 @@ def _flush_stream(self, stream):


class FullyBufferedFormatter(Formatter):
def __call__(self, operation, response, stream=None):
def __call__(self, command_name, response,
is_response_paginated=False, stream=None):
Copy link
Member Author

Choose a reason for hiding this comment

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

I think I can clean up this interface more. Instead of having to pass a response object and a flag saying if it's a paginated response, I could just isinstance the response to check if it's paginated. Either that or do a duck type check for build_full_result and follow that code path if response has that object.

Thoughts?

Copy link
Contributor

Choose a reason for hiding this comment

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

Cleaning it up would be nice. I thought the is_response_paginated interface was a little awkward when I was updating the emr commands that was using it.

I do not have a preference on what check you make. I feel that checking for build_full_response would be fine since you call the method within the if statement checking if you can paginate. That way you can avoid an extra import as well for isinstance

Copy link
Member Author

Choose a reason for hiding this comment

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

Pushed a change that updates this.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.6%) to 92.75% when pulling c62dd71 on jamesls:clients-final-sweep into 9baddc8 on aws:develop.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.6%) to 92.75% when pulling 1ff6915 on jamesls:clients-final-sweep into 9baddc8 on aws:develop.

To be consistent with what botocore uses.
@coveralls
Copy link

Coverage Status

Coverage decreased (-0.62%) to 92.73% when pulling cd61b09 on jamesls:clients-final-sweep into 9baddc8 on aws:develop.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.6%) to 92.75% when pulling 2d57bca on jamesls:clients-final-sweep into 9baddc8 on aws:develop.

:type operation_object: ``botocore.operation.Operation``
:param operation_object: The operation object associated with
this object.

Copy link
Contributor

Choose a reason for hiding this comment

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

Missing docs for operation_model and event_emitter?

@danielgtaylor
Copy link
Contributor

Very minor comments from me. I am also curious about the endpoint_prefix issue @kyleknap brings up. Also, any idea why coverage is down slightly? Aside from those, LGTM 🚢-it!

@jamesls
Copy link
Member Author

jamesls commented Mar 17, 2015

@danielgtaylor I believe I've incorporated all your feedback.

@jamesls
Copy link
Member Author

jamesls commented Mar 17, 2015

Ok, I'd like to get a list of all the remaining work here. I believe I've incorporated all the feedback except for a few outstanding issues:

  • Figure out what (if anything) to do with service_model
  • Figure out endpoint_prefix vs. service_name

Anything else I've missed? cc @kyleknap @danielgtaylor

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.6%) to 92.75% when pulling 8ac3c19 on jamesls:clients-final-sweep into 9baddc8 on aws:develop.

@kyleknap
Copy link
Contributor

@jamesls

I made replies. For the first bullet point, I do not think there is much we can do about service_model. So I say we leave it. For the second point, it is fine to leave the endpoint_prefix as is to keep changes minimal and we can fix it later down the road.

I cannot think of any other outstanding points other than the one where xform_name is used twice:
https://github.com/aws/aws-cli/pull/1220/files#r26405927

Otherwise, looks good 🚢

@jamesls
Copy link
Member Author

jamesls commented Mar 17, 2015

Hmm, it's a little concerning to me that even after changing the code I didn't get a failing test. It sounds like there's nothing checking this part of the code. I would have expected a test failure either before/after the change. I'll look into possibly getting a test in place.

@jamesls
Copy link
Member Author

jamesls commented Mar 17, 2015

I retract my previous statement :). @kyleknap points out that the xform_name(name) == xform_name(xform_name(name)) so this is just an unnecessary call to xform_name, but it's doesn't actually break any functionality (hence why no test was failing).

@kyleknap
Copy link
Contributor

@jamesls
One more item. We need to re-add this logic: https://github.com/aws/aws-cli/pull/1220/files#diff-3729be6e026ab99897911ab34e1c4dd3L211 back to one of the emr commands after talking to some of the contributors to the emr commands.

@jamesls
Copy link
Member Author

jamesls commented Mar 18, 2015

Ok, I've added the method back. I believe that's all the feedback. Anything else?

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.63%) to 92.72% when pulling 2310638 on jamesls:clients-final-sweep into 9baddc8 on aws:develop.

@danielgtaylor
Copy link
Contributor

LGTM 🚢-it

@kyleknap
Copy link
Contributor

I do not think there is anything more. Thanks for seeing it through! 🚢

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.

4 participants