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
4,801
clear
def clear(self) -> None: self.samples.clear()
python
wandb/sdk/internal/system/assets/gpu.py
207
208
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
4,802
aggregate
def aggregate(self) -> dict: if not self.samples: return {} stats = {} device_count = pynvml.nvmlDeviceGetCount() # type: ignore for i in range(device_count): samples = [sample[i] for sample in self.samples] aggregate = aggregate_mean(samples) stats[self.name.format(i)] = aggregate handle = pynvml.nvmlDeviceGetHandleByIndex(i) # type: ignore if gpu_in_use_by_this_process(handle, self.pid): stats[self.name.format(f"process.{i}")] = aggregate return stats
python
wandb/sdk/internal/system/assets/gpu.py
210
224
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
4,803
__init__
def __init__(self, pid: int) -> None: self.pid = pid self.samples = deque([])
python
wandb/sdk/internal/system/assets/gpu.py
234
236
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
4,804
sample
def sample(self) -> None: power_usage = [] device_count = pynvml.nvmlDeviceGetCount() # type: ignore for i in range(device_count): handle = pynvml.nvmlDeviceGetHandleByIndex(i) # type: ignore power_watts = pynvml.nvmlDeviceGetPowerUsage(handle) / 1000 # type: ignore power_usage.append(power_watts) self.samples.append(power_usage)
python
wandb/sdk/internal/system/assets/gpu.py
238
245
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
4,805
clear
def clear(self) -> None: self.samples.clear()
python
wandb/sdk/internal/system/assets/gpu.py
247
248
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
4,806
aggregate
def aggregate(self) -> dict: stats = {} device_count = pynvml.nvmlDeviceGetCount() # type: ignore for i in range(device_count): samples = [sample[i] for sample in self.samples] aggregate = aggregate_mean(samples) stats[self.name.format(i)] = aggregate handle = pynvml.nvmlDeviceGetHandleByIndex(i) # type: ignore if gpu_in_use_by_this_process(handle, self.pid): stats[self.name.format(f"process.{i}")] = aggregate return stats
python
wandb/sdk/internal/system/assets/gpu.py
250
262
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
4,807
__init__
def __init__(self, pid: int) -> None: self.pid = pid self.samples = deque([])
python
wandb/sdk/internal/system/assets/gpu.py
272
274
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
4,808
sample
def sample(self) -> None: power_usage = [] device_count = pynvml.nvmlDeviceGetCount() # type: ignore for i in range(device_count): handle = pynvml.nvmlDeviceGetHandleByIndex(i) # type: ignore power_watts = pynvml.nvmlDeviceGetPowerUsage(handle) # type: ignore power_capacity_watts = pynvml.nvmlDeviceGetEnforcedPowerLimit(handle) # type: ignore power_usage.append((power_watts / power_capacity_watts) * 100) self.samples.append(power_usage)
python
wandb/sdk/internal/system/assets/gpu.py
276
284
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
4,809
clear
def clear(self) -> None: self.samples.clear()
python
wandb/sdk/internal/system/assets/gpu.py
286
287
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
4,810
aggregate
def aggregate(self) -> dict: if not self.samples: return {} stats = {} device_count = pynvml.nvmlDeviceGetCount() # type: ignore for i in range(device_count): samples = [sample[i] for sample in self.samples] aggregate = aggregate_mean(samples) stats[self.name.format(i)] = aggregate handle = pynvml.nvmlDeviceGetHandleByIndex(i) # type: ignore if gpu_in_use_by_this_process(handle, self.pid): stats[self.name.format(f"process.{i}")] = aggregate return stats
python
wandb/sdk/internal/system/assets/gpu.py
289
303
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
4,811
__init__
def __init__( self, interface: "Interface", settings: "SettingsStatic", shutdown_event: threading.Event, ) -> None: self.name = self.__class__.__name__.lower() self.metrics: List[Metric] = [ GPUMemoryAllocated(settings._stats_pid), GPUMemoryUtilization(settings._stats_pid), GPUUtilization(settings._stats_pid), GPUTemperature(settings._stats_pid), GPUPowerUsageWatts(settings._stats_pid), GPUPowerUsagePercent(settings._stats_pid), ] self.metrics_monitor = MetricsMonitor( self.name, self.metrics, interface, settings, shutdown_event, )
python
wandb/sdk/internal/system/assets/gpu.py
308
329
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
4,812
is_available
def is_available(cls) -> bool: try: pynvml.nvmlInit() # type: ignore return True except pynvml.NVMLError_LibraryNotFound: # type: ignore return False except Exception as e: logger.error(f"Error initializing NVML: {e}") return False
python
wandb/sdk/internal/system/assets/gpu.py
332
340
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
4,813
start
def start(self) -> None: self.metrics_monitor.start()
python
wandb/sdk/internal/system/assets/gpu.py
342
343
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
4,814
finish
def finish(self) -> None: self.metrics_monitor.finish()
python
wandb/sdk/internal/system/assets/gpu.py
345
346
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
4,815
probe
def probe(self) -> dict: info = {} try: pynvml.nvmlInit() # type: ignore # todo: this is an adapter for the legacy stats system: info["gpu"] = pynvml.nvmlDeviceGetName(pynvml.nvmlDeviceGetHandleByIndex(0)) # type: ignore info["gpu_count"] = pynvml.nvmlDeviceGetCount() # type: ignore device_count = pynvml.nvmlDeviceGetCount() # type: ignore devices = [] for i in range(device_count): handle = pynvml.nvmlDeviceGetHandleByIndex(i) # type: ignore gpu_info = pynvml.nvmlDeviceGetMemoryInfo(handle) # type: ignore devices.append( { "name": pynvml.nvmlDeviceGetName(handle), "memory_total": gpu_info.total, } ) info["gpu_devices"] = devices except pynvml.NVMLError: pass return info
python
wandb/sdk/internal/system/assets/gpu.py
348
372
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
4,816
__init__
def __init__(self, target: Callable, kwargs: Dict[str, Any]) -> None: threading.Thread.__init__(self) self.name = "BackendThr" self._target = target self._kwargs = kwargs self.daemon = True self.pid = 0
python
wandb/sdk/backend/backend.py
41
47
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
4,817
run
def run(self) -> None: self._target(**self._kwargs)
python
wandb/sdk/backend/backend.py
49
50
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
4,818
__init__
def __init__( self, mailbox: Mailbox, settings: Optional[Settings] = None, log_level: Optional[int] = None, manager: Optional[_Manager] = None, ) -> None: self._done = False self.record_q = None self.result_q = None self.wandb_process = None self.interface = None self._internal_pid = None self._settings = settings self._log_level = log_level self._manager = manager self._mailbox = mailbox self._multiprocessing = multiprocessing # type: ignore self._multiprocessing_setup() # for _module_main_* methods self._save_mod_path: Optional[str] = None self._save_mod_spec = None
python
wandb/sdk/backend/backend.py
64
87
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
4,819
_hack_set_run
def _hack_set_run(self, run: "Run") -> None: assert self.interface self.interface._hack_set_run(run)
python
wandb/sdk/backend/backend.py
89
91
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
4,820
_multiprocessing_setup
def _multiprocessing_setup(self) -> None: assert self._settings if self._settings.start_method == "thread": return # defaulting to spawn for now, fork needs more testing start_method = self._settings.start_method or "spawn" # TODO: use fork context if unix and frozen? # if py34+, else fall back if not hasattr(multiprocessing, "get_context"): return all_methods = multiprocessing.get_all_start_methods() logger.info( "multiprocessing start_methods={}, using: {}".format( ",".join(all_methods), start_method ) ) ctx = multiprocessing.get_context(start_method) self._multiprocessing = ctx
python
wandb/sdk/backend/backend.py
93
112
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
4,821
_module_main_install
def _module_main_install(self) -> None: # Support running code without a: __name__ == "__main__" main_module = sys.modules["__main__"] main_mod_spec = getattr(main_module, "__spec__", None) main_mod_path = getattr(main_module, "__file__", None) if main_mod_spec is None: # hack for pdb # Note: typing has trouble with BuiltinImporter loader: "Loader" = importlib.machinery.BuiltinImporter # type: ignore # noqa: F821 main_mod_spec = importlib.machinery.ModuleSpec( name="wandb.mpmain", loader=loader ) main_module.__spec__ = main_mod_spec else: self._save_mod_spec = main_mod_spec if main_mod_path is not None: self._save_mod_path = main_module.__file__ fname = os.path.join( os.path.dirname(wandb.__file__), "mpmain", "__main__.py" ) main_module.__file__ = fname
python
wandb/sdk/backend/backend.py
114
134
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
4,822
_module_main_uninstall
def _module_main_uninstall(self) -> None: main_module = sys.modules["__main__"] # Undo temporary changes from: __name__ == "__main__" main_module.__spec__ = self._save_mod_spec if self._save_mod_path: main_module.__file__ = self._save_mod_path
python
wandb/sdk/backend/backend.py
136
141
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
4,823
_ensure_launched_manager
def _ensure_launched_manager(self) -> None: # grpc_port: Optional[int] = None # attach_id = self._settings._attach_id if self._settings else None # if attach_id: # # TODO(attach): implement # # already have a server, assume it is already up # grpc_port = int(attach_id) assert self._manager svc = self._manager._get_service() assert svc svc_iface = svc.service_interface svc_transport = svc_iface.get_transport() if svc_transport == "tcp": from ..interface.interface_sock import InterfaceSock svc_iface_sock = cast("ServiceSockInterface", svc_iface) sock_client = svc_iface_sock._get_sock_client() sock_interface = InterfaceSock(sock_client, mailbox=self._mailbox) self.interface = sock_interface elif svc_transport == "grpc": from ..interface.interface_grpc import InterfaceGrpc svc_iface_grpc = cast("ServiceGrpcInterface", svc_iface) stub = svc_iface_grpc._get_stub() grpc_interface = InterfaceGrpc(mailbox=self._mailbox) grpc_interface._connect(stub=stub) self.interface = grpc_interface else: raise AssertionError(f"Unsupported service transport: {svc_transport}")
python
wandb/sdk/backend/backend.py
143
173
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
4,824
ensure_launched
def ensure_launched(self) -> None: """Launch backend worker if not running.""" settings: Dict[str, Any] = dict() if self._settings is not None: settings = self._settings.make_static() settings["_log_level"] = self._log_level or logging.DEBUG # TODO: this is brittle and should likely be handled directly on the # settings object. Multiprocessing blows up when it can't pickle # objects. if "_early_logger" in settings: del settings["_early_logger"] start_method = settings.get("start_method") if self._manager: self._ensure_launched_manager() return user_pid = os.getpid() if start_method == "thread": self.record_q = queue.Queue() self.result_q = queue.Queue() wandb._set_internal_process(disable=True) # type: ignore wandb_thread = BackendThread( target=wandb_internal, kwargs=dict( settings=settings, record_q=self.record_q, result_q=self.result_q, user_pid=user_pid, ), ) # TODO: risky cast, assumes BackendThread Process duck typing self.wandb_process = wandb_thread # type: ignore else: self.record_q = self._multiprocessing.Queue() self.result_q = self._multiprocessing.Queue() self.wandb_process = self._multiprocessing.Process( # type: ignore target=wandb_internal, kwargs=dict( settings=settings, record_q=self.record_q, result_q=self.result_q, user_pid=user_pid, ), ) assert self.wandb_process self.wandb_process.name = "wandb_internal" self._module_main_install() logger.info("starting backend process...") # Start the process with __name__ == "__main__" workarounds assert self.wandb_process self.wandb_process.start() self._internal_pid = self.wandb_process.pid logger.info(f"started backend process with pid: {self.wandb_process.pid}") self._module_main_uninstall() self.interface = InterfaceQueue( process=self.wandb_process, record_q=self.record_q, result_q=self.result_q, mailbox=self._mailbox, )
python
wandb/sdk/backend/backend.py
175
243
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
4,825
server_status
def server_status(self) -> None: """Report server status.""" pass
python
wandb/sdk/backend/backend.py
245
247
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
4,826
cleanup
def cleanup(self) -> None: # TODO: make _done atomic if self._done: return self._done = True if self.interface: self.interface.join() if self.wandb_process: self.wandb_process.join() if self.record_q and hasattr(self.record_q, "close"): self.record_q.close() if self.result_q and hasattr(self.result_q, "close"): self.result_q.close() # No printing allowed from here until redirect restore!!!
python
wandb/sdk/backend/backend.py
249
263
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
4,827
__init__
def __init__(self) -> None: self._urls_dict = None
python
wandb/sdk/lib/wburls.py
22
23
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
4,828
_get_urls
def _get_urls(self) -> Dict["URLS", str]: return dict( cli_launch="https://wandb.me/launch", doc_run="https://wandb.me/run", doc_require="https://wandb.me/library-require", doc_start_err="https://docs.wandb.ai/guides/track/tracking-faq#initstarterror-error-communicating-with-wandb-process-", doc_artifacts_guide="https://docs.wandb.ai/guides/artifacts", upgrade_server="https://wandb.me/server-upgrade", multiprocess="http://wandb.me/init-multiprocess", wandb_init="https://wandb.me/wandb-init", wandb_server="https://wandb.me/wandb-server", )
python
wandb/sdk/lib/wburls.py
25
36
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
4,829
get
def get(self, s: "URLS") -> str: if self._urls_dict is None: self._urls_dict = self._get_urls() return self._urls_dict[s]
python
wandb/sdk/lib/wburls.py
38
41
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
4,830
deprecate
def deprecate( field_name: DEPRECATED_FEATURES, warning_message: str, run: Optional["wandb_run.Run"] = None, ) -> None: """Warn the user that a feature has been deprecated. Also stores the information about the event in telemetry. Args: field_name: The name of the feature that has been deprecated. Defined in wandb/proto/wandb_telemetry.proto::Deprecated warning_message: The message to display to the user. run: The run to whose telemetry the event will be added. """ known_fields = TelemetryDeprecated.DESCRIPTOR.fields_by_name.keys() if field_name not in known_fields: raise ValueError( f"Unknown field name: {field_name}. Known fields: {known_fields}" ) _run = run or wandb.run with wandb.wandb_lib.telemetry.context(run=_run) as tel: # type: ignore[attr-defined] setattr(tel.deprecated, field_name, True) wandb.termwarn(warning_message, repeat=False)
python
wandb/sdk/lib/deprecate.py
19
42
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
4,831
__init__
def __init__(self) -> None: self.exit_code = 0 self.exception = None
python
wandb/sdk/lib/exit_hooks.py
17
19
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
4,832
hook
def hook(self) -> None: self._orig_exit = sys.exit sys.exit = self.exit self._orig_excepthook = ( sys.excepthook if sys.excepthook != sys.__excepthook__ # respect hooks by other libraries like pdb else None ) sys.excepthook = self.exc_handler # type: ignore
python
wandb/sdk/lib/exit_hooks.py
21
30
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
4,833
exit
def exit(self, code: object = 0) -> "NoReturn": orig_code = code code = code if code is not None else 0 code = code if isinstance(code, int) else 1 self.exit_code = code self._orig_exit(orig_code) # type: ignore
python
wandb/sdk/lib/exit_hooks.py
32
37
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
4,834
was_ctrl_c
def was_ctrl_c(self) -> bool: return isinstance(self.exception, KeyboardInterrupt)
python
wandb/sdk/lib/exit_hooks.py
39
40
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
4,835
exc_handler
def exc_handler( self, exc_type: Type[BaseException], exc: BaseException, tb: TracebackType ) -> None: self.exit_code = 1 self.exception = exc if issubclass(exc_type, Error): wandb.termerror(str(exc), repeat=False) if self.was_ctrl_c(): self.exit_code = 255 traceback.print_exception(exc_type, exc, tb) if self._orig_excepthook: self._orig_excepthook(exc_type, exc, tb)
python
wandb/sdk/lib/exit_hooks.py
42
55
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
4,836
win32_redirect
def win32_redirect(stdout_slave_fd, stderr_slave_fd): # import win32api # save for later # fd_stdout = os.dup(1) # fd_stderr = os.dup(2) # std_out = win32api.GetStdHandle(win32api.STD_OUTPUT_HANDLE) # std_err = win32api.GetStdHandle(win32api.STD_ERROR_HANDLE) # os.dup2(stdout_slave_fd, 1) # os.dup2(stderr_slave_fd, 2) # TODO(jhr): do something about current stdout, stderr file handles pass
python
wandb/sdk/lib/console.py
6
20
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
4,837
win32_create_pipe
def win32_create_pipe(): # import pywintypes # import win32pipe # sa=pywintypes.SECURITY_ATTRIBUTES() # sa.bInheritHandle=1 # read_fd, write_fd = win32pipe.FdCreatePipe(sa, 0, os.O_TEXT) # read_fd, write_fd = win32pipe.FdCreatePipe(sa, 0, os.O_BINARY) read_fd, write_fd = os.pipe() # http://timgolden.me.uk/pywin32-docs/win32pipe__FdCreatePipe_meth.html # https://stackoverflow.com/questions/17942874/stdout-redirection-with-ctypes # f = open("testing.txt", "rb") # read_fd = f.fileno() return read_fd, write_fd
python
wandb/sdk/lib/console.py
23
39
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
4,838
__init__
def __init__( self, root: Optional[str] = None, remote: str = "origin", lazy: bool = True, remote_url: Optional[str] = None, commit: Optional[str] = None, ) -> None: self.remote_name = remote if remote_url is None else None self._root = root self._remote_url = remote_url self._commit = commit self._repo = None if not lazy: self.repo # noqa: B018
python
wandb/sdk/lib/git.py
13
27
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
4,839
repo
def repo(self): if self._repo is None: if self.remote_name is None: self._repo = False else: try: self._repo = Repo( self._root or os.getcwd(), search_parent_directories=True ) except exc.InvalidGitRepositoryError: logger.debug("git repository is invalid") self._repo = False except exc.NoSuchPathError: wandb.termwarn(f"git root {self._root} does not exist") logger.warn(f"git root {self._root} does not exist") self._repo = False return self._repo
python
wandb/sdk/lib/git.py
30
46
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
4,840
auto
def auto(self): return self._remote_url is None
python
wandb/sdk/lib/git.py
49
50
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
4,841
is_untracked
def is_untracked(self, file_name: str) -> bool: if not self.repo: return True return file_name in self.repo.untracked_files
python
wandb/sdk/lib/git.py
52
55
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
4,842
enabled
def enabled(self) -> bool: return bool(self.repo)
python
wandb/sdk/lib/git.py
58
59
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
4,843
root
def root(self) -> Optional[str]: if not self.repo: return None try: return self.repo.git.rev_parse("--show-toplevel") except exc.GitCommandError as e: # todo: collect telemetry on this logger.error(f"git root error: {e}") return None
python
wandb/sdk/lib/git.py
62
70
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
4,844
dirty
def dirty(self) -> bool: if not self.repo: return False return self.repo.is_dirty()
python
wandb/sdk/lib/git.py
73
76
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
4,845
email
def email(self) -> Optional[str]: if not self.repo: return None try: return self.repo.config_reader().get_value("user", "email") except configparser.Error: return None
python
wandb/sdk/lib/git.py
79
85
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
4,846
last_commit
def last_commit(self): if self._commit: return self._commit if not self.repo: return None if not self.repo.head or not self.repo.head.is_valid(): return None # TODO: Saw a user getting a Unicode decode error when parsing refs, # more details on implementing a real fix in [WB-4064] try: if len(self.repo.refs) > 0: return self.repo.head.commit.hexsha else: return self.repo.git.show_ref("--head").split(" ")[0] except Exception: logger.exception("Unable to find most recent commit in git") return None
python
wandb/sdk/lib/git.py
88
104
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
4,847
branch
def branch(self) -> Optional[str]: if not self.repo: return None return self.repo.head.ref.name
python
wandb/sdk/lib/git.py
107
110
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
4,848
remote
def remote(self): if not self.repo: return None try: return self.repo.remotes[self.remote_name] except IndexError: return None
python
wandb/sdk/lib/git.py
113
119
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
4,849
has_submodule_diff
def has_submodule_diff(self) -> bool: if not self.repo: return False return self.repo.git.version_info >= (2, 11, 0)
python
wandb/sdk/lib/git.py
124
127
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
4,850
remote_url
def remote_url(self): if self._remote_url: return self._remote_url if not self.remote: return None parsed = urlparse(self.remote.url) hostname = parsed.hostname if parsed.port is not None: hostname += ":" + str(parsed.port) if parsed.password is not None: return urlunparse(parsed._replace(netloc=f"{parsed.username}:@{hostname}")) return urlunparse(parsed._replace(netloc=hostname))
python
wandb/sdk/lib/git.py
130
141
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
4,851
root_dir
def root_dir(self): if not self.repo: return None return self.repo.git.rev_parse("--show-toplevel")
python
wandb/sdk/lib/git.py
144
147
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
4,852
get_upstream_fork_point
def get_upstream_fork_point(self): """Get the most recent ancestor of HEAD that occurs on an upstream branch. First looks at the current branch's tracking branch, if applicable. If that doesn't work, looks at every other branch to find the most recent ancestor of HEAD that occurs on a tracking branch. Returns: git.Commit object or None """ possible_relatives = [] try: if not self.repo: return None try: active_branch = self.repo.active_branch except (TypeError, ValueError): logger.debug("git is in a detached head state") return None # detached head else: tracking_branch = active_branch.tracking_branch() if tracking_branch: possible_relatives.append(tracking_branch.commit) if not possible_relatives: for branch in self.repo.branches: tracking_branch = branch.tracking_branch() if tracking_branch is not None: possible_relatives.append(tracking_branch.commit) head = self.repo.head most_recent_ancestor = None for possible_relative in possible_relatives: # at most one: for ancestor in self.repo.merge_base(head, possible_relative): if most_recent_ancestor is None: most_recent_ancestor = ancestor elif self.repo.is_ancestor(most_recent_ancestor, ancestor): most_recent_ancestor = ancestor return most_recent_ancestor except exc.GitCommandError as e: logger.debug("git remote upstream fork point could not be found") logger.debug(str(e)) return None
python
wandb/sdk/lib/git.py
149
192
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
4,853
tag
def tag(self, name, message): try: return self.repo.create_tag("wandb/" + name, message=message, force=True) except exc.GitCommandError: print("Failed to tag repository.") return None
python
wandb/sdk/lib/git.py
194
199
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
4,854
push
def push(self, name): if self.remote: try: return self.remote.push("wandb/" + name, force=True) except exc.GitCommandError: logger.debug("failed to push git") return None
python
wandb/sdk/lib/git.py
201
207
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
4,855
repo
def repo(self): return None
python
wandb/sdk/lib/git.py
212
213
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
4,856
__init__
def __init__( self, api: Optional[InternalApi] = None, settings: Optional["Settings"] = None, ) -> None: self._api = api or InternalApi(default_settings=settings) self._error_network: Optional[bool] = None self._viewer: Dict[str, Any] = {} self._flags: Dict[str, Any] = {} self._settings = settings
python
wandb/sdk/lib/server.py
18
27
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
4,857
query_with_timeout
def query_with_timeout(self, timeout: Union[int, float, None] = None) -> None: if self._settings and self._settings._disable_viewer: return timeout = timeout or 5 async_viewer = util.async_call(self._api.viewer_server_info, timeout=timeout) try: viewer_tuple, viewer_thread = async_viewer() except Exception: # TODO: currently a bare exception as lots can happen, we should classify self._error_network = True return if viewer_thread.is_alive(): # this is likely a DNS hang self._error_network = True return self._error_network = False # TODO(jhr): should we kill the thread? self._viewer, self._serverinfo = viewer_tuple self._flags = json.loads(self._viewer.get("flags", "{}"))
python
wandb/sdk/lib/server.py
29
47
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
4,858
is_valid
def is_valid(self) -> bool: if self._error_network is None: raise Exception("invalid usage: must query server") return self._error_network
python
wandb/sdk/lib/server.py
49
52
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
4,859
__init__
def __init__(self) -> None: self._buf_list = [] self._buf_lengths = [] self._buf_total = 0
python
wandb/sdk/lib/sock_client.py
27
30
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
4,860
length
def length(self) -> int: return self._buf_total
python
wandb/sdk/lib/sock_client.py
33
34
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
4,861
_get
def _get(self, start: int, end: int, peek: bool = False) -> bytes: index: Optional[int] = None buffers = [] need = end # compute buffers needed for i, (buf_len, buf_data) in enumerate(zip(self._buf_lengths, self._buf_list)): buffers.append(buf_data[:need] if need < buf_len else buf_data) if need <= buf_len: index = i break need -= buf_len # buffer not large enough, caller should have made sure there was enough data if index is None: raise IndexError("SockBuffer index out of range") # advance buffer internals if we are not peeking into the data if not peek: self._buf_total -= end if need < buf_len: # update partially used buffer list self._buf_list = self._buf_list[index:] self._buf_lengths = self._buf_lengths[index:] self._buf_list[0] = self._buf_list[0][need:] self._buf_lengths[0] -= need else: # update fully used buffer list self._buf_list = self._buf_list[index + 1 :] self._buf_lengths = self._buf_lengths[index + 1 :] return b"".join(buffers)[start:end]
python
wandb/sdk/lib/sock_client.py
36
67
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
4,862
get
def get(self, start: int, end: int) -> bytes: return self._get(start, end)
python
wandb/sdk/lib/sock_client.py
69
70
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
4,863
peek
def peek(self, start: int, end: int) -> bytes: return self._get(start, end, peek=True)
python
wandb/sdk/lib/sock_client.py
72
73
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
4,864
put
def put(self, data: bytes, data_len: int) -> None: self._buf_list.append(data) self._buf_lengths.append(data_len) self._buf_total += data_len
python
wandb/sdk/lib/sock_client.py
75
78
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
4,865
__init__
def __init__(self) -> None: # TODO: use safe uuid's (python3.7+) or emulate this self._sockid = uuid.uuid4().hex self._retry_delay = 0.1 self._lock = threading.Lock() self._bufsize = 4096 self._buffer = SockBuffer()
python
wandb/sdk/lib/sock_client.py
92
98
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
4,866
connect
def connect(self, port: int) -> None: s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.connect(("localhost", port)) self._sock = s self._detect_bufsize()
python
wandb/sdk/lib/sock_client.py
100
104
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
4,867
_detect_bufsize
def _detect_bufsize(self) -> None: sndbuf_size = self._sock.getsockopt(socket.SOL_SOCKET, socket.SO_SNDBUF) rcvbuf_size = self._sock.getsockopt(socket.SOL_SOCKET, socket.SO_RCVBUF) self._bufsize = min(sndbuf_size, rcvbuf_size, 65536)
python
wandb/sdk/lib/sock_client.py
106
109
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
4,868
close
def close(self) -> None: self._sock.close()
python
wandb/sdk/lib/sock_client.py
111
112
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
4,869
shutdown
def shutdown(self, val: int) -> None: self._sock.shutdown(val)
python
wandb/sdk/lib/sock_client.py
114
115
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
4,870
set_socket
def set_socket(self, sock: socket.socket) -> None: self._sock = sock self._detect_bufsize()
python
wandb/sdk/lib/sock_client.py
117
119
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
4,871
_sendall_with_error_handle
def _sendall_with_error_handle(self, data: bytes) -> None: # This is a helper function for sending data in a retry fashion. # Similar to the sendall() function in the socket module, but with a # an error handling in case of timeout. total_sent = 0 total_data = len(data) while total_sent < total_data: start_time = time.monotonic() try: sent = self._sock.send(data) # sent equal to 0 indicates a closed socket if sent == 0: raise SockClientClosedError("socket connection broken") total_sent += sent # truncate our data to save memory data = data[sent:] # we handle the timeout case for the cases when timeout is set # on a system level by another application except socket.timeout: # adding sleep to avoid tight loop delta_time = time.monotonic() - start_time if delta_time < self._retry_delay: time.sleep(self._retry_delay - delta_time)
python
wandb/sdk/lib/sock_client.py
121
143
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
4,872
_send_message
def _send_message(self, msg: Any) -> None: tracelog.log_message_send(msg, self._sockid) raw_size = msg.ByteSize() data = msg.SerializeToString() assert len(data) == raw_size, "invalid serialization" header = struct.pack("<BI", ord("W"), raw_size) with self._lock: self._sendall_with_error_handle(header + data)
python
wandb/sdk/lib/sock_client.py
145
152
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
4,873
send_server_request
def send_server_request(self, msg: Any) -> None: self._send_message(msg)
python
wandb/sdk/lib/sock_client.py
154
155
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
4,874
send_server_response
def send_server_response(self, msg: Any) -> None: try: self._send_message(msg) except BrokenPipeError: # TODO(jhr): user thread might no longer be around to receive responses to # things like network status poll loop, there might be a better way to quiesce pass
python
wandb/sdk/lib/sock_client.py
157
163
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
4,875
send_and_recv
def send_and_recv( self, *, inform_init: Optional[spb.ServerInformInitRequest] = None, inform_start: Optional[spb.ServerInformStartRequest] = None, inform_attach: Optional[spb.ServerInformAttachRequest] = None, inform_finish: Optional[spb.ServerInformFinishRequest] = None, inform_teardown: Optional[spb.ServerInformTeardownRequest] = None, ) -> spb.ServerResponse: self.send( inform_init=inform_init, inform_start=inform_start, inform_attach=inform_attach, inform_finish=inform_finish, inform_teardown=inform_teardown, ) # TODO: this solution is fragile, but for checking attach # it should be relatively stable. # This pass would be solved as part of the fix in https://wandb.atlassian.net/browse/WB-8709 response = self.read_server_response(timeout=1) if response is None: raise Exception("No response") return response
python
wandb/sdk/lib/sock_client.py
165
187
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
4,876
send
def send( self, *, inform_init: Optional[spb.ServerInformInitRequest] = None, inform_start: Optional[spb.ServerInformStartRequest] = None, inform_attach: Optional[spb.ServerInformAttachRequest] = None, inform_finish: Optional[spb.ServerInformFinishRequest] = None, inform_teardown: Optional[spb.ServerInformTeardownRequest] = None, ) -> None: server_req = spb.ServerRequest() if inform_init: server_req.inform_init.CopyFrom(inform_init) elif inform_start: server_req.inform_start.CopyFrom(inform_start) elif inform_attach: server_req.inform_attach.CopyFrom(inform_attach) elif inform_finish: server_req.inform_finish.CopyFrom(inform_finish) elif inform_teardown: server_req.inform_teardown.CopyFrom(inform_teardown) else: raise Exception("unmatched") self.send_server_request(server_req)
python
wandb/sdk/lib/sock_client.py
189
211
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
4,877
send_record_communicate
def send_record_communicate(self, record: "pb.Record") -> None: server_req = spb.ServerRequest() server_req.record_communicate.CopyFrom(record) self.send_server_request(server_req)
python
wandb/sdk/lib/sock_client.py
213
216
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
4,878
send_record_publish
def send_record_publish(self, record: "pb.Record") -> None: server_req = spb.ServerRequest() server_req.record_publish.CopyFrom(record) self.send_server_request(server_req)
python
wandb/sdk/lib/sock_client.py
218
221
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
4,879
_extract_packet_bytes
def _extract_packet_bytes(self) -> Optional[bytes]: # Do we have enough data to read the header? start_offset = self.HEADLEN if self._buffer.length >= start_offset: header = self._buffer.peek(0, start_offset) fields = struct.unpack("<BI", header) magic, dlength = fields assert magic == ord("W") # Do we have enough data to read the full record? end_offset = self.HEADLEN + dlength if self._buffer.length >= end_offset: rec_data = self._buffer.get(start_offset, end_offset) return rec_data return None
python
wandb/sdk/lib/sock_client.py
223
236
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
4,880
_read_packet_bytes
def _read_packet_bytes(self, timeout: Optional[int] = None) -> Optional[bytes]: """Read full message from socket. Args: timeout: number of seconds to wait on socket data. Raises: SockClientClosedError: socket has been closed. """ while True: rec = self._extract_packet_bytes() if rec: return rec if timeout: self._sock.settimeout(timeout) try: data = self._sock.recv(self._bufsize) except socket.timeout: break except ConnectionResetError: raise SockClientClosedError except OSError: raise SockClientClosedError finally: if timeout: self._sock.settimeout(None) data_len = len(data) if data_len == 0: # socket.recv() will return 0 bytes if socket was shutdown # caller will handle this condition like other connection problems raise SockClientClosedError self._buffer.put(data, data_len) return None
python
wandb/sdk/lib/sock_client.py
238
271
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
4,881
read_server_request
def read_server_request(self) -> Optional[spb.ServerRequest]: data = self._read_packet_bytes() if not data: return None rec = spb.ServerRequest() rec.ParseFromString(data) tracelog.log_message_recv(rec, self._sockid) return rec
python
wandb/sdk/lib/sock_client.py
273
280
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
4,882
read_server_response
def read_server_response( self, timeout: Optional[int] = None ) -> Optional[spb.ServerResponse]: data = self._read_packet_bytes(timeout=timeout) if not data: return None rec = spb.ServerResponse() rec.ParseFromString(data) tracelog.log_message_recv(rec, self._sockid) return rec
python
wandb/sdk/lib/sock_client.py
282
291
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
4,883
generate_id
def generate_id(length: int = 8) -> str: """Generate a random base-36 string of `length` digits.""" # There are ~2.8T base-36 8-digit strings. If we generate 210k ids, # we'll have a ~1% chance of collision. alphabet = string.ascii_lowercase + string.digits return "".join(secrets.choice(alphabet) for _ in range(length))
python
wandb/sdk/lib/runid.py
7
12
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
4,884
where
def where(self, x): return ([i for i in range(len(x)) if x[i]],)
python
wandb/sdk/lib/redirect.py
25
26
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
4,885
diff
def diff(self, x): return [x[i + 1] - x[i] for i in range(len(x) - 1)]
python
wandb/sdk/lib/redirect.py
28
29
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
4,886
arange
def arange(self, x): class Arr(list): def __getitem__(self, s): if isinstance(s, slice): self._start = s.start return self return super().__getitem__(s) def __getslice__(self, i, j): self._start = i return self def __iadd__(self, i): # type: ignore for j in range(self._start, len(self)): self[j] += i return Arr(range(x))
python
wandb/sdk/lib/redirect.py
31
47
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
4,887
__getitem__
def __getitem__(self, s): if isinstance(s, slice): self._start = s.start return self return super().__getitem__(s)
python
wandb/sdk/lib/redirect.py
33
37
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
4,888
__getslice__
def __getslice__(self, i, j): self._start = i return self
python
wandb/sdk/lib/redirect.py
39
41
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
4,889
__iadd__
def __iadd__(self, i): # type: ignore for j in range(self._start, len(self)): self[j] += i
python
wandb/sdk/lib/redirect.py
43
45
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
4,890
_get_char
def _get_char(code): return "\033[" + str(code) + "m"
python
wandb/sdk/lib/redirect.py
102
103
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
4,891
__init__
def __init__( self, data=" ", fg=ANSI_FG_DEFAULT, bg=ANSI_BG_DEFAULT, bold=False, italics=False, underscore=False, blink=False, strikethrough=False, reverse=False, ): self.data = data self.fg = fg self.bg = bg self.bold = bold self.italics = italics self.underscore = underscore self.blink = blink self.strikethrough = strikethrough self.reverse = reverse
python
wandb/sdk/lib/redirect.py
121
141
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
4,892
reset
def reset(self): # Reset everything other than data to defaults default = self.__class__() for k in self.__slots__[1:]: self[k] = default[k]
python
wandb/sdk/lib/redirect.py
143
147
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
4,893
__getitem__
def __getitem__(self, k): return getattr(self, k)
python
wandb/sdk/lib/redirect.py
149
150
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
4,894
__setitem__
def __setitem__(self, k, v): setattr(self, k, v)
python
wandb/sdk/lib/redirect.py
152
153
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
4,895
copy
def copy(self, **kwargs): attrs = {} for k in self.__slots__: if k in kwargs: attrs[k] = kwargs[k] else: attrs[k] = self[k] return self.__class__(**attrs)
python
wandb/sdk/lib/redirect.py
155
162
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
4,896
__eq__
def __eq__(self, other): for k in self.__slots__: if self[k] != other[k]: return False return True
python
wandb/sdk/lib/redirect.py
164
168
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
4,897
__init__
def __init__(self, x=0, y=0, char=None): if char is None: char = Char() self.x = x self.y = y self.char = char
python
wandb/sdk/lib/redirect.py
185
190
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
4,898
__init__
def __init__(self): self.buffer = defaultdict(lambda: defaultdict(lambda: _defchar)) self.cursor = Cursor() self._num_lines = None # Cache # For diffing: self._prev_num_lines = None self._prev_last_line = None
python
wandb/sdk/lib/redirect.py
201
208
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
4,899
cursor_up
def cursor_up(self, n=1): n = min(n, self.cursor.y) self.cursor.y -= n
python
wandb/sdk/lib/redirect.py
210
212
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
4,900
cursor_down
def cursor_down(self, n=1): self.cursor.y += n
python
wandb/sdk/lib/redirect.py
214
215
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }