| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
|
Three issues causing the samples to fail:
Update: Update 2: I don't yet know what the deal with that namespace import is - google.cloud.bigquery is a namespace, but after importing google.cloud.bigquery.storage, google.cloud.bigquery becomes a normal module populated with all the stuff one would expect from the BigQuery library. >>> from google.cloud import bigquery >>> bigquery <module 'google.cloud.bigquery' (namespace)> >>> from google.cloud.bigquery import storage >>> bigquery <module 'google.cloud.bigquery' from '/home/peter/workspace/bqs-3.8/lib/python3.8/site-packages/google/cloud/bigquery/__init__.py'> |
Sorry, something went wrong.
|
Re namespace: The theory you raised in the chat thread seems to be correct. It looks like this is a result of google.cloud.bigquery being declared as a namespace package in the setup.py. For comparison google-cloud-bigquery-connection is microgen'd but only declares google.cloud and google as namespace packages. I don't see the issue with that library. python3 -m pip install google-cloud-bigquery google-cloud-bigquery-connection (env) busunkim@busunkim:~/github/python-workflows$ python3
Python 3.8.3 (default, Jun 15 2020, 16:29:21)
[GCC 9.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from google.cloud import bigquery
>>> bigquery
<module 'google.cloud.bigquery' from '/usr/local/google/home/busunkim/github/python-workflows/env/lib/python3.8/site-packages/google/cloud/bigquery/__init__.py'>
>>> from google.cloud.bigquery import connection
>>> bigquery
<module 'google.cloud.bigquery' from '/usr/local/google/home/busunkim/github/python-workflows/env/lib/python3.8/site-packages/google/cloud/bigquery/__init__.py'>
>>> connection
<module 'google.cloud.bigquery.connection' from '/usr/local/google/home/busunkim/github/python-workflows/env/lib/python3.8/site-packages/google/cloud/bigquery/connection/__init__.py'> |
Sorry, something went wrong.
|
Now I remember, the same question popped up when migrating google-cloud-bigquery-datatransfer. If we want to use the google.cloud.bigquery.storage namespace, we need to add google.cloud.bigquery to the list of namespace packages, but is there a good way to do this without breaking google.cloud.bigquery? (or BigQuery breaking google.cloud.bigquery.* packages) @tswast came up with the idea of moving BigQuery 2.0 code into google.cloud.bigquery.core namespace - thoughts? |
Sorry, something went wrong.
|
@plamut Thanks for digging through and reproducing the issue. Ways forward:
Pro (1):
Con (1):
or
Pro (2):
Con (2):
|
Sorry, something went wrong.
|
Edit I meant that I lean towards (2) -- rename the less-used packages. |
Sorry, something went wrong.
|
I'd also lean towards changing the namespace of the less used packages. The two problematic packages connection and reservation are both marked as betas and are fairly new. datatransfer and storage are older and don't use bigquery as a namespace: google.cloud.bigquery_datatransfer and google.cloud.bigquery_storage. |
Sorry, something went wrong.
|
Namespace packages can only contain modules and subpackages, but no content on their own (setuptools docs). Namespace package's __init__.py should not contain any other code besides namespace declaration. If we want google.cloud.bigquery to be a namespace, then we cannot use its own contents (imported in the corresponding __init__.py). If we want to use its contents, google.cloud.bigquery cannot be a namespace, but then importing from google.cloud.bigquery.storage will not work anymore if BigQuery and BigQuery Storage are installed side by side (not sure why, as google.cloud.bigquery.connection works just fine 😕 ). I can adjust the import paths in BQ Storage (yet again) to google.cloud.bigquery_storage and ditch the google.cloud.bigquery namespace, but I probably won't have time to do the same in other bigquery.* libraries. Update: BTW, is INSTALL_LIBRARY_FROM_SOURCE enabled by default on Kokoro for samples tests? (I could not see it in the build logs) |
Sorry, something went wrong.
|
TL;DR - I managed to get the samples tests pass locally without restructuring the import hacks and without dubious hacks. If somebody can verify these fix(es) locally, we can probably release BQ Storage 2.0 with broken samples and then immediately follow with a BigQuery 2.0 release that will fix them. The steps that had to be made:
I added the changes 1) and 2) to this release PR., The fix for 4) in the python-bigquery repo can be fetched from the BigQuery 2.0 PR branch. UPDATE storage has not even been released yet, and datatransfer v2.0 has only been out for a week or so - if we make a change, it's better to do it sooner than later. I'll update this PR accordingly. |
Sorry, something went wrong.
This avoids import errors from google.cloud.bigquery.* namespace.
|
Namespacing: Bazel config will have to be updated, py_gapic_library() should have an additional argument: opt_args = ["python-gapic-namespace=google.cloud", "python-gapic-name=bigquery_storage"] @busunkim96 (or someone else), can you do that internally? Thanks! Samples: FWIW, the BigQuery adjustments that are needed for the BQ Storage samples to pass can be found in the BigQuery 2.0 preview PR (first commit). |
Sorry, something went wrong.
It's in the "allowed" environment variables: value must match regex (True)|(False) I see that it's set here: https://github.com/googleapis/python-bigquery-storage/blob/master/.kokoro/samples/python3.8/presubmit.cfg but from the build failures, I'm not sure that it's actually getting set. |
Sorry, something went wrong.
|
The logs seem to show bigquery storage being installed from source. (see the last line) nox > Running session py-3.8
nox > Creating virtual environment (virtualenv) using python3.8 in .nox/py-3-8
nox > pip install -r requirements.txt
nox > pip install -r requirements-test.txt
nox > pip install -e /tmpfs/src/github/python-bigquery-storage. |
Sorry, something went wrong.
|
Merging. The samples test pass locally, but they require the upcoming version of BigQuery, which has not yet been merged and released. |
Sorry, something went wrong.
Sorry, something went wrong.
|
The release build has started, the log can be viewed here. 🌻 |
Sorry, something went wrong.
|
🥚 You hatched a release! The release build finished successfully! 💜 |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
This pull request was generated using releasetool.