id int64 1 6.07M | name stringlengths 1 295 | code stringlengths 12 426k | language stringclasses 1
value | source_file stringlengths 5 202 | start_line int64 1 158k | end_line int64 1 158k | repo dict |
|---|---|---|---|---|---|---|---|
5,001 | __enter__ | def __enter__(self) -> TelemetryRecord:
return self._obj | python | wandb/sdk/lib/telemetry.py | 31 | 32 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,002 | __exit__ | def __exit__(
self,
exctype: Optional[Type[BaseException]],
excinst: Optional[BaseException],
exctb: Optional[TracebackType],
) -> None:
if not self._run:
return
self._run._telemetry_callback(self._obj) | python | wandb/sdk/lib/telemetry.py | 34 | 42 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,003 | context | def context(
run: Optional["wandb_run.Run"] = None, obj: Optional[TelemetryRecord] = None
) -> ContextManager[TelemetryRecord]:
return _TelemetryObject(run=run, obj=obj) | python | wandb/sdk/lib/telemetry.py | 45 | 48 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,004 | _parse_label_lines | def _parse_label_lines(lines: List[str]) -> Dict[str, str]:
seen = False
ret = {}
for line in lines:
idx = line.find(_LABEL_TOKEN)
if idx < 0:
# Stop parsing on first non token line after match
if seen:
break
continue
seen = True
label_str = line[idx + len(_LABEL_TOKEN) :]
# match identifier (first token without key=value syntax (optional)
# Note: Parse is fairly permissive as it doesnt enforce strict syntax
r = MATCH_RE.match(label_str)
if r:
ret["code"] = r.group("code").replace("-", "_")
label_str = r.group("rest")
# match rest of tokens on one line
tokens = re.findall(
r'([a-zA-Z0-9_]+)\s*=\s*("[a-zA-Z0-9_-]*"|[a-zA-Z0-9_-]*)[,}]', label_str
)
for k, v in tokens:
ret[k] = v.strip('"').replace("-", "_")
return ret | python | wandb/sdk/lib/telemetry.py | 54 | 80 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,005 | list_telemetry_imports | def list_telemetry_imports(only_imported: bool = False) -> Set[str]:
import_telemetry_set = {
desc.name
for desc in TelemetryImports.DESCRIPTOR.fields
if desc.type == desc.TYPE_BOOL
}
if only_imported:
imported_modules_set = set(sys.modules)
return imported_modules_set.intersection(import_telemetry_set)
return import_telemetry_set | python | wandb/sdk/lib/telemetry.py | 83 | 92 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,006 | __init__ | def __init__(self, *args, **kwargs):
object.__setattr__(self, "___dict", {}) | python | wandb/sdk/lib/disabled.py | 5 | 6 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,007 | __add__ | def __add__(self, other):
return self | python | wandb/sdk/lib/disabled.py | 8 | 9 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,008 | __sub__ | def __sub__(self, other):
return self | python | wandb/sdk/lib/disabled.py | 11 | 12 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,009 | __mul__ | def __mul__(self, other):
return self | python | wandb/sdk/lib/disabled.py | 14 | 15 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,010 | __truediv__ | def __truediv__(self, other):
return self | python | wandb/sdk/lib/disabled.py | 17 | 18 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,011 | __floordiv__ | def __floordiv__(self, other):
return self | python | wandb/sdk/lib/disabled.py | 20 | 21 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,012 | __mod__ | def __mod__(self, other):
return self | python | wandb/sdk/lib/disabled.py | 23 | 24 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,013 | __pow__ | def __pow__(self, other, modulo=None):
return self | python | wandb/sdk/lib/disabled.py | 26 | 27 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,014 | __lshift__ | def __lshift__(self, other):
return self | python | wandb/sdk/lib/disabled.py | 29 | 30 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,015 | __rshift__ | def __rshift__(self, other):
return self | python | wandb/sdk/lib/disabled.py | 32 | 33 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,016 | __and__ | def __and__(self, other):
return self | python | wandb/sdk/lib/disabled.py | 35 | 36 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,017 | __xor__ | def __xor__(self, other):
return self | python | wandb/sdk/lib/disabled.py | 38 | 39 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,018 | __or__ | def __or__(self, other):
return self | python | wandb/sdk/lib/disabled.py | 41 | 42 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,019 | __iadd__ | def __iadd__(self, other):
return self | python | wandb/sdk/lib/disabled.py | 44 | 45 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,020 | __isub__ | def __isub__(self, other):
return self | python | wandb/sdk/lib/disabled.py | 47 | 48 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,021 | __imul__ | def __imul__(self, other):
return self | python | wandb/sdk/lib/disabled.py | 50 | 51 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,022 | __idiv__ | def __idiv__(self, other):
return self | python | wandb/sdk/lib/disabled.py | 53 | 54 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,023 | __ifloordiv__ | def __ifloordiv__(self, other):
return self | python | wandb/sdk/lib/disabled.py | 56 | 57 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,024 | __imod__ | def __imod__(self, other):
return self | python | wandb/sdk/lib/disabled.py | 59 | 60 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,025 | __ipow__ | def __ipow__(self, other, modulo=None):
return self | python | wandb/sdk/lib/disabled.py | 62 | 63 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,026 | __ilshift__ | def __ilshift__(self, other):
return self | python | wandb/sdk/lib/disabled.py | 65 | 66 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,027 | __irshift__ | def __irshift__(self, other):
return self | python | wandb/sdk/lib/disabled.py | 68 | 69 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,028 | __iand__ | def __iand__(self, other):
return self | python | wandb/sdk/lib/disabled.py | 71 | 72 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,029 | __ixor__ | def __ixor__(self, other):
return self | python | wandb/sdk/lib/disabled.py | 74 | 75 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,030 | __ior__ | def __ior__(self, other):
return self | python | wandb/sdk/lib/disabled.py | 77 | 78 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,031 | __neg__ | def __neg__(self):
return self | python | wandb/sdk/lib/disabled.py | 80 | 81 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,032 | __pos__ | def __pos__(self):
return self | python | wandb/sdk/lib/disabled.py | 83 | 84 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,033 | __abs__ | def __abs__(self):
return self | python | wandb/sdk/lib/disabled.py | 86 | 87 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,034 | __invert__ | def __invert__(self):
return self | python | wandb/sdk/lib/disabled.py | 89 | 90 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,035 | __complex__ | def __complex__(self):
return 1 + 0j | python | wandb/sdk/lib/disabled.py | 92 | 93 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,036 | __int__ | def __int__(self):
return 1 | python | wandb/sdk/lib/disabled.py | 95 | 96 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,037 | __long__ | def __long__(self):
return 1 | python | wandb/sdk/lib/disabled.py | 98 | 99 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,038 | __float__ | def __float__(self):
return 1.0 | python | wandb/sdk/lib/disabled.py | 101 | 102 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,039 | __oct__ | def __oct__(self):
return oct(1) | python | wandb/sdk/lib/disabled.py | 104 | 105 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,040 | __hex__ | def __hex__(self):
return hex(1) | python | wandb/sdk/lib/disabled.py | 107 | 108 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,041 | __lt__ | def __lt__(self, other):
return True | python | wandb/sdk/lib/disabled.py | 110 | 111 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,042 | __le__ | def __le__(self, other):
return True | python | wandb/sdk/lib/disabled.py | 113 | 114 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,043 | __eq__ | def __eq__(self, other):
return True | python | wandb/sdk/lib/disabled.py | 116 | 117 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,044 | __ne__ | def __ne__(self, other):
return True | python | wandb/sdk/lib/disabled.py | 119 | 120 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,045 | __gt__ | def __gt__(self, other):
return True | python | wandb/sdk/lib/disabled.py | 122 | 123 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,046 | __ge__ | def __ge__(self, other):
return True | python | wandb/sdk/lib/disabled.py | 125 | 126 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,047 | __getattr__ | def __getattr__(self, attr):
return self[attr] | python | wandb/sdk/lib/disabled.py | 128 | 129 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,048 | __getitem__ | def __getitem__(self, key):
d = object.__getattribute__(self, "___dict")
try:
if key in d:
return d[key]
except TypeError:
key = str(key)
if key in d:
return d[key]
dummy = RunDisabled()
d[key] = dummy
return dummy | python | wandb/sdk/lib/disabled.py | 131 | 142 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,049 | __setitem__ | def __setitem__(self, key, value):
object.__getattribute__(self, "___dict")[key] = value | python | wandb/sdk/lib/disabled.py | 144 | 145 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,050 | __setattr__ | def __setattr__(self, key, value):
self[key] = value | python | wandb/sdk/lib/disabled.py | 147 | 148 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,051 | __call__ | def __call__(self, *args, **kwargs):
return RunDisabled() | python | wandb/sdk/lib/disabled.py | 150 | 151 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,052 | __len__ | def __len__(self):
return 1 | python | wandb/sdk/lib/disabled.py | 153 | 154 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,053 | __str__ | def __str__(self):
return "" | python | wandb/sdk/lib/disabled.py | 156 | 157 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,054 | __enter__ | def __enter__(self):
return self | python | wandb/sdk/lib/disabled.py | 159 | 160 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,055 | __exit__ | def __exit__(self, exc_type, exc_val, exc_tb):
return exc_type is None | python | wandb/sdk/lib/disabled.py | 162 | 163 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,056 | __repr__ | def __repr__(self):
return "" | python | wandb/sdk/lib/disabled.py | 165 | 166 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,057 | __nonzero__ | def __nonzero__(self):
return True | python | wandb/sdk/lib/disabled.py | 168 | 169 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,058 | __bool__ | def __bool__(self):
return True | python | wandb/sdk/lib/disabled.py | 171 | 172 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,059 | __getstate__ | def __getstate__(self):
return 1 | python | wandb/sdk/lib/disabled.py | 174 | 175 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,060 | __getattr__ | def __getattr__(self, key):
return self[key] | python | wandb/sdk/lib/disabled.py | 182 | 183 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,061 | __getitem__ | def __getitem__(self, key):
val = dict.__getitem__(self, key)
if isinstance(val, dict) and not isinstance(val, SummaryDisabled):
val = SummaryDisabled(val)
self[key] = val
return val | python | wandb/sdk/lib/disabled.py | 185 | 190 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,062 | isfinite | def isfinite(f):
return not (math.isinf(f) or math.isnan(f)) | python | wandb/sdk/lib/sparkline.py | 11 | 12 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,063 | sparkify | def sparkify(series: List[Union[float, int]]) -> str:
"""Convert <series> to a sparkline string.
Example:
>>> sparkify([ 0.5, 1.2, 3.5, 7.3, 8.0, 12.5, 13.2, 15.0, 14.2, 11.8, 6.1,
... 1.9 ])
u'▁▁▂▄▅▇▇██▆▄▂'
>>> sparkify([1, 1, -2, 3, -5, 8, -13])
u'▆▆▅▆▄█▁'
Raises ValueError if input data cannot be converted to float.
Raises TypeError if series is not an iterable.
"""
series = [float(i) for i in series]
finite_series = [x for x in series if isfinite(x)]
if not finite_series:
return ""
minimum = min(finite_series)
maximum = max(finite_series)
data_range = maximum - minimum
if data_range == 0.0:
# Graph a baseline if every input value is equal.
return "".join([spark_chars[0] if isfinite(x) else " " for x in series])
coefficient = (len(spark_chars) - 1.0) / data_range
return "".join(
[
spark_chars[int(round((x - minimum) * coefficient))] if isfinite(x) else " "
for x in series
]
) | python | wandb/sdk/lib/sparkline.py | 15 | 45 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,064 | __init__ | def __init__(
self, msg: Optional[str] = None, exc: Optional[BaseException] = None
) -> None:
super().__init__(msg)
self.message = msg
self.exception = exc | python | wandb/sdk/lib/retry.py | 35 | 40 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,065 | __init__ | def __init__(
self,
call_fn: Callable[..., _R],
retry_timedelta: Optional[datetime.timedelta] = None,
retry_cancel_event: Optional[threading.Event] = None,
num_retries: Optional[int] = None,
check_retry_fn: CheckRetryFnType = lambda e: True,
retryable_exceptions: Optional[Tuple[Type[Exception], ...]] = None,
error_prefix: str = "Network error",
retry_callback: Optional[Callable[[int, str], Any]] = None,
) -> None:
self._call_fn = call_fn
self._check_retry_fn = check_retry_fn
self._error_prefix = error_prefix
self._last_print = datetime.datetime.now() - datetime.timedelta(minutes=1)
self._retry_timedelta = retry_timedelta
self._retry_cancel_event = retry_cancel_event
self._num_retries = num_retries
if retryable_exceptions is not None:
self._retryable_exceptions = retryable_exceptions
else:
self._retryable_exceptions = (TransientError,)
self._index = 0
self.retry_callback = retry_callback | python | wandb/sdk/lib/retry.py | 55 | 78 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,066 | _sleep_check_cancelled | def _sleep_check_cancelled(
self, wait_seconds: float, cancel_event: Optional[threading.Event]
) -> bool:
if not cancel_event:
SLEEP_FN(wait_seconds)
return False
cancelled = cancel_event.wait(wait_seconds)
return cancelled | python | wandb/sdk/lib/retry.py | 80 | 87 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,067 | num_iters | def num_iters(self) -> int:
"""The number of iterations the previous __call__ retried."""
return self._num_iter | python | wandb/sdk/lib/retry.py | 90 | 92 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,068 | __call__ | def __call__(self, *args: Any, **kwargs: Any) -> _R: # noqa: C901
"""Call the wrapped function, with retries.
Arguments:
retry_timedelta (kwarg): amount of time to retry before giving up.
sleep_base (kwarg): amount of time to sleep upon first failure, all other sleeps
are derived from this one.
"""
retry_timedelta = kwargs.pop("retry_timedelta", self._retry_timedelta)
if retry_timedelta is None:
retry_timedelta = datetime.timedelta(days=365)
retry_cancel_event = kwargs.pop("retry_cancel_event", self._retry_cancel_event)
num_retries = kwargs.pop("num_retries", self._num_retries)
if num_retries is None:
num_retries = 1000000
if os.environ.get("WANDB_TEST"):
num_retries = 0
sleep_base: float = kwargs.pop("retry_sleep_base", 1)
# an extra function to allow performing more logic on the filtered exception
check_retry_fn: CheckRetryFnType = kwargs.pop(
"check_retry_fn", self._check_retry_fn
)
sleep = sleep_base
now = NOW_FN()
start_time = now
start_time_triggered = None
self._num_iter = 0
while True:
try:
result = self._call_fn(*args, **kwargs)
# Only print resolved attempts once every minute
if self._num_iter > 2 and now - self._last_print > datetime.timedelta(
minutes=1
):
self._last_print = NOW_FN()
if self.retry_callback:
self.retry_callback(
200,
"{} resolved after {}, resuming normal operation.".format(
self._error_prefix, NOW_FN() - start_time
),
)
return result
except self._retryable_exceptions as e:
# if the secondary check fails, re-raise
retry_timedelta_triggered = check_retry_fn(e)
if not retry_timedelta_triggered:
raise
# always enforce num_retries no matter which type of exception was seen
if self._num_iter >= num_retries:
raise
now = NOW_FN()
# handle a triggered secondary check which could have a shortened timeout
if isinstance(retry_timedelta_triggered, datetime.timedelta):
# save the time of the first secondary trigger
if not start_time_triggered:
start_time_triggered = now
# make sure that we havent run out of time from secondary trigger
if now - start_time_triggered >= retry_timedelta_triggered:
raise
# always enforce the default timeout from start of retries
if now - start_time >= retry_timedelta:
raise
if self._num_iter == 2:
logger.info("Retry attempt failed:", exc_info=e)
if (
isinstance(e, HTTPError)
and e.response is not None
and self.retry_callback is not None
):
self.retry_callback(e.response.status_code, e.response.text)
else:
# todo: would like to catch other errors, eg wandb.errors.Error, ConnectionError etc
# but some of these can be raised before the retry handler thread (RunStatusChecker) is
# spawned in wandb_init
wandb.termlog(
"{} ({}), entering retry loop.".format(
self._error_prefix, e.__class__.__name__
)
)
# if wandb.env.is_debug():
# traceback.print_exc()
cancelled = self._sleep_check_cancelled(
sleep + random.random() * 0.25 * sleep, cancel_event=retry_cancel_event
)
if cancelled:
raise ContextCancelledError("retry timeout")
sleep *= 2
if sleep > self.MAX_SLEEP_SECONDS:
sleep = self.MAX_SLEEP_SECONDS
now = NOW_FN()
self._num_iter += 1 | python | wandb/sdk/lib/retry.py | 94 | 200 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,069 | retriable | def retriable(*args: Any, **kargs: Any) -> Callable[[_F], _F]:
def decorator(fn: _F) -> _F:
retrier: Retry[Any] = Retry(fn, *args, **kargs)
@functools.wraps(fn)
def wrapped_fn(*args: Any, **kargs: Any) -> Any:
return retrier(*args, **kargs)
return wrapped_fn # type: ignore
return decorator | python | wandb/sdk/lib/retry.py | 206 | 216 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,070 | decorator | def decorator(fn: _F) -> _F:
retrier: Retry[Any] = Retry(fn, *args, **kargs)
@functools.wraps(fn)
def wrapped_fn(*args: Any, **kargs: Any) -> Any:
return retrier(*args, **kargs)
return wrapped_fn # type: ignore | python | wandb/sdk/lib/retry.py | 207 | 214 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,071 | wrapped_fn | def wrapped_fn(*args: Any, **kargs: Any) -> Any:
return retrier(*args, **kargs) | python | wandb/sdk/lib/retry.py | 211 | 212 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,072 | next_sleep_or_reraise | def next_sleep_or_reraise(self, exc: Exception) -> datetime.timedelta:
raise NotImplementedError # pragma: no cover | python | wandb/sdk/lib/retry.py | 223 | 224 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,073 | __init__ | def __init__(
self,
initial_sleep: datetime.timedelta,
max_sleep: datetime.timedelta,
max_retries: Optional[int] = None,
timeout_at: Optional[datetime.datetime] = None,
) -> None:
self._next_sleep = min(max_sleep, initial_sleep)
self._max_sleep = max_sleep
self._remaining_retries = max_retries
self._timeout_at = timeout_at | python | wandb/sdk/lib/retry.py | 230 | 240 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,074 | next_sleep_or_reraise | def next_sleep_or_reraise(self, exc: Exception) -> datetime.timedelta:
if self._remaining_retries is not None:
if self._remaining_retries <= 0:
raise exc
self._remaining_retries -= 1
if self._timeout_at is not None and NOW_FN() > self._timeout_at:
raise exc
result, self._next_sleep = self._next_sleep, min(
self._max_sleep, self._next_sleep * (1 + random.random())
)
return result | python | wandb/sdk/lib/retry.py | 242 | 255 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,075 | __init__ | def __init__(self, filter: Callable[[Exception], bool], wrapped: Backoff) -> None:
self._filter = filter
self._wrapped = wrapped | python | wandb/sdk/lib/retry.py | 261 | 263 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,076 | next_sleep_or_reraise | def next_sleep_or_reraise(self, exc: Exception) -> datetime.timedelta:
if not self._filter(exc):
raise exc
return self._wrapped.next_sleep_or_reraise(exc) | python | wandb/sdk/lib/retry.py | 265 | 268 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,077 | retry_async | async def retry_async(
backoff: Backoff,
fn: Callable[..., Awaitable[_R]],
*args: Any,
on_exc: Optional[Callable[[Exception], None]] = None,
**kwargs: Any,
) -> _R:
"""Call `fn` repeatedly until either it succeeds, or `backoff` decides we should give up.
Each time `fn` fails, `on_exc` is called with the exception.
"""
while True:
try:
return await fn(*args, **kwargs)
except Exception as e:
if on_exc is not None:
on_exc(e)
await SLEEP_ASYNC_FN(backoff.next_sleep_or_reraise(e).total_seconds()) | python | wandb/sdk/lib/retry.py | 271 | 288 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,078 | _log | def _log(
msg_type: str,
log_type: str,
is_response: bool = False,
record: Optional["pb.Record"] = None,
result: Optional["pb.Result"] = None,
resource: Optional[str] = None,
) -> None:
prefix = "TRACELOG(1)"
tname = threading.current_thread().name
now = datetime.datetime.now()
ts = now.strftime("%H%M%S.%f")
arrow = "<-" if is_response else "->"
resource = resource or "unknown"
uuid = ""
data = record or result
record_id = ""
if data:
uuid = data.uuid or uuid
record_id = data._info._tracelog_id
uuid = uuid or "-"
record_id = record_id or "-"
relay = ""
if data and data.control and data.control.relay_id:
relay = data.control.relay_id
relay = relay or "-"
line = f"{prefix} {arrow} {ts} {record_id:16} {log_type:7} {resource:8} {tname:16} {msg_type:32} {uuid:32} {relay:32}"
if tracelog_mode == "stdout":
stdout_write(f"{line}\n")
elif tracelog_mode == "stderr":
stderr_write(f"{line}\n")
elif tracelog_mode == "logger":
logger.info(line) | python | wandb/sdk/lib/tracelog.py | 52 | 84 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,079 | _record_msg_type | def _record_msg_type(record: "pb.Record") -> str:
msg_type = str(record.WhichOneof("record_type"))
if msg_type == "request":
request = record.request
msg_type = str(request.WhichOneof("request_type"))
return msg_type | python | wandb/sdk/lib/tracelog.py | 87 | 92 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,080 | _result_msg_type | def _result_msg_type(result: "pb.Result") -> str:
msg_type = str(result.WhichOneof("result_type"))
if msg_type == "response":
response = result.response
msg_type = str(response.WhichOneof("response_type"))
return msg_type | python | wandb/sdk/lib/tracelog.py | 95 | 100 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,081 | _log_message | def _log_message(
msg: "MessageType", log_type: str, resource: Optional[str] = None
) -> None:
record: Optional["pb.Record"] = None
result: Optional["pb.Result"] = None
is_response = False
msg_type: str
# Note: using strings to avoid an import
message_type_str = type(msg).__name__
if message_type_str == "Record":
record = cast("pb.Record", msg)
msg_type = _record_msg_type(record)
elif message_type_str == "Result":
is_response = True
result = cast("pb.Result", msg)
msg_type = _result_msg_type(result)
elif message_type_str == "ServerRequest":
server_request = cast("spb.ServerRequest", msg)
msg_type = str(server_request.WhichOneof("server_request_type"))
if msg_type == "record_publish":
record = server_request.record_publish
sub_msg_type = _record_msg_type(record)
msg_type = f"pub-{sub_msg_type}"
elif msg_type == "record_communicate":
record = server_request.record_communicate
sub_msg_type = _record_msg_type(record)
msg_type = f"comm-{sub_msg_type}"
# print("SRV", server_request)
elif message_type_str == "ServerResponse":
is_response = True
server_response = cast("spb.ServerResponse", msg)
msg_type = str(server_response.WhichOneof("server_response_type"))
if msg_type == "result_communicate":
result = server_response.result_communicate
sub_msg_type = _result_msg_type(result)
msg_type = f"comm-{sub_msg_type}"
else:
raise AssertionError(f"Unknown message type {message_type_str}")
_log(
msg_type,
is_response=is_response,
record=record,
result=result,
log_type=log_type,
resource=resource,
) | python | wandb/sdk/lib/tracelog.py | 103 | 148 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,082 | _log_message_queue | def _log_message_queue(msg: "MessageQueueType", q: "QueueType") -> None:
_annotate_message(msg)
resource = getattr(q, ANNOTATE_QUEUE_NAME, None)
_log_message(msg, "queue", resource=resource) | python | wandb/sdk/lib/tracelog.py | 151 | 154 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,083 | _log_message_dequeue | def _log_message_dequeue(msg: "MessageQueueType", q: "QueueType") -> None:
resource = getattr(q, ANNOTATE_QUEUE_NAME, None)
_log_message(msg, "dequeue", resource=resource) | python | wandb/sdk/lib/tracelog.py | 157 | 159 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,084 | _log_message_send | def _log_message_send(msg: "MessageType", t: "TransportType") -> None:
_log_message(msg, "send") | python | wandb/sdk/lib/tracelog.py | 162 | 163 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,085 | _log_message_recv | def _log_message_recv(msg: "MessageType", t: "TransportType") -> None:
_log_message(msg, "recv") | python | wandb/sdk/lib/tracelog.py | 166 | 167 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,086 | _log_message_process | def _log_message_process(msg: "MessageType") -> None:
_log_message(msg, "process") | python | wandb/sdk/lib/tracelog.py | 170 | 171 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,087 | _log_message_link | def _log_message_link(src: "MessageType", dest: "MessageType") -> None:
_log_message(src, "source")
_log_message(dest, "dest") | python | wandb/sdk/lib/tracelog.py | 174 | 176 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,088 | _log_message_assert | def _log_message_assert(msg: "MessageType") -> None:
_log_message(msg, "assert") | python | wandb/sdk/lib/tracelog.py | 179 | 180 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,089 | _annotate_queue | def _annotate_queue(q: "QueueType", name: str) -> None:
setattr(q, ANNOTATE_QUEUE_NAME, name) | python | wandb/sdk/lib/tracelog.py | 183 | 184 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,090 | _annotate_message | def _annotate_message(msg: "MessageQueueType") -> None:
record_id = secrets.token_hex(8)
msg._info._tracelog_id = record_id | python | wandb/sdk/lib/tracelog.py | 187 | 189 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,091 | log_message_queue | def log_message_queue(msg: "MessageQueueType", q: "QueueType") -> None:
return None | python | wandb/sdk/lib/tracelog.py | 197 | 198 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,092 | log_message_dequeue | def log_message_dequeue(msg: "MessageQueueType", q: "QueueType") -> None:
return None | python | wandb/sdk/lib/tracelog.py | 201 | 202 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,093 | log_message_send | def log_message_send(msg: "MessageType", t: "TransportType") -> None:
return None | python | wandb/sdk/lib/tracelog.py | 205 | 206 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,094 | log_message_recv | def log_message_recv(msg: "MessageType", t: "TransportType") -> None:
return None | python | wandb/sdk/lib/tracelog.py | 209 | 210 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,095 | log_message_process | def log_message_process(msg: "MessageType") -> None:
return None | python | wandb/sdk/lib/tracelog.py | 213 | 214 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,096 | log_message_link | def log_message_link(src: "MessageType", dest: "MessageType") -> None:
return None | python | wandb/sdk/lib/tracelog.py | 217 | 218 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,097 | log_message_assert | def log_message_assert(msg: "MessageType") -> None:
return None | python | wandb/sdk/lib/tracelog.py | 221 | 222 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,098 | annotate_queue | def annotate_queue(q: "QueueType", name: str) -> None:
return None | python | wandb/sdk/lib/tracelog.py | 225 | 226 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,099 | annotate_message | def annotate_message(msg: "MessageQueueType") -> None:
return None | python | wandb/sdk/lib/tracelog.py | 229 | 230 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
5,100 | enable | def enable(log_mode: Optional[str] = None) -> None:
global tracelog_mode
if log_mode:
tracelog_mode = log_mode
global log_message_queue
global log_message_dequeue
global log_message_send
global log_message_recv
global log_message_process
global log_message_link
global log_message_assert
global annotate_queue
global annotate_message
log_message_queue = _log_message_queue
log_message_dequeue = _log_message_dequeue
log_message_send = _log_message_send
log_message_recv = _log_message_recv
log_message_process = _log_message_process
log_message_link = _log_message_link
log_message_assert = _log_message_assert
annotate_queue = _annotate_queue
annotate_message = _annotate_message | python | wandb/sdk/lib/tracelog.py | 233 | 255 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.