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 |
|---|---|---|---|---|---|---|---|
2,701 | get | def get(self, *args):
return self._items.get(*args) | python | wandb/sdk/wandb_config.py | 189 | 190 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,702 | persist | def persist(self):
"""Call the callback if it's set."""
if self._callback:
self._callback(data=self._as_dict()) | python | wandb/sdk/wandb_config.py | 192 | 195 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,703 | setdefaults | def setdefaults(self, d):
d = wandb_helper.parse_config(d)
# strip out keys already configured
d = {k: v for k, v in d.items() if k not in self._items}
d = self._sanitize_dict(d)
self._items.update(d)
if self._callback:
self._callback(data=d) | python | wandb/sdk/wandb_config.py | 197 | 204 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,704 | update_locked | def update_locked(self, d, user=None, _allow_val_change=None):
if user not in self._users:
self._users[user] = self._users_cnt
self._users_inv[self._users_cnt] = user
object.__setattr__(self, "_users_cnt", self._users_cnt + 1)
num = self._users[user]
for k, v in d.items():
k, v = self._sanitize(k, v, allow_val_change=_allow_val_change)
self._locked[k] = num
self._items[k] = v
if self._callback:
self._callback(data=d) | python | wandb/sdk/wandb_config.py | 206 | 220 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,705 | _load_defaults | def _load_defaults(self):
conf_dict = config_util.dict_from_config_file("config-defaults.yaml")
if conf_dict is not None:
self.update(conf_dict) | python | wandb/sdk/wandb_config.py | 222 | 225 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,706 | _sanitize_dict | def _sanitize_dict(
self,
config_dict,
allow_val_change=None,
ignore_keys: Optional[set] = None,
):
sanitized = {}
self._raise_value_error_on_nested_artifact(config_dict)
for k, v in config_dict.items():
if ignore_keys and k in ignore_keys:
continue
k, v = self._sanitize(k, v, allow_val_change)
sanitized[k] = v
return sanitized | python | wandb/sdk/wandb_config.py | 227 | 240 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,707 | _sanitize | def _sanitize(self, key, val, allow_val_change=None):
# TODO: enable WBValues in the config in the future
# refuse all WBValues which is all Media and Histograms
if isinstance(val, wandb.sdk.data_types.base_types.wb_value.WBValue):
raise ValueError("WBValue objects cannot be added to the run config")
# Let jupyter change config freely by default
if self._settings and self._settings._jupyter and allow_val_change is None:
allow_val_change = True
# We always normalize keys by stripping '-'
key = key.strip("-")
if _is_artifact_representation(val):
val = self._artifact_callback(key, val)
# if the user inserts an artifact into the config
if not (
isinstance(val, wandb.Artifact)
or isinstance(val, wandb.apis.public.Artifact)
):
val = json_friendly_val(val)
if not allow_val_change:
if key in self._items and val != self._items[key]:
raise config_util.ConfigError(
(
'Attempted to change value of key "{}" '
"from {} to {}\n"
"If you really want to do this, pass"
" allow_val_change=True to config.update()"
).format(key, self._items[key], val)
)
return key, val | python | wandb/sdk/wandb_config.py | 242 | 270 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,708 | _raise_value_error_on_nested_artifact | def _raise_value_error_on_nested_artifact(self, v, nested=False):
# we can't swap nested artifacts because their root key can be locked by other values
# best if we don't allow nested artifacts until we can lock nested keys in the config
if isinstance(v, dict) and check_dict_contains_nested_artifact(v, nested):
raise ValueError(
"Instances of wandb.Artifact and wandb.apis.public.Artifact"
" can only be top level keys in wandb.config"
) | python | wandb/sdk/wandb_config.py | 272 | 279 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,709 | __init__ | def __init__(self, config):
object.__setattr__(self, "__dict__", dict(config)) | python | wandb/sdk/wandb_config.py | 283 | 284 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,710 | __setattr__ | def __setattr__(self, name, value):
raise AttributeError("Error: wandb.run.config_static is a readonly object") | python | wandb/sdk/wandb_config.py | 286 | 287 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,711 | __setitem__ | def __setitem__(self, key, val):
raise AttributeError("Error: wandb.run.config_static is a readonly object") | python | wandb/sdk/wandb_config.py | 289 | 290 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,712 | keys | def keys(self):
return self.__dict__.keys() | python | wandb/sdk/wandb_config.py | 292 | 293 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,713 | __getitem__ | def __getitem__(self, key):
return self.__dict__[key] | python | wandb/sdk/wandb_config.py | 295 | 296 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,714 | __str__ | def __str__(self):
return str(self.__dict__) | python | wandb/sdk/wandb_config.py | 298 | 299 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,715 | __init__ | def __init__(
self,
interface: InterfaceBase,
stop_polling_interval: int = 15,
retry_polling_interval: int = 5,
) -> None:
self._interface = interface
self._stop_polling_interval = stop_polling_interval
self._retry_polling_interval = retry_polling_interval
self._join_event = threading.Event()
self._stop_status_lock = threading.Lock()
self._stop_status_handle = None
self._stop_thread = threading.Thread(
target=self.check_stop_status,
name="ChkStopThr",
daemon=True,
)
self._network_status_lock = threading.Lock()
self._network_status_handle = None
self._network_status_thread = threading.Thread(
target=self.check_network_status,
name="NetStatThr",
daemon=True,
) | python | wandb/sdk/wandb_run.py | 169 | 195 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,716 | start | def start(self) -> None:
self._stop_thread.start()
self._network_status_thread.start() | python | wandb/sdk/wandb_run.py | 197 | 199 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,717 | _loop_check_status | def _loop_check_status(
self,
*,
lock: threading.Lock,
set_handle: Any,
timeout: int,
request: Any,
process: Any,
) -> None:
local_handle: Optional[MailboxHandle] = None
join_requested = False
while not join_requested:
time_probe = time.monotonic()
if not local_handle:
local_handle = request()
assert local_handle
with lock:
if self._join_event.is_set():
return
set_handle(local_handle)
try:
result = local_handle.wait(timeout=timeout)
except MailboxError:
# background threads are oportunistically getting results
# from the internal process but the internal process could
# be shutdown at any time. In this case assume that the
# thread should exit silently. This is possible
# because we do not have an atexit handler for the user
# process which quiesces active threads.
break
with lock:
set_handle(None)
if result:
process(result)
# if request finished, clear the handle to send on the next interval
local_handle = None
time_elapsed = time.monotonic() - time_probe
wait_time = max(self._stop_polling_interval - time_elapsed, 0)
join_requested = self._join_event.wait(timeout=wait_time) | python | wandb/sdk/wandb_run.py | 201 | 242 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,718 | check_network_status | def check_network_status(self) -> None:
def _process_network_status(result: Result) -> None:
network_status = result.response.network_status_response
for hr in network_status.network_responses:
if (
hr.http_status_code == 200 or hr.http_status_code == 0
): # we use 0 for non-http errors (eg wandb errors)
wandb.termlog(f"{hr.http_response_text}")
else:
wandb.termlog(
"{} encountered ({}), retrying request".format(
hr.http_status_code, hr.http_response_text.rstrip()
)
)
self._loop_check_status(
lock=self._network_status_lock,
set_handle=lambda x: setattr(self, "_network_status_handle", x),
timeout=self._retry_polling_interval,
request=self._interface.deliver_network_status,
process=_process_network_status,
) | python | wandb/sdk/wandb_run.py | 244 | 265 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,719 | _process_network_status | def _process_network_status(result: Result) -> None:
network_status = result.response.network_status_response
for hr in network_status.network_responses:
if (
hr.http_status_code == 200 or hr.http_status_code == 0
): # we use 0 for non-http errors (eg wandb errors)
wandb.termlog(f"{hr.http_response_text}")
else:
wandb.termlog(
"{} encountered ({}), retrying request".format(
hr.http_status_code, hr.http_response_text.rstrip()
)
) | python | wandb/sdk/wandb_run.py | 245 | 257 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,720 | check_stop_status | def check_stop_status(self) -> None:
def _process_stop_status(result: Result) -> None:
stop_status = result.response.stop_status_response
if stop_status.run_should_stop:
# TODO(frz): This check is required
# until WB-3606 is resolved on server side.
if not wandb.agents.pyagent.is_running():
thread.interrupt_main()
return
self._loop_check_status(
lock=self._stop_status_lock,
set_handle=lambda x: setattr(self, "_stop_status_handle", x),
timeout=self._stop_polling_interval,
request=self._interface.deliver_stop_status,
process=_process_stop_status,
) | python | wandb/sdk/wandb_run.py | 267 | 283 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,721 | _process_stop_status | def _process_stop_status(result: Result) -> None:
stop_status = result.response.stop_status_response
if stop_status.run_should_stop:
# TODO(frz): This check is required
# until WB-3606 is resolved on server side.
if not wandb.agents.pyagent.is_running():
thread.interrupt_main()
return | python | wandb/sdk/wandb_run.py | 268 | 275 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,722 | stop | def stop(self) -> None:
self._join_event.set()
with self._stop_status_lock:
if self._stop_status_handle:
self._stop_status_handle.abandon()
with self._network_status_lock:
if self._network_status_handle:
self._network_status_handle.abandon() | python | wandb/sdk/wandb_run.py | 285 | 292 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,723 | join | def join(self) -> None:
self.stop()
self._stop_thread.join()
self._network_status_thread.join() | python | wandb/sdk/wandb_run.py | 294 | 297 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,724 | _attach | def _attach(cls, func: Callable) -> Callable:
@functools.wraps(func)
def wrapper(self: Type["Run"], *args: Any, **kwargs: Any) -> Any:
# * `_attach_id` is only assigned in service hence for all non-service cases
# it will be a passthrough.
# * `_attach_pid` is only assigned in _init (using _attach_pid guarantees single attach):
# - for non-fork case the object is shared through pickling so will be None.
# - for fork case the new process share mem space hence the value would be of parent process.
if (
getattr(self, "_attach_id", None)
and getattr(self, "_attach_pid", None) != os.getpid()
):
if cls._is_attaching:
message = (
f"Trying to attach `{func.__name__}` "
f"while in the middle of attaching `{cls._is_attaching}`"
)
raise RuntimeError(message)
cls._is_attaching = func.__name__
try:
wandb._attach(run=self)
except Exception as e:
# In case the attach fails we will raise the exception that caused the issue.
# This exception should be caught and fail the execution of the program.
cls._is_attaching = ""
raise e
cls._is_attaching = ""
return func(self, *args, **kwargs)
return wrapper | python | wandb/sdk/wandb_run.py | 307 | 336 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,725 | wrapper | def wrapper(self: Type["Run"], *args: Any, **kwargs: Any) -> Any:
# * `_attach_id` is only assigned in service hence for all non-service cases
# it will be a passthrough.
# * `_attach_pid` is only assigned in _init (using _attach_pid guarantees single attach):
# - for non-fork case the object is shared through pickling so will be None.
# - for fork case the new process share mem space hence the value would be of parent process.
if (
getattr(self, "_attach_id", None)
and getattr(self, "_attach_pid", None) != os.getpid()
):
if cls._is_attaching:
message = (
f"Trying to attach `{func.__name__}` "
f"while in the middle of attaching `{cls._is_attaching}`"
)
raise RuntimeError(message)
cls._is_attaching = func.__name__
try:
wandb._attach(run=self)
except Exception as e:
# In case the attach fails we will raise the exception that caused the issue.
# This exception should be caught and fail the execution of the program.
cls._is_attaching = ""
raise e
cls._is_attaching = ""
return func(self, *args, **kwargs) | python | wandb/sdk/wandb_run.py | 309 | 334 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,726 | _noop_on_finish | def _noop_on_finish(cls, message: str = "", only_warn: bool = False) -> Callable:
def decorator_fn(func: Callable) -> Callable:
@functools.wraps(func)
def wrapper_fn(self: Type["Run"], *args: Any, **kwargs: Any) -> Any:
if not getattr(self, "_is_finished", False):
return func(self, *args, **kwargs)
default_message = (
f"Run ({self.id}) is finished. The call to `{func.__name__}` will be ignored. "
f"Please make sure that you are using an active run."
)
resolved_message = message or default_message
if only_warn:
warnings.warn(resolved_message, UserWarning, stacklevel=2)
else:
raise errors.UsageError(resolved_message)
return wrapper_fn
return decorator_fn | python | wandb/sdk/wandb_run.py | 339 | 358 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,727 | decorator_fn | def decorator_fn(func: Callable) -> Callable:
@functools.wraps(func)
def wrapper_fn(self: Type["Run"], *args: Any, **kwargs: Any) -> Any:
if not getattr(self, "_is_finished", False):
return func(self, *args, **kwargs)
default_message = (
f"Run ({self.id}) is finished. The call to `{func.__name__}` will be ignored. "
f"Please make sure that you are using an active run."
)
resolved_message = message or default_message
if only_warn:
warnings.warn(resolved_message, UserWarning, stacklevel=2)
else:
raise errors.UsageError(resolved_message)
return wrapper_fn | python | wandb/sdk/wandb_run.py | 340 | 356 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,728 | wrapper_fn | def wrapper_fn(self: Type["Run"], *args: Any, **kwargs: Any) -> Any:
if not getattr(self, "_is_finished", False):
return func(self, *args, **kwargs)
default_message = (
f"Run ({self.id}) is finished. The call to `{func.__name__}` will be ignored. "
f"Please make sure that you are using an active run."
)
resolved_message = message or default_message
if only_warn:
warnings.warn(resolved_message, UserWarning, stacklevel=2)
else:
raise errors.UsageError(resolved_message) | python | wandb/sdk/wandb_run.py | 342 | 354 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,729 | _noop | def _noop(cls, func: Callable) -> Callable:
@functools.wraps(func)
def wrapper(self: Type["Run"], *args: Any, **kwargs: Any) -> Any:
# `_attach_id` is only assigned in service hence for all service cases
# it will be a passthrough. We don't pickle non-service so again a way
# to see that we are in non-service case
if getattr(self, "_attach_id", None) is None:
# `_init_pid` is only assigned in __init__ (this will be constant check for mp):
# - for non-fork case the object is shared through pickling,
# and we don't pickle non-service so will be None
# - for fork case the new process share mem space hence the value would be of parent process.
_init_pid = getattr(self, "_init_pid", None)
if _init_pid != os.getpid():
message = "`{}` ignored (called from pid={}, `init` called from pid={}). See: {}".format(
func.__name__,
os.getpid(),
_init_pid,
wburls.get("multiprocess"),
)
# - if this process was pickled in non-service case,
# we ignore the attributes (since pickle is not supported)
# - for fork case will use the settings of the parent process
# - only point of inconsistent behavior from forked and non-forked cases
settings = getattr(self, "_settings", None)
if settings and settings["strict"]:
wandb.termerror(message, repeat=False)
raise errors.UnsupportedError(
f"`{func.__name__}` does not support multiprocessing"
)
wandb.termwarn(message, repeat=False)
return cls.Dummy()
return func(self, *args, **kwargs)
return wrapper | python | wandb/sdk/wandb_run.py | 361 | 395 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,730 | wrapper | def wrapper(self: Type["Run"], *args: Any, **kwargs: Any) -> Any:
# `_attach_id` is only assigned in service hence for all service cases
# it will be a passthrough. We don't pickle non-service so again a way
# to see that we are in non-service case
if getattr(self, "_attach_id", None) is None:
# `_init_pid` is only assigned in __init__ (this will be constant check for mp):
# - for non-fork case the object is shared through pickling,
# and we don't pickle non-service so will be None
# - for fork case the new process share mem space hence the value would be of parent process.
_init_pid = getattr(self, "_init_pid", None)
if _init_pid != os.getpid():
message = "`{}` ignored (called from pid={}, `init` called from pid={}). See: {}".format(
func.__name__,
os.getpid(),
_init_pid,
wburls.get("multiprocess"),
)
# - if this process was pickled in non-service case,
# we ignore the attributes (since pickle is not supported)
# - for fork case will use the settings of the parent process
# - only point of inconsistent behavior from forked and non-forked cases
settings = getattr(self, "_settings", None)
if settings and settings["strict"]:
wandb.termerror(message, repeat=False)
raise errors.UnsupportedError(
f"`{func.__name__}` does not support multiprocessing"
)
wandb.termwarn(message, repeat=False)
return cls.Dummy()
return func(self, *args, **kwargs) | python | wandb/sdk/wandb_run.py | 363 | 393 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,731 | __init__ | def __init__(
self,
settings: Settings,
config: Optional[Dict[str, Any]] = None,
sweep_config: Optional[Dict[str, Any]] = None,
launch_config: Optional[Dict[str, Any]] = None,
) -> None:
# pid is set, so we know if this run object was initialized by this process
self._init_pid = os.getpid()
self._init(
settings=settings,
config=config,
sweep_config=sweep_config,
launch_config=launch_config,
) | python | wandb/sdk/wandb_run.py | 531 | 545 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,732 | _init | def _init(
self,
settings: Settings,
config: Optional[Dict[str, Any]] = None,
sweep_config: Optional[Dict[str, Any]] = None,
launch_config: Optional[Dict[str, Any]] = None,
) -> None:
self._settings = settings
self._config = wandb_config.Config()
self._config._set_callback(self._config_callback)
self._config._set_artifact_callback(self._config_artifact_callback)
self._config._set_settings(self._settings)
self._backend = None
self._internal_run_interface = None
self.summary = wandb_summary.Summary(
self._summary_get_current_summary_callback,
)
self.summary._set_update_callback(self._summary_update_callback)
self._step = 0
self._torch_history: Optional["wandb.wandb_torch.TorchHistory"] = None
# todo: eventually would be nice to make this configurable using self._settings._start_time
# need to test (jhr): if you set start time to 2 days ago and run a test for 15 minutes,
# does the total time get calculated right (not as 2 days and 15 minutes)?
self._start_time = time.time()
_datatypes_set_callback(self._datatypes_callback)
self._printer = get_printer(self._settings._jupyter)
self._wl = None
self._reporter: Optional[Reporter] = None
self._entity = None
self._project = None
self._group = None
self._job_type = None
self._run_id = self._settings.run_id
self._starting_step = 0
self._name = None
self._notes = None
self._tags = None
self._remote_url = None
self._commit = None
self._hooks = None
self._teardown_hooks = []
self._out_redir = None
self._err_redir = None
self._stdout_slave_fd = None
self._stderr_slave_fd = None
self._exit_code = None
self._exit_result = None
self._quiet = self._settings.quiet
self._output_writer = None
self._used_artifact_slots: Dict[str, str] = {}
# Returned from backend request_run(), set from wandb_init?
self._run_obj = None
self._run_obj_offline = None
# Created when the run "starts".
self._run_status_checker = None
self._check_version = None
self._sampled_history = None
self._final_summary = None
self._poll_exit_response = None
self._server_info_response = None
self._poll_exit_handle = None
# Initialize telemetry object
self._telemetry_obj = telemetry.TelemetryRecord()
self._telemetry_obj_active = False
self._telemetry_obj_flushed = b""
self._telemetry_obj_dirty = False
self._atexit_cleanup_called = False
# Pull info from settings
self._init_from_settings(self._settings)
# Initial scope setup for sentry.
# This might get updated when the actual run comes back.
wandb._sentry.configure_scope(
settings=self._settings,
process_context="user",
)
# Populate config
config = config or dict()
wandb_key = "_wandb"
config.setdefault(wandb_key, dict())
self._launch_artifact_mapping: Dict[str, Any] = {}
self._unique_launch_artifact_sequence_names: Dict[str, Any] = {}
if self._settings.save_code and self._settings.program_relpath:
config[wandb_key]["code_path"] = to_forward_slash_path(
os.path.join("code", self._settings.program_relpath)
)
if sweep_config:
self._config.update_locked(
sweep_config, user="sweep", _allow_val_change=True
)
if launch_config:
self._config.update_locked(
launch_config, user="launch", _allow_val_change=True
)
self._config._update(config, ignore_locked=True)
# interface pid and port configured when backend is configured (See _hack_set_run)
# TODO: using pid isn't the best for windows as pid reuse can happen more often than unix
self._iface_pid = None
self._iface_port = None
self._attach_id = None
self._is_attached = False
self._is_finished = False
self._attach_pid = os.getpid()
# for now, use runid as attach id, this could/should be versioned in the future
if not self._settings._disable_service:
self._attach_id = self._settings.run_id | python | wandb/sdk/wandb_run.py | 547 | 670 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,733 | _set_iface_pid | def _set_iface_pid(self, iface_pid: int) -> None:
self._iface_pid = iface_pid | python | wandb/sdk/wandb_run.py | 672 | 673 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,734 | _set_iface_port | def _set_iface_port(self, iface_port: int) -> None:
self._iface_port = iface_port | python | wandb/sdk/wandb_run.py | 675 | 676 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,735 | _handle_launch_artifact_overrides | def _handle_launch_artifact_overrides(self) -> None:
if self._settings.launch and (os.environ.get("WANDB_ARTIFACTS") is not None):
try:
artifacts: Dict[str, Any] = json.loads(
os.environ.get("WANDB_ARTIFACTS", "{}")
)
except (ValueError, SyntaxError):
wandb.termwarn("Malformed WANDB_ARTIFACTS, using original artifacts")
else:
self._initialize_launch_artifact_maps(artifacts)
elif (
self._settings.launch
and self._settings.launch_config_path
and os.path.exists(self._settings.launch_config_path)
):
self._save(self._settings.launch_config_path)
with open(self._settings.launch_config_path) as fp:
launch_config = json.loads(fp.read())
if launch_config.get("overrides", {}).get("artifacts") is not None:
artifacts = launch_config.get("overrides").get("artifacts")
self._initialize_launch_artifact_maps(artifacts) | python | wandb/sdk/wandb_run.py | 678 | 699 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,736 | _initialize_launch_artifact_maps | def _initialize_launch_artifact_maps(self, artifacts: Dict[str, Any]) -> None:
for key, item in artifacts.items():
self._launch_artifact_mapping[key] = item
artifact_sequence_tuple_or_slot = key.split(":")
if len(artifact_sequence_tuple_or_slot) == 2:
sequence_name = artifact_sequence_tuple_or_slot[0].split("/")[-1]
if self._unique_launch_artifact_sequence_names.get(sequence_name):
self._unique_launch_artifact_sequence_names.pop(sequence_name)
else:
self._unique_launch_artifact_sequence_names[sequence_name] = item | python | wandb/sdk/wandb_run.py | 701 | 711 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,737 | _telemetry_callback | def _telemetry_callback(self, telem_obj: telemetry.TelemetryRecord) -> None:
self._telemetry_obj.MergeFrom(telem_obj)
self._telemetry_obj_dirty = True
self._telemetry_flush() | python | wandb/sdk/wandb_run.py | 713 | 716 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,738 | _telemetry_flush | def _telemetry_flush(self) -> None:
if not self._telemetry_obj_active:
return
if not self._telemetry_obj_dirty:
return
if self._backend and self._backend.interface:
serialized = self._telemetry_obj.SerializeToString()
if serialized == self._telemetry_obj_flushed:
return
self._backend.interface._publish_telemetry(self._telemetry_obj)
self._telemetry_obj_flushed = serialized
self._telemetry_obj_dirty = False | python | wandb/sdk/wandb_run.py | 718 | 729 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,739 | _freeze | def _freeze(self) -> None:
self._frozen = True | python | wandb/sdk/wandb_run.py | 731 | 732 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,740 | __setattr__ | def __setattr__(self, attr: str, value: object) -> None:
if getattr(self, "_frozen", None) and not hasattr(self, attr):
raise Exception(f"Attribute {attr} is not supported on Run object.")
super().__setattr__(attr, value) | python | wandb/sdk/wandb_run.py | 734 | 737 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,741 | _update_settings | def _update_settings(self, settings: Settings) -> None:
self._settings = settings
self._init_from_settings(settings) | python | wandb/sdk/wandb_run.py | 739 | 741 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,742 | _init_from_settings | def _init_from_settings(self, settings: Settings) -> None:
if settings.entity is not None:
self._entity = settings.entity
if settings.project is not None:
self._project = settings.project
if settings.run_group is not None:
self._group = settings.run_group
if settings.run_job_type is not None:
self._job_type = settings.run_job_type
if settings.run_name is not None:
self._name = settings.run_name
if settings.run_notes is not None:
self._notes = settings.run_notes
if settings.run_tags is not None:
self._tags = settings.run_tags | python | wandb/sdk/wandb_run.py | 743 | 757 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,743 | _make_proto_run | def _make_proto_run(self, run: RunRecord) -> None:
"""Populate protocol buffer RunData for interface/interface."""
if self._entity is not None:
run.entity = self._entity
if self._project is not None:
run.project = self._project
if self._group is not None:
run.run_group = self._group
if self._job_type is not None:
run.job_type = self._job_type
if self._run_id is not None:
run.run_id = self._run_id
if self._name is not None:
run.display_name = self._name
if self._notes is not None:
run.notes = self._notes
if self._tags is not None:
for tag in self._tags:
run.tags.append(tag)
if self._start_time is not None:
run.start_time.FromMicroseconds(int(self._start_time * 1e6))
if self._remote_url is not None:
run.git.remote_url = self._remote_url
if self._commit is not None:
run.git.commit = self._commit
# Note: run.config is set in interface/interface:_make_run() | python | wandb/sdk/wandb_run.py | 759 | 784 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,744 | _populate_git_info | def _populate_git_info(self) -> None:
# Use user provided git info if available otherwise resolve it from the environment
try:
repo = GitRepo(
root=self._settings.git_root,
remote=self._settings.git_remote,
remote_url=self._settings.git_remote_url,
commit=self._settings.git_commit,
lazy=False,
)
self._remote_url, self._commit = repo.remote_url, repo.last_commit
except Exception:
wandb.termwarn("Cannot find valid git repo associated with this directory.") | python | wandb/sdk/wandb_run.py | 786 | 798 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,745 | __deepcopy__ | def __deepcopy__(self, memo: Dict[int, Any]) -> "Run":
return self | python | wandb/sdk/wandb_run.py | 800 | 801 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,746 | __getstate__ | def __getstate__(self) -> Any:
"""Return run state as a custom pickle."""
# We only pickle in service mode
if not self._settings or self._settings._disable_service:
return
_attach_id = self._attach_id
if not _attach_id:
return
return dict(
_attach_id=_attach_id,
_init_pid=self._init_pid,
_is_finished=self._is_finished,
) | python | wandb/sdk/wandb_run.py | 803 | 817 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,747 | __setstate__ | def __setstate__(self, state: Any) -> None:
"""Set run state from a custom pickle."""
if not state:
return
_attach_id = state.get("_attach_id")
if not _attach_id:
return
if state["_init_pid"] == os.getpid():
raise RuntimeError("attach in the same process is not supported currently")
self.__dict__.update(state) | python | wandb/sdk/wandb_run.py | 819 | 831 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,748 | _torch | def _torch(self) -> "wandb.wandb_torch.TorchHistory":
if self._torch_history is None:
self._torch_history = wandb.wandb_torch.TorchHistory()
return self._torch_history | python | wandb/sdk/wandb_run.py | 834 | 837 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,749 | settings | def settings(self) -> Settings:
"""A frozen copy of run's Settings object."""
cp = self._settings.copy()
cp.freeze()
return cp | python | wandb/sdk/wandb_run.py | 841 | 845 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,750 | dir | def dir(self) -> str:
"""The directory where files associated with the run are saved."""
return self._settings.files_dir | python | wandb/sdk/wandb_run.py | 849 | 851 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,751 | config | def config(self) -> wandb_config.Config:
"""Config object associated with this run."""
return self._config | python | wandb/sdk/wandb_run.py | 855 | 857 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,752 | config_static | def config_static(self) -> wandb_config.ConfigStatic:
return wandb_config.ConfigStatic(self._config) | python | wandb/sdk/wandb_run.py | 861 | 862 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,753 | name | def name(self) -> Optional[str]:
"""Display name of the run.
Display names are not guaranteed to be unique and may be descriptive.
By default, they are randomly generated.
"""
if self._name:
return self._name
if not self._run_obj:
return None
return self._run_obj.display_name | python | wandb/sdk/wandb_run.py | 866 | 876 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,754 | name | def name(self, name: str) -> None:
with telemetry.context(run=self) as tel:
tel.feature.set_run_name = True
self._name = name
if self._backend and self._backend.interface:
run = self._backend.interface._make_run(self)
self._backend.interface.publish_run(run) | python | wandb/sdk/wandb_run.py | 880 | 886 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,755 | notes | def notes(self) -> Optional[str]:
"""Notes associated with the run, if there are any.
Notes can be a multiline string and can also use markdown and latex equations
inside `$$`, like `$x + 3$`.
"""
if self._notes:
return self._notes
if not self._run_obj:
return None
return self._run_obj.notes | python | wandb/sdk/wandb_run.py | 890 | 900 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,756 | notes | def notes(self, notes: str) -> None:
self._notes = notes
if self._backend and self._backend.interface:
run = self._backend.interface._make_run(self)
self._backend.interface.publish_run(run) | python | wandb/sdk/wandb_run.py | 904 | 908 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,757 | tags | def tags(self) -> Optional[Tuple]:
"""Tags associated with the run, if there are any."""
if self._tags:
return self._tags
run_obj = self._run_obj or self._run_obj_offline
if run_obj:
return tuple(run_obj.tags)
return None | python | wandb/sdk/wandb_run.py | 912 | 919 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,758 | tags | def tags(self, tags: Sequence) -> None:
with telemetry.context(run=self) as tel:
tel.feature.set_run_tags = True
self._tags = tuple(tags)
if self._backend and self._backend.interface:
run = self._backend.interface._make_run(self)
self._backend.interface.publish_run(run) | python | wandb/sdk/wandb_run.py | 923 | 929 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,759 | id | def id(self) -> str:
"""Identifier for this run."""
if TYPE_CHECKING:
assert self._run_id is not None
return self._run_id | python | wandb/sdk/wandb_run.py | 933 | 937 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,760 | sweep_id | def sweep_id(self) -> Optional[str]:
"""ID of the sweep associated with the run, if there is one."""
if not self._run_obj:
return None
return self._run_obj.sweep_id or None | python | wandb/sdk/wandb_run.py | 941 | 945 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,761 | _get_path | def _get_path(self) -> str:
parts = [
e for e in [self._entity, self._project, self._run_id] if e is not None
]
return "/".join(parts) | python | wandb/sdk/wandb_run.py | 947 | 951 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,762 | path | def path(self) -> str:
"""Path to the run.
Run paths include entity, project, and run ID, in the format
`entity/project/run_id`.
"""
return self._get_path() | python | wandb/sdk/wandb_run.py | 955 | 961 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,763 | _get_start_time | def _get_start_time(self) -> float:
return (
self._start_time
if not self._run_obj
else (self._run_obj.start_time.ToMicroseconds() / 1e6)
) | python | wandb/sdk/wandb_run.py | 963 | 968 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,764 | start_time | def start_time(self) -> float:
"""Unix timestamp (in seconds) of when the run started."""
return self._get_start_time() | python | wandb/sdk/wandb_run.py | 972 | 974 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,765 | _get_starting_step | def _get_starting_step(self) -> int:
return self._starting_step if not self._run_obj else self._run_obj.starting_step | python | wandb/sdk/wandb_run.py | 976 | 977 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,766 | starting_step | def starting_step(self) -> int:
"""The first step of the run."""
return self._get_starting_step() | python | wandb/sdk/wandb_run.py | 981 | 983 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,767 | resumed | def resumed(self) -> bool:
"""True if the run was resumed, False otherwise."""
return self._run_obj.resumed if self._run_obj else False | python | wandb/sdk/wandb_run.py | 987 | 989 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,768 | step | def step(self) -> int:
"""Current value of the step.
This counter is incremented by `wandb.log`.
"""
return self._step | python | wandb/sdk/wandb_run.py | 993 | 998 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,769 | project_name | def project_name(self) -> str:
run_obj = self._run_obj or self._run_obj_offline
return run_obj.project if run_obj else "" | python | wandb/sdk/wandb_run.py | 1,000 | 1,002 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,770 | mode | def mode(self) -> str:
"""For compatibility with `0.9.x` and earlier, deprecate eventually."""
deprecate.deprecate(
field_name=deprecate.Deprecated.run__mode,
warning_message=(
"The mode property of wandb.run is deprecated "
"and will be removed in a future release."
),
)
return "dryrun" if self._settings._offline else "run" | python | wandb/sdk/wandb_run.py | 1,006 | 1,015 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,771 | offline | def offline(self) -> bool:
return self._settings._offline | python | wandb/sdk/wandb_run.py | 1,019 | 1,020 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,772 | disabled | def disabled(self) -> bool:
return self._settings._noop | python | wandb/sdk/wandb_run.py | 1,024 | 1,025 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,773 | _get_group | def _get_group(self) -> str:
run_obj = self._run_obj or self._run_obj_offline
return run_obj.run_group if run_obj else "" | python | wandb/sdk/wandb_run.py | 1,027 | 1,029 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,774 | group | def group(self) -> str:
"""Name of the group associated with the run.
Setting a group helps the W&B UI organize runs in a sensible way.
If you are doing a distributed training you should give all of the
runs in the training the same group.
If you are doing crossvalidation you should give all the crossvalidation
folds the same group.
"""
return self._get_group() | python | wandb/sdk/wandb_run.py | 1,033 | 1,043 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,775 | job_type | def job_type(self) -> str:
run_obj = self._run_obj or self._run_obj_offline
return run_obj.job_type if run_obj else "" | python | wandb/sdk/wandb_run.py | 1,047 | 1,049 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,776 | project | def project(self) -> str:
"""Name of the W&B project associated with the run."""
return self.project_name() | python | wandb/sdk/wandb_run.py | 1,053 | 1,055 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,777 | log_code | def log_code(
self,
root: Optional[str] = ".",
name: Optional[str] = None,
include_fn: Callable[[str], bool] = _is_py_path,
exclude_fn: Callable[[str], bool] = filenames.exclude_wandb_fn,
) -> Optional[Artifact]:
"""Save the current state of your code to a W&B Artifact.
By default, it walks the current directory and logs all files that end with `.py`.
Arguments:
root: The relative (to `os.getcwd()`) or absolute path to recursively find code from.
name: (str, optional) The name of our code artifact. By default, we'll name
the artifact `source-$PROJECT_ID-$ENTRYPOINT_RELPATH`. There may be scenarios where you want
many runs to share the same artifact. Specifying name allows you to achieve that.
include_fn: A callable that accepts a file path and
returns True when it should be included and False otherwise. This
defaults to: `lambda path: path.endswith(".py")`
exclude_fn: A callable that accepts a file path and returns `True` when it should be
excluded and `False` otherwise. This defaults to: `lambda path: False`
Examples:
Basic usage
```python
run.log_code()
```
Advanced usage
```python
run.log_code(
"../", include_fn=lambda path: path.endswith(".py") or path.endswith(".ipynb")
)
```
Returns:
An `Artifact` object if code was logged
"""
if name is None:
name_string = wandb.util.make_artifact_name_safe(
f"{self._project}-{self._settings.program_relpath}"
)
name = f"source-{name_string}"
art = wandb.Artifact(name, "code")
files_added = False
if root is not None:
root = os.path.abspath(root)
for file_path in filenames.filtered_dir(root, include_fn, exclude_fn):
files_added = True
save_name = os.path.relpath(file_path, root)
art.add_file(file_path, name=save_name)
# Add any manually staged files such is ipynb notebooks
for dirpath, _, files in os.walk(self._settings._tmp_code_dir):
for fname in files:
file_path = os.path.join(dirpath, fname)
save_name = os.path.relpath(file_path, self._settings._tmp_code_dir)
files_added = True
art.add_file(file_path, name=save_name)
if not files_added:
return None
return self._log_artifact(art) | python | wandb/sdk/wandb_run.py | 1,059 | 1,120 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,778 | get_url | def get_url(self) -> Optional[str]:
"""Return the url for the W&B run, if there is one.
Offline runs will not have a url.
"""
if self._settings._offline:
wandb.termwarn("URL not available in offline run")
return None
return self._settings.run_url | python | wandb/sdk/wandb_run.py | 1,122 | 1,130 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,779 | get_project_url | def get_project_url(self) -> Optional[str]:
"""Return the url for the W&B project associated with the run, if there is one.
Offline runs will not have a project url.
"""
if self._settings._offline:
wandb.termwarn("URL not available in offline run")
return None
return self._settings.project_url | python | wandb/sdk/wandb_run.py | 1,132 | 1,140 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,780 | get_sweep_url | def get_sweep_url(self) -> Optional[str]:
"""Return the url for the sweep associated with the run, if there is one."""
if self._settings._offline:
wandb.termwarn("URL not available in offline run")
return None
return self._settings.sweep_url | python | wandb/sdk/wandb_run.py | 1,142 | 1,147 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,781 | url | def url(self) -> Optional[str]:
"""The W&B url associated with the run."""
return self.get_url() | python | wandb/sdk/wandb_run.py | 1,151 | 1,153 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,782 | entity | def entity(self) -> str:
"""The name of the W&B entity associated with the run.
Entity can be a user name or the name of a team or organization.
"""
return self._entity or "" | python | wandb/sdk/wandb_run.py | 1,157 | 1,162 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,783 | _label_internal | def _label_internal(
self,
code: Optional[str] = None,
repo: Optional[str] = None,
code_version: Optional[str] = None,
) -> None:
with telemetry.context(run=self) as tel:
if code and RE_LABEL.match(code):
tel.label.code_string = code
if repo and RE_LABEL.match(repo):
tel.label.repo_string = repo
if code_version and RE_LABEL.match(code_version):
tel.label.code_version = code_version | python | wandb/sdk/wandb_run.py | 1,164 | 1,176 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,784 | _label | def _label(
self,
code: Optional[str] = None,
repo: Optional[str] = None,
code_version: Optional[str] = None,
**kwargs: str,
) -> None:
if self._settings.label_disable:
return
for k, v in (("code", code), ("repo", repo), ("code_version", code_version)):
if v and not RE_LABEL.match(v):
wandb.termwarn(
"Label added for '{}' with invalid identifier '{}' (ignored).".format(
k, v
),
repeat=False,
)
for v in kwargs:
wandb.termwarn(
f"Label added for unsupported key {v!r} (ignored).",
repeat=False,
)
self._label_internal(code=code, repo=repo, code_version=code_version)
# update telemetry in the backend immediately for _label() callers
self._telemetry_flush() | python | wandb/sdk/wandb_run.py | 1,178 | 1,204 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,785 | _label_probe_lines | def _label_probe_lines(self, lines: List[str]) -> None:
if not lines:
return
parsed = telemetry._parse_label_lines(lines)
if not parsed:
return
label_dict = {}
code = parsed.get("code") or parsed.get("c")
if code:
label_dict["code"] = code
repo = parsed.get("repo") or parsed.get("r")
if repo:
label_dict["repo"] = repo
code_ver = parsed.get("version") or parsed.get("v")
if code_ver:
label_dict["code_version"] = code_ver
self._label_internal(**label_dict) | python | wandb/sdk/wandb_run.py | 1,206 | 1,222 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,786 | _label_probe_main | def _label_probe_main(self) -> None:
m = sys.modules.get("__main__")
if not m:
return
doc = getattr(m, "__doc__", None)
if not doc:
return
doclines = doc.splitlines()
self._label_probe_lines(doclines) | python | wandb/sdk/wandb_run.py | 1,224 | 1,233 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,787 | _label_probe_notebook | def _label_probe_notebook(self, notebook: Any) -> None:
logger.info("probe notebook")
lines = None
try:
data = notebook.probe_ipynb()
cell0 = data.get("cells", [])[0]
lines = cell0.get("source")
# kaggle returns a string instead of a list
if isinstance(lines, str):
lines = lines.split()
except Exception as e:
logger.info(f"Unable to probe notebook: {e}")
return
if lines:
self._label_probe_lines(lines) | python | wandb/sdk/wandb_run.py | 1,236 | 1,250 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,788 | display | def display(self, height: int = 420, hidden: bool = False) -> bool:
"""Display this run in jupyter."""
if self._settings._jupyter and ipython.in_jupyter():
ipython.display_html(self.to_html(height, hidden))
return True
else:
wandb.termwarn(".display() only works in jupyter environments")
return False | python | wandb/sdk/wandb_run.py | 1,253 | 1,260 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,789 | to_html | def to_html(self, height: int = 420, hidden: bool = False) -> str:
"""Generate HTML containing an iframe displaying the current run."""
url = self._settings.run_url + "?jupyter=true"
style = f"border:none;width:100%;height:{height}px;"
prefix = ""
if hidden:
style += "display:none;"
prefix = ipython.toggle_button()
return prefix + f"<iframe src={url!r} style={style!r}></iframe>" | python | wandb/sdk/wandb_run.py | 1,263 | 1,271 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,790 | _repr_mimebundle_ | def _repr_mimebundle_(
self, include: Optional[Any] = None, exclude: Optional[Any] = None
) -> Dict[str, str]:
return {"text/html": self.to_html(hidden=True)} | python | wandb/sdk/wandb_run.py | 1,273 | 1,276 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,791 | _config_callback | def _config_callback(
self,
key: Optional[Union[Tuple[str, ...], str]] = None,
val: Optional[Any] = None,
data: Optional[Dict[str, object]] = None,
) -> None:
logger.info(f"config_cb {key} {val} {data}")
if self._backend and self._backend.interface:
self._backend.interface.publish_config(key=key, val=val, data=data) | python | wandb/sdk/wandb_run.py | 1,279 | 1,287 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,792 | _config_artifact_callback | def _config_artifact_callback(
self, key: str, val: Union[str, Artifact, dict]
) -> Union[Artifact, public.Artifact]:
# artifacts can look like dicts as they are passed into the run config
# since the run config stores them on the backend as a dict with fields shown
# in wandb.util.artifact_to_json
if _is_artifact_version_weave_dict(val):
assert isinstance(val, dict)
public_api = self._public_api()
artifact = public.Artifact.from_id(val["id"], public_api.client)
return self.use_artifact(artifact, use_as=key)
elif _is_artifact_string(val):
# this will never fail, but is required to make mypy happy
assert isinstance(val, str)
artifact_string, base_url, is_id = parse_artifact_string(val)
overrides = {}
if base_url is not None:
overrides = {"base_url": base_url}
public_api = public.Api(overrides)
else:
public_api = self._public_api()
if is_id:
artifact = public.Artifact.from_id(artifact_string, public_api._client)
else:
artifact = public_api.artifact(name=artifact_string)
# in the future we'll need to support using artifacts from
# different instances of wandb. simplest way to do that is
# likely to convert the retrieved public.Artifact to a wandb.Artifact
return self.use_artifact(artifact, use_as=key)
elif _is_artifact_object(val):
return self.use_artifact(val, use_as=key)
else:
raise ValueError(
f"Cannot call _config_artifact_callback on type {type(val)}"
) | python | wandb/sdk/wandb_run.py | 1,289 | 1,324 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,793 | _set_config_wandb | def _set_config_wandb(self, key: str, val: Any) -> None:
self._config_callback(key=("_wandb", key), val=val) | python | wandb/sdk/wandb_run.py | 1,326 | 1,327 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,794 | _summary_update_callback | def _summary_update_callback(self, summary_record: SummaryRecord) -> None:
if self._backend and self._backend.interface:
self._backend.interface.publish_summary(summary_record) | python | wandb/sdk/wandb_run.py | 1,330 | 1,332 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,795 | _on_progress_get_summary | def _on_progress_get_summary(self, handle: MailboxProgress) -> None:
pass
# TODO(jhr): enable printing for get_summary in later mailbox dev phase
# line = "Waiting for run.summary data..."
# self._printer.display(line) | python | wandb/sdk/wandb_run.py | 1,334 | 1,338 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,796 | _summary_get_current_summary_callback | def _summary_get_current_summary_callback(self) -> Dict[str, Any]:
if not self._backend or not self._backend.interface:
return {}
handle = self._backend.interface.deliver_get_summary()
result = handle.wait(
timeout=self._settings.summary_timeout,
on_progress=self._on_progress_get_summary,
)
if not result:
return {}
get_summary_response = result.response.get_summary_response
return proto_util.dict_from_proto_list(get_summary_response.item) | python | wandb/sdk/wandb_run.py | 1,340 | 1,351 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,797 | _metric_callback | def _metric_callback(self, metric_record: MetricRecord) -> None:
if self._backend and self._backend.interface:
self._backend.interface._publish_metric(metric_record) | python | wandb/sdk/wandb_run.py | 1,353 | 1,355 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,798 | _datatypes_callback | def _datatypes_callback(self, fname: str) -> None:
if not self._backend or not self._backend.interface:
return
files: "FilesDict" = dict(files=[(GlobStr(glob.escape(fname)), "now")])
self._backend.interface.publish_files(files) | python | wandb/sdk/wandb_run.py | 1,357 | 1,361 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,799 | _visualization_hack | def _visualization_hack(self, row: Dict[str, Any]) -> Dict[str, Any]:
# TODO(jhr): move visualize hack somewhere else
chart_keys = set()
for k in row:
if isinstance(row[k], Visualize):
key = row[k].get_config_key(k)
value = row[k].get_config_value(k)
row[k] = row[k]._data
self._config_callback(val=value, key=key)
elif isinstance(row[k], CustomChart):
chart_keys.add(k)
key = row[k].get_config_key(k)
value = row[k].get_config_value(
"Vega2", row[k].user_query(f"{k}_table")
)
row[k] = row[k]._data
self._config_callback(val=value, key=key)
for k in chart_keys:
# remove the chart key from the row
# TODO: is this really the right move? what if the user logs
# a non-custom chart to this key?
row[f"{k}_table"] = row.pop(k)
return row | python | wandb/sdk/wandb_run.py | 1,363 | 1,386 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
2,800 | _partial_history_callback | def _partial_history_callback(
self,
row: Dict[str, Any],
step: Optional[int] = None,
commit: Optional[bool] = None,
) -> None:
row = row.copy()
if row:
row = self._visualization_hack(row)
if self._backend and self._backend.interface:
not_using_tensorboard = len(wandb.patched["tensorboard"]) == 0
self._backend.interface.publish_partial_history(
row,
user_step=self._step,
step=step,
flush=commit,
publish_step=not_using_tensorboard,
) | python | wandb/sdk/wandb_run.py | 1,388 | 1,407 | {
"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.