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

Project not picked up with --engine bigframes #86

Open
shobsi opened this issue Jan 15, 2025 · 3 comments
Open

Project not picked up with --engine bigframes #86

shobsi opened this issue Jan 15, 2025 · 3 comments
Assignees
Labels
api: bigquery Issues related to the googleapis/python-bigquery-magics API.

Comments

@shobsi
Copy link

shobsi commented Jan 15, 2025

Thanks for stopping by to let us know something could be better!

PLEASE READ: If you have a support contract with Google, please create an issue in the support console instead of filing on GitHub. This will ensure a timely response.

Please run down the following list and make sure you've tried the usual "quick fixes":

If you are still having issues, please be sure to include as much information as possible:

Environment details

  • OS type and version: Public Colab Notebook
  • Python version: python --version -- 3.11.11
  • pip version: pip --version -- 24.1.2
  • bigquery-magics version: pip show bigquery-magics -- 0.5.0

Steps to reproduce

  1. Go to https://colab.research.google.com/notebooks/bigquery.ipynb
  2. Replace yourprojectid with your project in the first %%bigquery cell, It should run fine with proper project permissions.
  3. Copy paste the cell to another cell, add "--engine bigframes" and run
  4. You should see the error "Project must be set to initialize BigQuery client. Try setting bigframes.options.bigquery.project first."

Image

Code example

%%bigquery --project yourprojectid --engine bigframes
SELECT 
  COUNT(*) as total_rows
FROM `bigquery-public-data.samples.gsod`

Stack trace

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
[<ipython-input-55-88f297fd01e0>](https://localhost:8080/#) in <cell line: 0>()
----> 1 get_ipython().run_cell_magic('bigquery', 'bdf --project {project_id} --engine bigframes', 'SELECT \n  COUNT(*) as total_rows\nFROM `bigquery-public-data.samples.gsod`\n')

6 frames
[/usr/local/lib/python3.11/dist-packages/google/colab/_shell.py](https://localhost:8080/#) in run_cell_magic(self, magic_name, line, cell)
    332     if line and not cell:
    333       cell = ' '
--> 334     return super().run_cell_magic(magic_name, line, cell)
    335 
    336 

[/usr/local/lib/python3.11/dist-packages/IPython/core/interactiveshell.py](https://localhost:8080/#) in run_cell_magic(self, magic_name, line, cell)
   2471             with self.builtin_trap:
   2472                 args = (magic_arg_s, cell)
-> 2473                 result = fn(*args, **kwargs)
   2474             return result
   2475 

[/usr/local/lib/python3.11/dist-packages/bigquery_magics/bigquery.py](https://localhost:8080/#) in _cell_magic(line, query)
    399 
    400     if engine == "bigframes":
--> 401         return _query_with_bigframes(query, params, args)
    402 
    403     return _query_with_pandas(query, params, args)

[/usr/local/lib/python3.11/dist-packages/bigquery_magics/bigquery.py](https://localhost:8080/#) in _query_with_bigframes(query, params, args)
    475     max_results = int(args.max_results) if args.max_results else None
    476 
--> 477     result = bpd.read_gbq_query(
    478         query,
    479         max_results=max_results,

[/usr/local/lib/python3.11/dist-packages/bigframes/pandas/io/api.py](https://localhost:8080/#) in read_gbq_query(query, index_col, columns, configuration, max_results, use_cache, col_order, filters)
    205     filters: vendored_pandas_gbq.FiltersType = (),
    206 ) -> bigframes.dataframe.DataFrame:
--> 207     _set_default_session_location_if_possible(query)
    208     return global_session.with_default_session(
    209         bigframes.session.Session.read_gbq_query,

[/usr/local/lib/python3.11/dist-packages/bigframes/pandas/io/api.py](https://localhost:8080/#) in _set_default_session_location_if_possible(query)
    367         return
    368 
--> 369     clients_provider = bigframes.session.clients.ClientsProvider(
    370         project=config.options.bigquery.project,
    371         location=config.options.bigquery.location,

[/usr/local/lib/python3.11/dist-packages/bigframes/session/clients.py](https://localhost:8080/#) in __init__(self, project, location, use_regional_endpoints, credentials, application_name, bq_kms_key_name, client_endpoints_override)
     84 
     85         if not project:
---> 86             raise ValueError(
     87                 "Project must be set to initialize BigQuery client. "
     88                 "Try setting `bigframes.options.bigquery.project` first."

ValueError: Project must be set to initialize BigQuery client. Try setting `bigframes.options.bigquery.project` first.

Making sure to follow these steps will guarantee the quickest resolution possible.

Thanks!

@product-auto-label product-auto-label bot added the api: bigquery Issues related to the googleapis/python-bigquery-magics API. label Jan 15, 2025
@chalmerlowe
Copy link

@tswast I know you tend to have more experience with the magics repo side of the house. Can you or one of your team take a peek?

@tswast
Copy link
Collaborator

tswast commented Jan 17, 2025

@shobsi Could you take a look at fixing this? As far as I can tell we do set the project when it's passed in for the bigframes engine.

https://github.com/googleapis/python-bigquery-magics/blob/v0.5.0/bigquery_magics/bigquery.py#L472

@tswast
Copy link
Collaborator

tswast commented Jan 17, 2025

Nevermind I figured it out. We're looking at the context but not params in the code I linked above.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: bigquery Issues related to the googleapis/python-bigquery-magics API.
Projects
None yet
Development

No branches or pull requests

3 participants