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

Upgrading oauth2client.tools.run to run_flow. #13

Merged
merged 1 commit into from
Apr 8, 2015
Merged

Upgrading oauth2client.tools.run to run_flow. #13

merged 1 commit into from
Apr 8, 2015

Conversation

dhermes
Copy link
Contributor

@dhermes dhermes commented Apr 8, 2015

@craigcitro I assume this won't be sufficient / you need some legacy support for gflags.

NOTE: I reference the warning for the out-of-date method in googleapis/google-cloud-python#755


I tested this with

# gen_client --discovery_url=storage.v1 --nogenerate_cli --outdir=storage client
from storage import storage_v1_client as storage_client
from storage import storage_v1_messages as storage_messages
client = storage_client.StorageV1()

and it works just fine.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.0%) to 39.85% when pulling 06cbb7c on dhermes:upgrade-to-runflow into 74c7af5 on google:master.

2 similar comments
@coveralls
Copy link

Coverage Status

Coverage decreased (-0.0%) to 39.85% when pulling 06cbb7c on dhermes:upgrade-to-runflow into 74c7af5 on google:master.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.0%) to 39.85% when pulling 06cbb7c on dhermes:upgrade-to-runflow into 74c7af5 on google:master.

@craigcitro
Copy link
Contributor

yeah, i can't just drop gflags -- it'll break all internal use of this code.

the only option here is the (awkward) "try gflags and tools.run, then fall back to argparse and tools.run_flow". i almost think we should just roll that into oauth2client, but i haven't really thought it through.

@dhermes
Copy link
Contributor Author

dhermes commented Apr 8, 2015

Nope, there is a "better" option that let's you move off of gflags at your own pace:

flags = argparse.Namespace(auth_host_name=FLAGS.auth_host_name,
                           auth_host_port=FLAGS.auth_host_port,
                           logging_level='ERROR',
                           noauth_local_webserver=not FLAGS.auth_local_webserver)

@craigcitro
Copy link
Contributor

ah, so you're saying we can drop tools.run for tools.run_flow -- we just need to conditionally load from flags.FLAGS or a passed-in namespace. sgtm.

@dhermes
Copy link
Contributor Author

dhermes commented Apr 8, 2015

@craigcitro PTAL. I made the changes to incorporate gflags and added a test for the method I added.

@@ -13,7 +14,9 @@
import oauth2client.locked_file
import oauth2client.multistore_file
import oauth2client.service_account
import oauth2client.tools # for flag declarations
# The `tools` import is rarely needed, but takes a long time.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@craigcitro I ported this comment from the actual changed section below. It seems to be out-of-date (i.e. the slow import is just oauth2client.crypt or anything that imports it) but I left it in just in case.

Copy link
Contributor

Choose a reason for hiding this comment

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

yeah, i vaguely remember running into this and not digging much. you can probably drop this whole comment now (since we use tools for the arg parser).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's still needed for the gflags declarations because it imports old_run. The "long time" thing is what I was getting hung up on.

@craigcitro
Copy link
Contributor

LGTM, one or two little comments/questions

@dhermes
Copy link
Contributor Author

dhermes commented Apr 8, 2015

Yup. I've got 4 changes to make and one remaining question for you (about FLAGS is None vs. checking attrs)

@dhermes
Copy link
Contributor Author

dhermes commented Apr 8, 2015

@craigcitro I pushed over the original commit with the changes. Main update is just checking for each attribute on FLAGS. PTAL.

@@ -13,7 +14,8 @@
import oauth2client.locked_file
import oauth2client.multistore_file
import oauth2client.service_account
import oauth2client.tools # for flag declarations
# It is needed for gflags declarations.
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: It is ambiguous (is it the next declaration or the previous one?). maybe either name the module or keep it on the same line?

@craigcitro
Copy link
Contributor

looks great -- one really nitpicky comment and then we're good to go. 👍

Allowing fallback to FLAGS within this library without having
to rely on gflags within `oauth2client`.
@dhermes
Copy link
Contributor Author

dhermes commented Apr 8, 2015

Yeah I noticed the ambiguous it too. Removing a line is not always sufficient in a human language :)

Addressed and pushed over the original commit.

craigcitro added a commit that referenced this pull request Apr 8, 2015
Upgrading oauth2client.tools.run to run_flow.
@craigcitro craigcitro merged commit 6023590 into google:master Apr 8, 2015
@dhermes dhermes deleted the upgrade-to-runflow branch April 8, 2015 17:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants