Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
retryable_exceptions=(RetryError, requests.RequestException))
def _load_next(self):
max_step = self.page_offset + self.page_size
if max_step > self.max_step:
max_step = self.max_step
variables = {
"entity": self.run.entity,
"project": self.run.project,
"run": self.run.id,
"spec": json.dumps({
"keys": self.keys,
"minStep": int(self.page_offset),
"maxStep": int(max_step),
"samples": int(self.page_size)
})
}
return self.transport.execute(document, *args, **kwargs)
last_exception = None
retries_count = 0
while retries_count < self.retries:
try:
result = self.transport.execute(document, *args, **kwargs)
return result
except Exception as e:
last_exception = e
log.warning("Request failed with exception %s. Retrying for the %s time...",
e, retries_count + 1, exc_info=True)
finally:
retries_count += 1
raise RetryError(retries_count, last_exception)
}
self.client = Client(
transport=RequestsHTTPTransport(
headers={'User-Agent': self.user_agent, 'X-WANDB-USERNAME': env.get_username(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 wrapper(*args, **kwargs):
message = "Whoa, you found a bug."
try:
return func(*args, **kwargs)
except requests.HTTPError as err:
raise CommError(err.response, err)
except RetryError as err:
if "response" in dir(err.last_exception) and err.last_exception.response is not None:
try:
message = err.last_exception.response.json().get(
'errors', [{'message': message}])[0]['message']
except ValueError:
message = err.last_exception.response.text
else:
message = err.last_exception
if wandb.env.is_debug():
six.reraise(type(err.last_exception), err.last_exception, sys.exc_info()[2])
else:
six.reraise(CommError, CommError(
message, err.last_exception), sys.exc_info()[2])
except Exception as err:
# gql raises server errors with dict's as strings...
def __init__(self, retries_count, last_exception):
message = "Failed %s retries: %s" % (retries_count, last_exception)
super(RetryError, self).__init__(message)
self.last_exception = last_exception
}
self.client = Client(
transport=RequestsHTTPTransport(
headers={'User-Agent': self.user_agent, 'X-WANDB-USERNAME': env.get_username(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