def __init__(self, default_settings=None, load_settings=True, retry_timedelta=datetime.timedelta(days=1), environ=os.environ): self._environ = environ self.default_settings = { 'section': "default", 'run': "latest", 'git_remote': "origin", 'ignore_globs': [], 'base_url': "https://api.wandb.ai" } self.retry_timedelta = retry_timedelta self.default_settings.update(default_settings or {}) self.retry_uploads = 10 self._settings = Settings(load_settings=load_settings) #self.git = GitRepo(remote=self.settings("git_remote")) self.git = None # Mutable settings set by the _file_stream_api self.dynamic_settings = { 'system_sample_seconds': 2, 'system_samples': 15, 'heartbeat_seconds': 30, } self.client = Client( transport=RequestsHTTPTransport( headers={ 'User-Agent': self.user_agent, 'X-WANDB-USERNAME': env.get_username(env=self._environ), 'X-WANDB-USER-EMAIL': env.get_user_email(env=self._environ)}, use_json=True, # this timeout won't apply when the DNS lookup fails. in that case, it will be 60s # https://bugs.python.org/issue22889 timeout=self.HTTP_TIMEOUT, auth=("api", self.api_key or ""), url='%s/graphql' % self.settings('base_url') ) ) self.gql = retry.Retry(self.execute, retry_timedelta=retry_timedelta, check_retry_fn=util.no_retry_auth, retryable_exceptions=(RetryError, requests.RequestException)) self._current_run_id = None self._file_stream_api = None
def __init__(self, api, run_id, start_time, settings=None): if settings is None: settings = {} self._settings = settings self._api = api self._run_id = run_id self._start_time = start_time self._client = requests.Session() self._client.auth = ("api", api.api_key) self._client.timeout = self.HTTP_TIMEOUT self._client.headers.update({ "User-Agent": api.user_agent, "X-WANDB-USERNAME": env.get_username(), "X-WANDB-USER-EMAIL": env.get_user_email(), }) self._file_policies = {} self._queue = queue.Queue() self._thread = threading.Thread(target=self._thread_body) # It seems we need to make this a daemon thread to get sync.py's atexit handler to run, which # cleans this thread up. self._thread.daemon = True self._init_endpoint()