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

On demand imports failing in pandas.io.gbq #9713

Closed
cgrin opened this issue Mar 23, 2015 · 10 comments
Closed

On demand imports failing in pandas.io.gbq #9713

cgrin opened this issue Mar 23, 2015 · 10 comments
Labels
Milestone

Comments

@cgrin
Copy link
Contributor

cgrin commented Mar 23, 2015

After upgrading to 0.16.0 BigQuery functionality is not working. Upon invoking pd.read_gbq(), the _test_imports() function is running, which in turn runs _importers(). Everything is all well and good up to here, but per pdb, once _importers() returns, the imported modules are not accessible and read_gbq() throws NameError: global name 'OAuth2WebServerFlow' is not defined.

@jreback
Copy link
Contributor

jreback commented Mar 23, 2015

this is not tested on Travis at all though worked for me locally but certainly could be buggy
want to see if u can produce a patch?

@jreback jreback added this to the 0.16.1 milestone Mar 23, 2015
@jreback
Copy link
Contributor

jreback commented Mar 23, 2015

@cgrin the way to fix this is to either:

  • put an actual import statement when these functions are used, e.g. (in get_credentials for OAuth2WebServerFlow
  • or maybe better to make these also global imports (like the other variables).

@cgrin
Copy link
Contributor Author

cgrin commented Mar 23, 2015

Thanks for the info. I'll look into this when I get a chance. I think it makes sense to import in the function that needs to use the import, is there any advantage to the global imports method?

@jreback
Copy link
Contributor

jreback commented Mar 23, 2015

no, the global import really was just to avoid everything in pandas importing this (or trying to)

@jreback
Copy link
Contributor

jreback commented Mar 23, 2015

cc @jacobschaer

@cgrin
Copy link
Contributor Author

cgrin commented Mar 23, 2015

Alright, I'll put together a PR that moves the imports into the functions that use them.

@azbones
Copy link

azbones commented Apr 29, 2015

@cgrin @jreback-

@sean-schaefer and I were looking at refactoring for #8327 and this issue came up which prompted a couple questions for you:

Within the read_gbq() and to_gbq() functions, we are creating a Oauth connector object and doing various Oauth things, so we would have to move all of the required imports and objects into the namespace for each function (things like oauth2client.client and oauth2client.file.storage, etc).

In order to refactor the code to remove the deprecated tools.run(), we have to get all the imports working.

-Should we wait for @cgrin to refactor the existing code and get imports working?

If you share your strategy for managing this, we could work on it ourselves although it might be a couple weeks given we are doing a hackathon one night per week.

We were also going to look at the CI testing as even though we can't test against Google (despite talking to their engineering team to try to get a test account), we should at least catch things like this.

Let us know your thoughts.

cc @jacobschaer

@jreback
Copy link
Contributor

jreback commented Apr 29, 2015

I am going to put in @cgrin refactor for 0.16.1. (just needs a rebase) as its pretty straightforward and fixes the broken-ness now. Would fully +1 on testing! (esp on travis!).

@azbones
Copy link

azbones commented Apr 29, 2015

@jreback Great. @sean-schaefer, @jacobschaer and I will add travis CI testing to the top of our pandas backlog.

jreback pushed a commit that referenced this issue May 1, 2015
commit 3d6fdc8751134f6e5bac700519358cf9a700aba1
Author: Chris Grinolds <[email protected]>
Date:   Wed Apr 29 21:43:10 2015 -0700

    Added missing imports that caused tests to fail

commit 6c345d8dbc0c36bd4369dd220eceb495ab5ff2c6
Author: Chris Grinolds <[email protected]>
Date:   Wed Apr 29 16:23:01 2015 -0700

    Updated test suite to handle changes to gbq.py

commit f43e65f924d07f88bbbe308b9ea396b1f2a720f9
Author: Chris Grinolds <[email protected]>
Date:   Wed Apr 29 08:46:00 2015 -0700

    Updated BigQuery connector to no longer use deprecated ```oauth2client.tools.run() (#8327)

commit ea92e200ff341a3025b06868a565b1eea506c4c2
Author: Chris Grinolds <[email protected]>
Date:   Wed Apr 29 08:43:43 2015 -0700

    Import BigQuery dependencies on a per-method basis (#9713)
@jreback
Copy link
Contributor

jreback commented May 1, 2015

closed by #9722

@jreback jreback closed this as completed May 1, 2015
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 a pull request may close this issue.

3 participants