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
1,201
add_log_parameters_hook
def add_log_parameters_hook( self, module: "torch.nn.Module", name: str = "", prefix: str = "", log_freq: int = 0, ) -> None: """This instruments hooks into the pytorch module log parameters after a forward pass log_freq - log gradients/parameters ever...
python
wandb/wandb_torch.py
79
119
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
1,202
parameter_log_hook
def parameter_log_hook(module, input_, output, log_track): if not log_track_update(log_track): return for name, parameter in module.named_parameters(): # for pytorch 0.3 Variables if isinstance(parameter, torch.autograd.Variable): ...
python
wandb/wandb_torch.py
96
105
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
1,203
add_log_gradients_hook
def add_log_gradients_hook( self, module: "torch.nn.Module", name: str = "", prefix: str = "", log_freq: int = 0, ) -> None: """This instruments hooks into the pytorch module log gradients after a backward pass log_freq - log gradients/parameters every...
python
wandb/wandb_torch.py
121
145
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
1,204
log_tensor_stats
def log_tensor_stats(self, tensor, name): """Add distribution statistics on a tensor's elements to the current History entry""" # TODO Handle the case of duplicate names. if isinstance(tensor, tuple) or isinstance(tensor, list): while (isinstance(tensor, tuple) or isinstance(tensor,...
python
wandb/wandb_torch.py
147
259
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
1,205
_hook_variable_gradient_stats
def _hook_variable_gradient_stats(self, var, name, log_track): """Logs a Variable's gradient's distribution statistics next time backward() is called on it. """ if not isinstance(var, torch.autograd.Variable): cls = type(var) raise TypeError( "Expe...
python
wandb/wandb_torch.py
261
284
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
1,206
_callback
def _callback(grad, log_track): if not log_track_update(log_track): return self.log_tensor_stats(grad.data, name)
python
wandb/wandb_torch.py
277
280
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
1,207
unhook_all
def unhook_all(self): for handle in self._hook_handles.values(): handle.remove() self._hook_handles = []
python
wandb/wandb_torch.py
286
289
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
1,208
unhook
def unhook(self, name): handle = self._hook_handles.pop(name) handle.remove()
python
wandb/wandb_torch.py
291
293
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
1,209
_torch_hook_handle_is_valid
def _torch_hook_handle_is_valid(self, handle): d = handle.hooks_dict_ref() if d is None: return False else: return handle.id in d
python
wandb/wandb_torch.py
295
300
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
1,210
_no_finite_values
def _no_finite_values(self, tensor: "torch.Tensor") -> bool: return tensor.shape == torch.Size([0]) or (~torch.isfinite(tensor)).all().item()
python
wandb/wandb_torch.py
302
303
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
1,211
_remove_infs_nans
def _remove_infs_nans(self, tensor: "torch.Tensor") -> "torch.Tensor": if not torch.isfinite(tensor).all(): tensor = tensor[torch.isfinite(tensor)] return tensor
python
wandb/wandb_torch.py
305
309
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
1,212
__init__
def __init__(self): super().__init__("torch") self._graph_hooks = set()
python
wandb/wandb_torch.py
313
315
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
1,213
hook_torch
def hook_torch(cls, model, criterion=None, graph_idx=0): wandb.termlog("logging graph, to disable use `wandb.watch(log_graph=False)`") graph = TorchGraph() graph.hook_torch_modules(model, criterion, graph_idx=graph_idx) return graph
python
wandb/wandb_torch.py
318
322
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
1,214
create_forward_hook
def create_forward_hook(self, name, graph_idx): graph = self def after_forward_hook(module, input, output): if id(module) not in self._graph_hooks: # hook already processed -> noop return if not isinstance(output, tuple): output = ...
python
wandb/wandb_torch.py
324
367
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
1,215
after_forward_hook
def after_forward_hook(module, input, output): if id(module) not in self._graph_hooks: # hook already processed -> noop return if not isinstance(output, tuple): output = (output,) parameters = [ (pname, list(param.size()...
python
wandb/wandb_torch.py
327
365
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
1,216
hook_torch_modules
def hook_torch_modules( self, module, criterion=None, prefix=None, graph_idx=0, parent=None ): torch = util.get_module("torch", "Could not import torch") layers = 0 graph = self if hasattr(module, "_wandb_watch_called") and module._wandb_watch_called: raise ValueE...
python
wandb/wandb_torch.py
369
430
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
1,217
from_torch_layers
def from_torch_layers(cls, module_graph, variable): """Recover something like neural net layers from PyTorch Module's and the compute graph from a Variable. Example output for a multi-layer RNN. We confusingly assign shared embedding values to the encoder, but ordered next to the decode...
python
wandb/wandb_torch.py
433
548
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
1,218
node_from_module
def node_from_module(cls, nid, module): numpy = util.get_module("numpy", "Could not import numpy") node = wandb.Node() node.id = nid node.child_parameters = 0 for parameter in module.parameters(): node.child_parameters += numpy.prod(parameter.size()) node.cla...
python
wandb/wandb_torch.py
551
561
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
1,219
__init__
def __init__( self, env=None, command=None, function=None, run_id=None, in_jupyter=None ): self._popen = None self._proc = None self._finished_q = multiprocessing.Queue() self._proc_killed = False if command: if platform.system() == "Windows": ...
python
wandb/wandb_agent.py
33
54
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
1,220
_start
def _start(self, finished_q, env, function, run_id, in_jupyter): if env: for k, v in env.items(): os.environ[k] = v # call user function print("wandb: Agent Started Run:", run_id) if function: function() print("wandb: Agent Finished Run:",...
python
wandb/wandb_agent.py
56
73
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
1,221
poll
def poll(self): if self._popen: return self._popen.poll() if self._proc_killed: # we need to join process to prevent zombies self._proc.join() return True try: finished = self._finished_q.get(False, 0) if finished: ...
python
wandb/wandb_agent.py
75
88
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
1,222
wait
def wait(self): if self._popen: # if on windows, wait() will block and we wont be able to interrupt if platform.system() == "Windows": try: while True: p = self._popen.poll() if p is not None: ...
python
wandb/wandb_agent.py
90
103
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
1,223
kill
def kill(self): if self._popen: return self._popen.kill() pid = self._proc.pid if pid: ret = os.kill(pid, signal.SIGKILL) self._proc_killed = True return ret return
python
wandb/wandb_agent.py
105
113
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
1,224
terminate
def terminate(self): if self._popen: # windows terminate is too strong, send Ctrl-C instead if platform.system() == "Windows": return self._popen.send_signal(signal.CTRL_C_EVENT) return self._popen.terminate() return self._proc.terminate()
python
wandb/wandb_agent.py
115
121
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
1,225
_create_sweep_command_args
def _create_sweep_command_args(command: Dict) -> Dict[str, Any]: """Create various formats of command arguments for the agent. Raises: ValueError: improperly formatted command dict """ if "args" not in command: raise ValueError('No "args" found in command: %s' % command) # four dif...
python
wandb/wandb_agent.py
124
162
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
1,226
__init__
def __init__( self, api, queue, sweep_id=None, function=None, in_jupyter=None, count=None ): self._api = api self._queue = queue self._run_processes = {} # keyed by run.id (GQL run name) self._server_responses = [] self._sweep_id = sweep_id self._in_jupyter =...
python
wandb/wandb_agent.py
180
210
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
1,227
is_flapping
def is_flapping(self): """Determine if the process is flapping. Flapping occurs if the agents receives FLAPPING_MAX_FAILURES non-0 exit codes in the first FLAPPING_MAX_SECONDS. """ if os.getenv(wandb.env.AGENT_DISABLE_FLAPPING) == "true": return False if time...
python
wandb/wandb_agent.py
212
221
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
1,228
is_failing
def is_failing(self): return ( self._failed >= self._finished and self._max_initial_failures <= self._failed )
python
wandb/wandb_agent.py
223
227
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
1,229
run
def run(self): # noqa: C901 # TODO: catch exceptions, handle errors, show validation warnings, and make more generic sweep_obj = self._api.sweep(self._sweep_id, "{}") if sweep_obj: sweep_yaml = sweep_obj.get("config") if sweep_yaml: sweep_config = yaml.sa...
python
wandb/wandb_agent.py
229
351
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
1,230
_process_command
def _process_command(self, command): logger.info( "Agent received command: %s" % (command["type"] if "type" in command else "Unknown") ) response = { "id": command.get("id"), "result": None, } try: command_type = command...
python
wandb/wandb_agent.py
353
384
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
1,231
_create_sweep_command
def _create_sweep_command(command: Optional[List] = None) -> List: """Return sweep command, filling in environment variable macros.""" # Start from default sweep command command = command or Agent.DEFAULT_SWEEP_COMMAND for i, chunk in enumerate(command): # Replace environment...
python
wandb/wandb_agent.py
387
401
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
1,232
_command_run
def _command_run(self, command): logger.info( "Agent starting run with config:\n" + "\n".join( ["\t{}: {}".format(k, v["value"]) for k, v in command["args"].items()] ) ) if self._in_jupyter: print( "wandb: Agent Star...
python
wandb/wandb_agent.py
403
487
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
1,233
_command_stop
def _command_stop(self, command): run_id = command["run_id"] if run_id in self._run_processes: proc = self._run_processes[run_id] now = util.stopwatch_now() if proc.last_sigterm_time is None: proc.last_sigterm_time = now logger.info("St...
python
wandb/wandb_agent.py
489
508
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
1,234
_command_exit
def _command_exit(self, command): logger.info("Received exit command. Killing runs and quitting.") for _, proc in self._run_processes.items(): try: proc.kill() except OSError: # process is already dead pass self._running = F...
python
wandb/wandb_agent.py
510
518
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
1,235
__init__
def __init__(self, queue): self._queue = queue self._command_id = 0 self._multiproc_manager = multiprocessing.Manager()
python
wandb/wandb_agent.py
522
525
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
1,236
command
def command(self, command): command["origin"] = "local" command["id"] = "local-%s" % self._command_id self._command_id += 1 resp_queue = self._multiproc_manager.Queue() command["resp_queue"] = resp_queue self._queue.put(command) result = resp_queue.get() p...
python
wandb/wandb_agent.py
527
541
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
1,237
run_agent
def run_agent( sweep_id, function=None, in_jupyter=None, entity=None, project=None, count=None ): parts = dict(entity=entity, project=project, name=sweep_id) err = util.parse_sweep_id(parts) if err: wandb.termerror(err) return entity = parts.get("entity") or entity project = part...
python
wandb/wandb_agent.py
544
589
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
1,238
agent
def agent(sweep_id, function=None, entity=None, project=None, count=None): """Run a function or program with configuration parameters specified by server. Generic agent entrypoint, used for CLI or jupyter. Arguments: sweep_id: (dict) Sweep ID generated by CLI or sweep API function: (func, ...
python
wandb/wandb_agent.py
592
650
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
1,239
_is_running
def _is_running(): return bool(_INSTANCES)
python
wandb/wandb_agent.py
656
657
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
1,240
__init__
def __init__(self, id: str, data: Table) -> None: self._id = id self._data = data
python
wandb/viz.py
8
10
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
1,241
get_config_value
def get_config_value(self, key: str) -> Dict[str, Any]: return { "id": self._id, "historyFieldSettings": {"x-axis": "_step", "key": key}, }
python
wandb/viz.py
12
16
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
1,242
get_config_key
def get_config_key(key: str) -> Tuple[str, str, str]: return "_wandb", "viz", key
python
wandb/viz.py
19
20
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
1,243
value
def value(self) -> Table: return self._data
python
wandb/viz.py
23
24
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
1,244
__init__
def __init__( self, id: str, data: Table, fields: Dict[str, Any], string_fields: Dict[str, Any], ) -> None: self._id = id self._data = data self._fields = fields self._string_fields = string_fields
python
wandb/viz.py
28
38
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
1,245
get_config_value
def get_config_value( self, panel_type: str, query: Dict[str, Any], ) -> Dict[str, Any]: return { "panel_type": panel_type, "panel_config": { "panelDefId": self._id, "fieldSettings": self._fields, "stringSettings...
python
wandb/viz.py
40
54
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
1,246
get_config_key
def get_config_key(key: str) -> Tuple[str, str, str]: return "_wandb", "visualize", key
python
wandb/viz.py
57
58
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
1,247
user_query
def user_query(table_key: str) -> Dict[str, Any]: return { "queryFields": [ { "name": "runSets", "args": [{"name": "runSets", "value": "${runSets}"}], "fields": [ {"name": "id", "fields": []}, ...
python
wandb/viz.py
61
79
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
1,248
table
def table(self) -> Table: return self._data
python
wandb/viz.py
82
83
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
1,249
fields
def fields(self) -> Dict[str, Any]: return self._fields
python
wandb/viz.py
86
87
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
1,250
string_fields
def string_fields(self) -> Dict[str, Any]: return self._string_fields
python
wandb/viz.py
90
91
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
1,251
custom_chart
def custom_chart( vega_spec_name: str, data_table: Table, fields: Dict[str, Any], string_fields: Dict[str, Any] = {}, ) -> CustomChart: if not isinstance(data_table, Table): raise Error( f"Expected `data_table` to be `wandb.Table` type, instead got {type(data_table).__name__}" ...
python
wandb/viz.py
94
109
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
1,252
visualize
def visualize(id: str, value: Table) -> Visualize: if not isinstance(value, Table): raise Error( f"Expected `value` to be `wandb.Table` type, instead got {type(value).__name__}" ) return Visualize(id=id, data=value)
python
wandb/viz.py
112
117
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
1,253
reset
def reset(): _triggers.clear()
python
wandb/trigger.py
14
15
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
1,254
register
def register(event: str, func: Callable): _triggers.setdefault(event, []).append(func)
python
wandb/trigger.py
18
19
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
1,255
call
def call(event_str: str, *args: Any, **kwargs: Any): for func in _triggers.get(event_str, []): func(*args, **kwargs)
python
wandb/trigger.py
22
24
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
1,256
unregister
def unregister(event: str, func: Callable): _triggers[event].remove(func)
python
wandb/trigger.py
27
28
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
1,257
magics_class
def magics_class(*args, **kwargs): return lambda *args, **kwargs: None
python
wandb/jupyter.py
28
29
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
1,258
magic_arguments
def magic_arguments(*args, **kwargs): return lambda *args, **kwargs: None
python
wandb/jupyter.py
31
32
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
1,259
argument
def argument(*args, **kwargs): return lambda *args, **kwargs: None
python
wandb/jupyter.py
34
35
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
1,260
line_cell_magic
def line_cell_magic(*args, **kwargs): return lambda *args, **kwargs: None
python
wandb/jupyter.py
37
38
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
1,261
maybe_display
def maybe_display(): """Display a run if the user added cell magic and we have run.""" if __IFrame is not None: return __IFrame.maybe_display() return False
python
wandb/jupyter.py
46
50
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
1,262
quiet
def quiet(): if __IFrame is not None: return __IFrame.opts.get("quiet") return False
python
wandb/jupyter.py
53
56
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
1,263
__init__
def __init__(self, path=None, opts=None): self.path = path self.api = wandb.Api() self.opts = opts or {} self.displayed = False self.height = self.opts.get("height", 420)
python
wandb/jupyter.py
60
65
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
1,264
maybe_display
def maybe_display(self) -> bool: if not self.displayed and (self.path or wandb.run): display(self) return self.displayed
python
wandb/jupyter.py
67
70
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
1,265
_repr_html_
def _repr_html_(self): try: self.displayed = True if self.opts.get("workspace", False): if self.path is None and wandb.run: self.path = wandb.run.path if isinstance(self.path, str): object = self.api.from_path(self.path) ...
python
wandb/jupyter.py
72
96
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
1,266
__init__
def __init__(self, shell, require_interaction=False): super().__init__(shell) self.options = {}
python
wandb/jupyter.py
101
103
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
1,267
wandb
def wandb(self, line, cell=None): """Display wandb resources in jupyter. This can be used as cell or line magic. %wandb USERNAME/PROJECT/runs/RUN_ID --- %%wandb -h 1024 with wandb.init() as run: run.log({"loss": 1}) """ # Record options args ...
python
wandb/jupyter.py
134
158
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
1,268
notebook_metadata_from_jupyter_servers_and_kernel_id
def notebook_metadata_from_jupyter_servers_and_kernel_id(): servers, kernel_id = jupyter_servers_and_kernel_id() for s in servers: if s.get("password"): raise ValueError("Can't query password protected kernel") res = requests.get( urljoin(s["url"], "api/sessions"), params...
python
wandb/jupyter.py
161
179
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
1,269
notebook_metadata
def notebook_metadata(silent) -> Dict[str, str]: """Attempt to query jupyter for the path and name of the notebook file. This can handle different jupyter environments, specifically: 1. Colab 2. Kaggle 3. JupyterLab 4. Notebooks 5. Other? """ error_message = ( "Failed to de...
python
wandb/jupyter.py
182
232
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
1,270
jupyter_servers_and_kernel_id
def jupyter_servers_and_kernel_id(): """Return a list of servers and the current kernel_id. Used to query for the name of the notebook. """ try: import ipykernel kernel_id = re.search( "kernel-(.*).json", ipykernel.connect.get_connection_file() ).group(1) # ...
python
wandb/jupyter.py
235
256
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
1,271
attempt_colab_load_ipynb
def attempt_colab_load_ipynb(): colab = wandb.util.get_module("google.colab") if colab: # This isn't thread safe, never call in a thread response = colab._message.blocking_request("get_ipynb", timeout_sec=5) if response: return response["ipynb"]
python
wandb/jupyter.py
259
265
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
1,272
attempt_kaggle_load_ipynb
def attempt_kaggle_load_ipynb(): kaggle = wandb.util.get_module("kaggle_session") if kaggle: try: client = kaggle.UserSessionClient() parsed = json.loads(client.get_exportable_ipynb()["source"]) # TODO: couldn't find a way to get the name of the notebook... ...
python
wandb/jupyter.py
268
279
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
1,273
attempt_colab_login
def attempt_colab_login(app_url): """This renders an iframe to wandb in the hopes it posts back an api key.""" from google.colab import output from google.colab._message import MessageError from IPython import display display.display( display.Javascript( """ window._wand...
python
wandb/jupyter.py
282
325
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
1,274
__init__
def __init__(self, settings): self.outputs = {} self.settings = settings self.shell = get_ipython()
python
wandb/jupyter.py
329
332
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
1,275
save_display
def save_display(self, exc_count, data_with_metadata): self.outputs[exc_count] = self.outputs.get(exc_count, []) # byte values such as images need to be encoded in base64 # otherwise nbformat.v4.new_output will throw a NotebookValidationError data = data_with_metadata["data"] b6...
python
wandb/jupyter.py
334
350
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
1,276
probe_ipynb
def probe_ipynb(self): """Return notebook as dict or None.""" relpath = self.settings._jupyter_path if relpath: if os.path.exists(relpath): with open(relpath) as json_file: data = json.load(json_file) return data colab_...
python
wandb/jupyter.py
352
369
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
1,277
save_ipynb
def save_ipynb(self) -> bool: if not self.settings.save_code: logger.info("not saving jupyter notebook") return False ret = False try: ret = self._save_ipynb() except Exception as e: logger.info(f"Problem saving notebook: {repr(e)}") ...
python
wandb/jupyter.py
371
380
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
1,278
_save_ipynb
def _save_ipynb(self) -> bool: relpath = self.settings._jupyter_path logger.info("looking for notebook: %s", relpath) if relpath: if os.path.exists(relpath): shutil.copy( relpath, os.path.join( self.setti...
python
wandb/jupyter.py
382
430
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
1,279
save_history
def save_history(self): """This saves all cell executions in the current session as a new notebook.""" try: from nbformat import v4, validator, write except ImportError: logger.error("Run pip install nbformat to save notebook history") return # TODO: s...
python
wandb/jupyter.py
432
501
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
1,280
_add_any
def _add_any( artifact: ArtifactInterface, path_or_obj: Union[ str, ArtifactManifestEntry, data_types.WBValue ], # todo: add dataframe name: Optional[str], ) -> Any: """Add an object to an artifact. High-level wrapper to add object(s) to an artifact - calls any of the .add* methods ...
python
wandb/beta/workflows.py
12
52
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
1,281
_log_artifact_version
def _log_artifact_version( name: str, type: str, entries: Dict[str, Union[str, ArtifactManifestEntry, data_types.WBValue]], aliases: Optional[Union[str, List[str]]] = None, description: Optional[str] = None, metadata: Optional[dict] = None, project: Optional[str] = None, scope_project: O...
python
wandb/beta/workflows.py
55
111
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
1,282
log_model
def log_model( model_obj: Any, name: str = "model", aliases: Optional[Union[str, List[str]]] = None, description: Optional[str] = None, metadata: Optional[dict] = None, project: Optional[str] = None, scope_project: Optional[bool] = None, **kwargs: Dict[str, Any], ) -> "_SavedModel": ...
python
wandb/beta/workflows.py
114
184
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
1,283
use_model
def use_model(aliased_path: str) -> "_SavedModel": """Fetch a saved model from an alias. Under the hood, we use the alias to fetch the model artifact containing the serialized model files and rebuild the model object from these files. We also declare the fetched model artifact as an input to the run (w...
python
wandb/beta/workflows.py
187
228
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
1,284
link_model
def link_model( model: "_SavedModel", target_path: str, aliases: Optional[Union[str, List[str]]] = None, ) -> None: """Link the given model to a portfolio. A portfolio is a promoted collection which contains (in this case) model artifacts. Linking to a portfolio allows for useful model-centric ...
python
wandb/beta/workflows.py
231
284
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
1,285
find_config_file
def find_config_file(config_path: Optional[str] = None) -> Optional[str]: paths = list( filter( None, [ config_path, # 1 config_path_from_environment(), # 2 os.path.join(home_dir(), DOCKER_CONFIG_FILENAME), # 3 os.pat...
python
wandb/docker/auth.py
37
59
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
1,286
config_path_from_environment
def config_path_from_environment() -> Optional[str]: config_dir = os.environ.get("DOCKER_CONFIG") if not config_dir: return None return os.path.join(config_dir, os.path.basename(DOCKER_CONFIG_FILENAME))
python
wandb/docker/auth.py
62
66
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
1,287
home_dir
def home_dir() -> str: """Get the user's home directory. Uses the same logic as the Docker Engine client - use %USERPROFILE% on Windows, $HOME/getuid on POSIX. """ if IS_WINDOWS_PLATFORM: return os.environ.get("USERPROFILE", "") else: return os.path.expanduser("~")
python
wandb/docker/auth.py
69
78
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
1,288
load_general_config
def load_general_config(config_path: Optional[str] = None) -> Dict: config_file = find_config_file(config_path) if not config_file: return {} try: with open(config_file) as f: conf: Dict = json.load(f) return conf except (OSError, ValueError) as e: # In ...
python
wandb/docker/auth.py
81
97
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
1,289
resolve_repository_name
def resolve_repository_name(repo_name: str) -> Tuple[str, str]: if "://" in repo_name: raise InvalidRepositoryError( f"Repository name cannot contain a scheme ({repo_name})" ) index_name, remote_name = split_repo_name(repo_name) if index_name[0] == "-" or index_name[-1] == "-": ...
python
wandb/docker/auth.py
100
112
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
1,290
resolve_index_name
def resolve_index_name(index_name: str) -> str: index_name = convert_to_hostname(index_name) if index_name == "index." + INDEX_NAME: index_name = INDEX_NAME return index_name
python
wandb/docker/auth.py
115
119
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
1,291
split_repo_name
def split_repo_name(repo_name: str) -> Tuple[str, str]: parts = repo_name.split("/", 1) if len(parts) == 1 or ( "." not in parts[0] and ":" not in parts[0] and parts[0] != "localhost" ): # This is a docker index repo (ex: username/foobar or ubuntu) return INDEX_NAME, repo_name re...
python
wandb/docker/auth.py
122
129
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
1,292
get_credential_store
def get_credential_store(authconfig: Dict, registry: str) -> Optional[str]: if not isinstance(authconfig, AuthConfig): authconfig = AuthConfig(authconfig) return authconfig.get_credential_store(registry)
python
wandb/docker/auth.py
132
135
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
1,293
__init__
def __init__(self, dct: Dict, credstore_env: Optional[Mapping] = None) -> None: super().__init__(dct) if "auths" not in dct: dct["auths"] = {} self.update(dct) self._credstore_env = credstore_env self._stores: Dict[str, "dockerpycreds.Store"] = dict()
python
wandb/docker/auth.py
139
145
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
1,294
parse_auth
def parse_auth( cls, entries: Dict[str, Dict[str, Any]], raise_on_error: bool = False, ) -> Dict[str, Dict[str, Any]]: """Parse authentication entries. Arguments: entries: Dict of authentication entries. raise_on_error: If set to true, an invalid f...
python
wandb/docker/auth.py
148
204
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
1,295
load_config
def load_config( cls, config_path: Optional[str], config_dict: Optional[Dict[str, Any]], credstore_env: Optional[Mapping] = None, ) -> "AuthConfig": """Load authentication data from a Docker configuration file. If the config_path is not passed in it looks for a confi...
python
wandb/docker/auth.py
207
257
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
1,296
auths
def auths(self) -> Dict[str, Dict[str, Any]]: return self.get("auths", {})
python
wandb/docker/auth.py
260
261
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
1,297
creds_store
def creds_store(self) -> Optional[str]: return self.get("credsStore", None)
python
wandb/docker/auth.py
264
265
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
1,298
cred_helpers
def cred_helpers(self) -> Dict: return self.get("credHelpers", {})
python
wandb/docker/auth.py
268
269
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
1,299
is_empty
def is_empty(self) -> bool: return not self.auths and not self.creds_store and not self.cred_helpers
python
wandb/docker/auth.py
272
273
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
1,300
resolve_authconfig
def resolve_authconfig( self, registry: Optional[str] = None ) -> Optional[Dict[str, Any]]: """Return the authentication data for a specific registry. As with the Docker client, legacy entries in the config with full URLs are stripped down to hostnames before checking for a match. R...
python
wandb/docker/auth.py
275
307
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }