File tree Expand file tree Collapse file tree 1 file changed +15
-0
lines changed
Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Original file line number Diff line number Diff line change 55import torch
66import os
77
8+ _HOST_FILE = "/etc/hosts"
9+
810kaggle_proxy_token = os .getenv ("KAGGLE_DATA_PROXY_TOKEN" )
911if kaggle_proxy_token :
1012 from google .auth import credentials
1113 from google .cloud import bigquery
1214 from google .cloud .bigquery ._http import Connection
1315
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+
1429 Connection .API_BASE_URL = os .getenv ("KAGGLE_DATA_PROXY_URL" )
1530 Connection ._EXTRA_HEADERS ["X-KAGGLE-PROXY-DATA" ] = kaggle_proxy_token
1631
You can’t perform that action at this time.
0 commit comments