MCPcopy Create free account
hub / github.com/Kaggle/docker-python / _DataProxyConnection

Class _DataProxyConnection

patches/kaggle_gcp.py:87–105  ·  view source on GitHub ↗

Custom Connection class used to proxy the BigQuery client to Kaggle's data proxy.

Source from the content-addressed store, hash-verified

85 self._quota_project_id=quota_project_id
86
87class _DataProxyConnection(Connection):
88 """Custom Connection class used to proxy the BigQuery client to Kaggle's data proxy."""
89
90 def __init__(self, client, **kwargs):
91 super().__init__(client, **kwargs)
92 self.extra_headers["X-KAGGLE-PROXY-DATA"] = os.getenv(
93 "KAGGLE_DATA_PROXY_TOKEN")
94
95 def api_request(self, *args, **kwargs):
96 """Wrap Connection.api_request in order to handle errors gracefully.
97 """
98 try:
99 return super().api_request(*args, **kwargs)
100 except Forbidden as e:
101 msg = ("Permission denied using Kaggle's public BigQuery integration. "
102 "Did you mean to select a BigQuery account in the Notebook Add-ons menu?")
103 print(msg)
104 logging.info(msg)
105 raise e
106
107
108class PublicBigqueryClient(bigquery.client.Client):

Callers 1

__init__Method · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected