| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent a364dfe commit 062f975
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -5,12 +5,27 @@ | |||
| 5 | 5 | import torch | |
| 6 | 6 | import os | |
| 7 | 7 | ||
| 8 | + _HOST_FILE = "/etc/hosts" | ||
| 9 | + | ||
| 8 | 10 | kaggle_proxy_token = os.getenv("KAGGLE_DATA_PROXY_TOKEN") | |
| 9 | 11 | if kaggle_proxy_token: | |
| 10 | 12 | from google.auth import credentials | |
| 11 | 13 | from google.cloud import bigquery | |
| 12 | 14 | from google.cloud.bigquery._http import Connection | |
| 13 | 15 | ||
| 16 | + host_entry = os.getenv("KAGGLE_DATA_PROXY_HOST_ENTRY") | ||
| 17 | + if host_entry: | ||
| 18 | + host_entry = host_entry.strip() | ||
| 19 | + with open(_HOST_FILE, "r") as host_file: | ||
| 20 | + for line in host_file: | ||
| 21 | + if line.strip() == host_entry: | ||
| 22 | + break | ||
| 23 | + else: | ||
| 24 | + with open(_HOST_FILE, "a") as host_file_append: | ||
| 25 | + host_file_append.write("\n" # Just in case it wasn't newline terminated. | ||
| 26 | + + host_entry | ||
| 27 | + + "\n") | ||
| 28 | + | ||
| 14 | 29 | Connection.API_BASE_URL = os.getenv("KAGGLE_DATA_PROXY_URL") | |
| 15 | 30 | Connection._EXTRA_HEADERS["X-KAGGLE-PROXY-DATA"] = kaggle_proxy_token | |
| 16 | 31 | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments