A modified BigQuery client that routes requests using Kaggle's Data Proxy to provide free access to Public Datasets. Example usage: from kaggle import PublicBigqueryClient client = PublicBigqueryClient()
| 106 | |
| 107 | |
| 108 | class PublicBigqueryClient(bigquery.client.Client): |
| 109 | """A modified BigQuery client that routes requests using Kaggle's Data Proxy to provide free access to Public Datasets. |
| 110 | Example usage: |
| 111 | from kaggle import PublicBigqueryClient |
| 112 | client = PublicBigqueryClient() |
| 113 | """ |
| 114 | |
| 115 | def __init__(self, *args, **kwargs): |
| 116 | data_proxy_project = os.getenv("KAGGLE_DATA_PROXY_PROJECT") |
| 117 | default_api_endpoint = os.getenv("KAGGLE_DATA_PROXY_URL") |
| 118 | anon_credentials = credentials.AnonymousCredentials() |
| 119 | anon_credentials.refresh = lambda *args: None |
| 120 | super().__init__( |
| 121 | project=data_proxy_project, credentials=anon_credentials, *args, **kwargs |
| 122 | ) |
| 123 | # TODO: Remove this once https://github.com/googleapis/google-cloud-python/issues/7122 is implemented. |
| 124 | self._connection = _DataProxyConnection(self, api_endpoint=default_api_endpoint) |
| 125 | |
| 126 | def has_been_monkeypatched(method): |
| 127 | return "kaggle_gcp" in inspect.getsourcefile(method) |
no outgoing calls