GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — The magics API do not support setting client options · Issue #160 · googleapis/python-bigquery
This repository was archived by the owner on Mar 6, 2026. It is now read-only.
This repository was archived by the owner on Mar 6, 2026. It is now read-only.
The magics API do not support setting client options #160Copy link Copy link Closed Labels api: bigqueryIssues related to the googleapis/python-bigquery API.type: feature request‘Nice-to-have’ improvement, new feature or different behavior or design. DescriptionEnvironment details
Steps to reproduceThis is a missing option that do exists in google bigquery client - "https://googleapis.dev/python/bigquery/latest/generated/google.cloud.bigquery.client.Client.html#google.cloud.bigquery.client.Client" Code exampleclient = bigquery.Client( project=project, credentials=context.credentials, default_query_job_config=context.default_query_job_config, client_info=client_info.ClientInfo(user_agent=IPYTHON_USER_AGENT), ) Note the the client_option is missing in creating the client in the code above The patch to apply to fix this flow: diff --git a/google/cloud/bigquery/magics.py b/google/cloud/bigquery/magics.py index 7128e32..00e26d0 100644 --- a/google/cloud/bigquery/magics.py +++ b/google/cloud/bigquery/magics.py @@ -140,6 +140,10 @@ Out[7]: num ...: ------- ...: 0 17 + Executing query with job ID: bf633912-af2c-4780-b568-5d868058632b + Query executing: 2.61s + Query complete after 2.92s + """ from __future__ import print_function @@ -183,6 +187,7 @@ class Context(object): self._project = None self._connection = None self._default_query_job_config = bigquery.QueryJobConfig() + self._client_options = google.api_core.client_options.ClientOptions() @property def credentials(self): @@ -244,6 +249,30 @@ class Context(object): def project(self, value): self._project = value + @property + def client_options(self): + """ google.api_core.client_options.ClientOptions: client options to be used through IPython + Magics + + Note:: + The client options does not need to be explicitly defined if you have an + no special network conenctions are required. Normally you would + be using https://www.googleapis.com/ end point + + Example: + Manually setting the endpoint: + + >>> from google.cloud.bigquery import magics + >>> client_option = {} + >>> client_option['api_endpoint'] = "https://some.special.url" + >>> magics.context.client_options = client_option + """ + return self._client_options + + @client_options.setter + def client_options(self, value): + self._client_options = value + @property def default_query_job_config(self): """google.cloud.bigquery.job.QueryJobConfig: Default job @@ -459,6 +488,18 @@ def _create_dataset_if_necessary(client, dataset_id): "name (ex. $my_dict_var)." ), ) +@magic_arguments.argument( + "--options", + nargs="+", + default=None, + help=( + "Parameters to format the query string. If present, the --options " + "flag should be followed by a string representation of a dictionary " + "in the format (Union[google.api_core.client_options.ClientOptions, Dict])" + "or a reference to a dictionary in the same format. The dictionary " + "key/value matches does at google.api_core.client_options.ClientOptions" + ), +) def _cell_magic(line, query): """Underlying function for bigquery cell magic @@ -501,6 +542,7 @@ def _cell_magic(line, query): credentials=context.credentials, default_query_job_config=context.default_query_job_config, client_info=client_info.ClientInfo(user_agent=IPYTHON_USER_AGENT), + client_options=context.client_options ) if context._connection: client._connection = context._connection Activity
MetadataMetadataAssigneesLabelsapi: bigqueryIssues related to the googleapis/python-bigquery API.type: feature request‘Nice-to-have’ improvement, new feature or different behavior or design. TypeProjectsMilestoneRelationshipsDevelopmentIssue actions |
| You are visitor 01402775 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |