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,401
begin
def begin(self): if wandb.run is None: raise wandb.Error("You must call `wandb.init()` before calling `WandbHook`") if self._summary_op is None: self._summary_op = merge_all_summaries() self._step = -1
python
wandb/integration/tensorflow/estimator_hook.py
35
40
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
2,402
before_run
def before_run(self, run_context): return SessionRunArgs( {"summary": self._summary_op, "global_step": get_global_step()} )
python
wandb/integration/tensorflow/estimator_hook.py
42
45
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
2,403
after_run
def after_run(self, run_context, run_values): step = run_values.results["global_step"] if step % self._steps_per_log == 0: wandb.tensorboard._log( run_values.results["summary"], history=self._history, step=step, )
python
wandb/integration/tensorflow/estimator_hook.py
47
54
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
2,404
make_ndarray
def make_ndarray(tensor: Any) -> Optional["np.ndarray"]: if tensor_util: res = tensor_util.make_ndarray(tensor) # Tensorboard can log generic objects, and we don't want to save them if res.dtype == "object": return None else: return res else: wandb...
python
wandb/integration/tensorboard/log.py
38
51
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
2,405
namespaced_tag
def namespaced_tag(tag: str, namespace: str = "") -> str: if not namespace: return tag elif tag in namespace: # This happens with tensorboardX return namespace else: return namespace + "/" + tag
python
wandb/integration/tensorboard/log.py
54
61
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
2,406
history_image_key
def history_image_key(key: str, namespace: str = "") -> str: """Convert invalid filesystem characters to _ for use in History keys. Unfortunately this means currently certain image keys will collide silently. We implement this mapping up here in the TensorFlow stuff rather than in the History stuff so ...
python
wandb/integration/tensorboard/log.py
64
72
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
2,407
tf_summary_to_dict
def tf_summary_to_dict( # noqa: C901 tf_summary_str_or_pb: Any, namespace: str = "" ) -> Optional[Dict[str, Any]]: """Convert a Tensorboard Summary to a dictionary. Accepts a tensorflow.summary.Summary, one encoded as a string, or a list of such encoded as strings. """ values = {} if hasat...
python
wandb/integration/tensorboard/log.py
75
271
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
2,408
encode_images
def encode_images(_img_strs: List[bytes], _value: Any) -> None: try: from PIL import Image except ImportError: wandb.termwarn( "Install pillow if you are logging images with Tensorboard. " "To install, run `pip install pillow`.", re...
python
wandb/integration/tensorboard/log.py
105
133
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
2,409
reset_state
def reset_state() -> None: """Internal method for resetting state, called by wandb.finish().""" global STEPS STEPS = {"": {"step": 0}, "global": {"step": 0, "last_log": None}}
python
wandb/integration/tensorboard/log.py
274
277
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
2,410
_log
def _log( tf_summary_str_or_pb: Any, history: Optional["TBHistory"] = None, step: int = 0, namespace: str = "", **kwargs: Any, ) -> None: """Logs a tfsummary to wandb. Can accept a tf summary string or parsed event. Will use wandb.run.history unless a history object is passed. Can opt...
python
wandb/integration/tensorboard/log.py
280
346
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
2,411
log
def log(tf_summary_str_or_pb: Any, step: int = 0, namespace: str = "") -> None: if wandb.run is None: raise wandb.Error( "You must call `wandb.init()` before calling `wandb.tensorflow.log`" ) with telemetry.context() as tel: tel.feature.tensorboard_log = True _log(tf_su...
python
wandb/integration/tensorboard/log.py
349
358
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
2,412
unpatch
def unpatch() -> None: for module, method in wandb.patched["tensorboard"]: writer = wandb.util.get_module(module, lazy=False) setattr(writer, method, getattr(writer, f"orig_{method}")) wandb.patched["tensorboard"] = []
python
wandb/integration/tensorboard/monkeypatch.py
18
22
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
2,413
patch
def patch( save: bool = True, tensorboard_x: Optional[bool] = None, pytorch: Optional[bool] = None, root_logdir: str = "", ) -> None: if len(wandb.patched["tensorboard"]) > 0: raise ValueError( "Tensorboard already patched, remove `sync_tensorboard=True` " "from `wand...
python
wandb/integration/tensorboard/monkeypatch.py
25
85
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
2,414
_patch_tensorflow2
def _patch_tensorflow2( writer: Any, module: Any, save: bool = True, root_logdir: str = "", ) -> None: # This configures TensorFlow 2 style Tensorboard logging old_csfw_func = writer.create_summary_file_writer logdir_hist = [] def new_csfw_func(*args: Any, **kwargs: Any) -> Any: ...
python
wandb/integration/tensorboard/monkeypatch.py
88
133
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
2,415
new_csfw_func
def new_csfw_func(*args: Any, **kwargs: Any) -> Any: logdir = ( kwargs["logdir"].numpy().decode("utf8") if hasattr(kwargs["logdir"], "numpy") else kwargs["logdir"] ) logdir_hist.append(logdir) root_logdir_arg = root_logdir if len(set(logdir_hi...
python
wandb/integration/tensorboard/monkeypatch.py
98
129
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
2,416
_patch_file_writer
def _patch_file_writer( writer: Any, module: Any, save: bool = True, root_logdir: str = "", ) -> None: # This configures non-TensorFlow Tensorboard logging, or tensorflow <= 1.15 logdir_hist = [] class TBXEventFileWriter(writer.EventFileWriter): def __init__(self, logdir: str, *args...
python
wandb/integration/tensorboard/monkeypatch.py
136
178
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
2,417
__init__
def __init__(self, logdir: str, *args: Any, **kwargs: Any) -> None: logdir_hist.append(logdir) root_logdir_arg = root_logdir if len(set(logdir_hist)) > 1 and root_logdir == "": wandb.termwarn( "When using several event log directories, " ...
python
wandb/integration/tensorboard/monkeypatch.py
146
174
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
2,418
_notify_tensorboard_logdir
def _notify_tensorboard_logdir( logdir: str, save: bool = True, root_logdir: str = "" ) -> None: if wandb.run is not None: wandb.run._tensorboard_callback(logdir, save=save, root_logdir=root_logdir)
python
wandb/integration/tensorboard/monkeypatch.py
181
185
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
2,419
monitor
def monitor(): """Monitor a gym environment. Supports both gym and gymnasium. """ gym_lib: Optional[GymLib] = None # gym is not maintained anymore, gymnasium is the drop-in replacement - prefer it if wandb.util.get_module("gymnasium") is not None: gym_lib = "gymnasium" elif wandb.u...
python
wandb/integration/gym/__init__.py
22
84
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
2,420
close
def close(self): recorder.orig_close(self) m = re.match(r".+(video\.\d+).+", getattr(self, path)) if m: key = m.group(1) else: key = "videos" wandb.log({key: wandb.Video(getattr(self, path))})
python
wandb/integration/gym/__init__.py
64
71
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
2,421
del_
def del_(self): self.orig_close()
python
wandb/integration/gym/__init__.py
73
74
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
2,422
named_entity
def named_entity(docs): """Create a named entity visualization. Taken from https://github.com/wandb/wandb/blob/main/wandb/plots/named_entity.py. """ spacy = util.get_module( "spacy", required="part_of_speech requires the spacy library, install with `pip install spacy`", ) util....
python
wandb/integration/prodigy/prodigy.py
33
54
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
2,423
merge
def merge(dict1, dict2): """Return a new dictionary by merging two dictionaries recursively.""" result = deepcopy(dict1) for key, value in dict2.items(): if isinstance(value, collections.abc.Mapping): result[key] = merge(result.get(key, {}), value) else: result[key] ...
python
wandb/integration/prodigy/prodigy.py
57
67
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
2,424
get_schema
def get_schema(list_data_dict, struct, array_dict_types): """Get a schema of the dataset's structure and data types.""" # Get the structure of the JSON objects in the database # This is similar to getting a JSON schema but with slightly different format for _i, item in enumerate(list_data_dict): ...
python
wandb/integration/prodigy/prodigy.py
70
135
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
2,425
standardize
def standardize(item, structure, array_dict_types): """Standardize all rows/entries in dataset to fit the schema. Will look for missing values and fill it in so all rows have the same items and structure. """ for k, v in structure.items(): if k not in item: # If the structure/fi...
python
wandb/integration/prodigy/prodigy.py
138
176
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
2,426
create_table
def create_table(data): """Create a W&B Table. - Create/decode images from URL/Base64 - Uses spacy to translate NER span data to visualizations. """ # create table object from columns table_df = pd.DataFrame(data) columns = list(table_df.columns) if ("spans" in table_df.columns) and ("t...
python
wandb/integration/prodigy/prodigy.py
179
268
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
2,427
upload_dataset
def upload_dataset(dataset_name): """Upload dataset from local database to Weights & Biases. Args: dataset_name: The name of the dataset in the Prodigy database. """ # Check if wandb.init has been called if wandb.run is None: raise ValueError("You must call wandb.init() before uploa...
python
wandb/integration/prodigy/prodigy.py
271
299
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
2,428
_wandb_use
def _wandb_use(name: str, data: pd.DataFrame, datasets=False, run=None, testing=False, *args, **kwargs): # type: ignore if testing: return "datasets" if datasets else None if datasets: run.use_artifact(f"{name}:latest") wandb.termlog(f"Using artifact: {name} ({type(...
python
wandb/integration/metaflow/metaflow.py
39
45
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
2,429
wandb_track
def wandb_track( name: str, data: pd.DataFrame, datasets=False, run=None, testing=False, *args, **kwargs, ): if testing: return "pd.DataFrame" if datasets else None if datasets: artifact = wandb.Artifact(name, type="dat...
python
wandb/integration/metaflow/metaflow.py
48
65
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
2,430
_wandb_use
def _wandb_use(name: str, data: nn.Module, models=False, run=None, testing=False, *args, **kwargs): # type: ignore if testing: return "models" if models else None if models: run.use_artifact(f"{name}:latest") wandb.termlog(f"Using artifact: {name} ({type(data)})")
python
wandb/integration/metaflow/metaflow.py
77
83
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
2,431
wandb_track
def wandb_track( name: str, data: nn.Module, models=False, run=None, testing=False, *args, **kwargs, ): if testing: return "nn.Module" if models else None if models: artifact = wandb.Artifact(name, type="model") ...
python
wandb/integration/metaflow/metaflow.py
86
103
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
2,432
_wandb_use
def _wandb_use(name: str, data: BaseEstimator, models=False, run=None, testing=False, *args, **kwargs): # type: ignore if testing: return "models" if models else None if models: run.use_artifact(f"{name}:latest") wandb.termlog(f"Using artifact: {name} ({type(data)})...
python
wandb/integration/metaflow/metaflow.py
114
120
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
2,433
wandb_track
def wandb_track( name: str, data: BaseEstimator, models=False, run=None, testing=False, *args, **kwargs, ): if testing: return "BaseEstimator" if models else None if models: artifact = wandb.Artifact(name, type="model")...
python
wandb/integration/metaflow/metaflow.py
123
140
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
2,434
__init__
def __init__(self, flow): # do this to avoid recursion problem with __setattr__ self.__dict__.update( { "flow": flow, "inputs": {}, "outputs": {}, "base": set(dir(flow)), "params": {p: getattr(flow, p) for p in c...
python
wandb/integration/metaflow/metaflow.py
149
159
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
2,435
__setattr__
def __setattr__(self, key, val): self.outputs[key] = val return setattr(self.flow, key, val)
python
wandb/integration/metaflow/metaflow.py
161
163
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
2,436
__getattr__
def __getattr__(self, key): if key not in self.base and key not in self.outputs: self.inputs[key] = getattr(self.flow, key) return getattr(self.flow, key)
python
wandb/integration/metaflow/metaflow.py
165
168
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
2,437
wandb_track
def wandb_track(name: str, data: (dict, list, set, str, int, float, bool), run=None, testing=False, *args, **kwargs): # type: ignore if testing: return "scalar" run.log({name: data})
python
wandb/integration/metaflow/metaflow.py
172
176
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
2,438
wandb_track
def wandb_track( name: str, data: Path, datasets=False, run=None, testing=False, *args, **kwargs ): if testing: return "Path" if datasets else None if datasets: artifact = wandb.Artifact(name, type="dataset") if data.is_dir(): artifact.add_dir(data) elif data.is_...
python
wandb/integration/metaflow/metaflow.py
180
193
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
2,439
wandb_track
def wandb_track( name: str, data, others=False, run=None, testing=False, *args, **kwargs ): if testing: return "generic" if others else None if others: artifact = wandb.Artifact(name, type="other") with artifact.new_file(f"{name}.pkl", "wb") as f: pickle.dump(data, f) ...
python
wandb/integration/metaflow/metaflow.py
198
209
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
2,440
wandb_use
def wandb_use(name: str, data, *args, **kwargs): try: return _wandb_use(name, data, *args, **kwargs) except wandb.CommError: print( f"This artifact ({name}, {type(data)}) does not exist in the wandb datastore!" f"If you created an instance inline (e.g. sklearn.ensemble.Ra...
python
wandb/integration/metaflow/metaflow.py
213
221
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
2,441
wandb_use
def wandb_use(name: str, data: (dict, list, set, str, int, float, bool), *args, **kwargs): # type: ignore pass # do nothing for these types
python
wandb/integration/metaflow/metaflow.py
225
226
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
2,442
_wandb_use
def _wandb_use(name: str, data: Path, datasets=False, run=None, testing=False, *args, **kwargs): # type: ignore if testing: return "datasets" if datasets else None if datasets: run.use_artifact(f"{name}:latest") wandb.termlog(f"Using artifact: {name} ({type(data)})")
python
wandb/integration/metaflow/metaflow.py
230
236
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
2,443
_wandb_use
def _wandb_use(name: str, data, others=False, run=None, testing=False, *args, **kwargs): # type: ignore if testing: return "others" if others else None if others: run.use_artifact(f"{name}:latest") wandb.termlog(f"Using artifact: {name} ({type(data)})")
python
wandb/integration/metaflow/metaflow.py
240
246
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
2,444
coalesce
def coalesce(*arg): return next((a for a in arg if a is not None), None)
python
wandb/integration/metaflow/metaflow.py
249
250
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
2,445
wandb_log
def wandb_log( func=None, # /, # py38 only datasets=False, models=False, others=False, settings=None, ): """Automatically log parameters and artifacts to W&B by type dispatch. This decorator can be applied to a flow, step, or both. - Decorating a step will enable or disable logging...
python
wandb/integration/metaflow/metaflow.py
253
348
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
2,446
decorator
def decorator(func): # If you decorate a class, apply the decoration to all methods in that class if inspect.isclass(func): cls = func for attr in cls.__dict__: if callable(getattr(cls, attr)): if not hasattr(attr, "_base_func"): ...
python
wandb/integration/metaflow/metaflow.py
277
343
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
2,447
wrapper
def wrapper(self, *args, settings=settings, **kwargs): if not isinstance(settings, wandb.sdk.wandb_settings.Settings): settings = wandb.Settings() settings.update( run_group=coalesce( settings.run_group, f"{current.flow_name}/{current.run_id}"...
python
wandb/integration/metaflow/metaflow.py
292
332
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
2,448
_define_metric
def _define_metric(data: str, metric_name: str) -> None: """Capture model performance at the best step. instead of the last step, of training in your `wandb.summary` """ if "loss" in str.lower(metric_name): wandb.define_metric(f"{data}_{metric_name}", summary="min") elif str.lower(metric_na...
python
wandb/integration/lightgbm/__init__.py
53
63
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
2,449
_checkpoint_artifact
def _checkpoint_artifact( model: "Booster", iteration: int, aliases: "List[str]" ) -> None: """Upload model checkpoint as W&B artifact.""" # NOTE: type ignore required because wandb.run is improperly inferred as None type model_name = f"model_{wandb.run.id}" # type: ignore model_path = Path(wandb.r...
python
wandb/integration/lightgbm/__init__.py
66
78
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
2,450
_log_feature_importance
def _log_feature_importance(model: "Booster") -> None: """Log feature importance.""" feat_imps = model.feature_importance() feats = model.feature_name() fi_data = [[feat, feat_imp] for feat, feat_imp in zip(feats, feat_imps)] table = wandb.Table(data=fi_data, columns=["Feature", "Importance"]) w...
python
wandb/integration/lightgbm/__init__.py
81
94
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
2,451
wandb_callback
def wandb_callback(log_params: bool = True, define_metric: bool = True) -> Callable: """Automatically integrates LightGBM with wandb. Arguments: log_params: (boolean) if True (default) logs params passed to lightgbm.train as W&B config define_metric: (boolean) if True (default) capture model pe...
python
wandb/integration/lightgbm/__init__.py
97
161
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
2,452
_init
def _init(env: "CallbackEnv") -> None: with wb_telemetry.context() as tel: tel.feature.lightgbm_wandb_callback = True wandb.config.update(env.params) log_params_list[0] = False if define_metric_list[0]: for i in range(len(env.evaluation_result_list)): ...
python
wandb/integration/lightgbm/__init__.py
130
141
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
2,453
_callback
def _callback(env: "CallbackEnv") -> None: if log_params_list[0]: _init(env) eval_results: "Dict[str, Dict[str, List[Any]]]" = {} recorder = lightgbm.record_evaluation(eval_results) recorder(env) for validation_key in eval_results.keys(): for key in eval...
python
wandb/integration/lightgbm/__init__.py
143
159
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
2,454
log_summary
def log_summary( model: Booster, feature_importance: bool = True, save_model_checkpoint: bool = False ) -> None: """Log useful metrics about lightgbm model after training is done. Arguments: model: (Booster) is an instance of lightgbm.basic.Booster. feature_importance: (boolean) if True (de...
python
wandb/integration/lightgbm/__init__.py
164
215
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
2,455
__init__
def __init__(self, metric_period: int = 1): if wandb.run is None: raise wandb.Error("You must call `wandb.init()` before `WandbCallback()`") with wb_telemetry.context() as tel: tel.feature.catboost_wandb_callback = True self.metric_period: int = metric_period
python
wandb/integration/catboost/catboost.py
42
49
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
2,456
after_iteration
def after_iteration(self, info: SimpleNamespace) -> bool: if info.iteration % self.metric_period == 0: for data, metric in info.metrics.items(): for metric_name, log in metric.items(): # todo: replace with wandb.run._log once available wandb.lo...
python
wandb/integration/catboost/catboost.py
51
60
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
2,457
_checkpoint_artifact
def _checkpoint_artifact( model: Union[CatBoostClassifier, CatBoostRegressor], aliases: List[str] ) -> None: """Upload model checkpoint as W&B artifact.""" if wandb.run is None: raise wandb.Error( "You must call `wandb.init()` before `_checkpoint_artifact()`" ) model_name = ...
python
wandb/integration/catboost/catboost.py
63
80
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
2,458
_log_feature_importance
def _log_feature_importance( model: Union[CatBoostClassifier, CatBoostRegressor] ) -> None: """Log feature importance with default settings.""" if wandb.run is None: raise wandb.Error( "You must call `wandb.init()` before `_checkpoint_artifact()`" ) feat_df = model.get_featu...
python
wandb/integration/catboost/catboost.py
83
107
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
2,459
log_summary
def log_summary( model: Union[CatBoostClassifier, CatBoostRegressor], log_all_params: bool = True, save_model_checkpoint: bool = False, log_feature_importance: bool = True, ) -> None: """`log_summary` logs useful metrics about catboost model after training is done. Arguments: model: it ...
python
wandb/integration/catboost/catboost.py
110
178
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
2,460
sagemaker_auth
def sagemaker_auth(overrides=None, path=".", api_key=None): """Write a secrets.env file with the W&B ApiKey and any additional secrets passed. Arguments: overrides (dict, optional): Additional environment variables to write to secrets.env path (str, optional)...
python
wandb/integration/sagemaker/auth.py
7
28
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
2,461
parse_sm_config
def parse_sm_config() -> Dict[str, Any]: """Attempt to parse SageMaker configuration. Returns: A dictionary of SageMaker config keys/values or empty dict if not found. """ conf = {} if os.path.exists(sm_files.SM_PARAM_CONFIG) and os.path.exists( sm_files.SM_RESOURCE_CONFIG ): ...
python
wandb/integration/sagemaker/config.py
9
28
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
2,462
parse_sm_secrets
def parse_sm_secrets() -> Dict[str, str]: """We read our api_key from secrets.env in SageMaker.""" env_dict = dict() # Set secret variables if os.path.exists(sm_files.SM_SECRETS): for line in open(sm_files.SM_SECRETS): key, val = line.strip().split("=", 1) env_dict[key] =...
python
wandb/integration/sagemaker/resources.py
10
18
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
2,463
parse_sm_resources
def parse_sm_resources() -> Tuple[Dict[str, str], Dict[str, str]]: run_dict = dict() run_id = os.getenv("TRAINING_JOB_NAME") if run_id and os.getenv("WANDB_RUN_ID") is None: suffix = "".join( secrets.choice(string.ascii_lowercase + string.digits) for _ in range(6) ) run_...
python
wandb/integration/sagemaker/resources.py
21
34
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
2,464
_terminate_thread
def _terminate_thread(thread): if not thread.is_alive(): return if hasattr(thread, "_terminated"): return thread._terminated = True tid = getattr(thread, "_thread_id", None) if tid is None: for k, v in threading._active.items(): if v is thread: tid...
python
wandb/agents/pyagent.py
23
47
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
2,465
__init__
def __init__(self, command): self.command = command job_type = command.get("type") self.type = job_type self.run_id = command.get("run_id") self.config = command.get("args")
python
wandb/agents/pyagent.py
51
56
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
2,466
__repr__
def __repr__(self): if self.type == "run": return f"Job({self.run_id},{self.config})" elif self.type == "stop": return f"stop({self.run_id})" else: return "exit"
python
wandb/agents/pyagent.py
58
64
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
2,467
__init__
def __init__( self, sweep_id=None, project=None, entity=None, function=None, count=None ): self._sweep_path = sweep_id self._sweep_id = None self._project = project self._entity = entity self._function = function self._count = count # glob_config = os....
python
wandb/agents/pyagent.py
81
100
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
2,468
_init
def _init(self): # These are not in constructor so that Agent instance can be rerun self._run_threads = {} self._run_status = {} self._queue = queue.Queue() self._exit_flag = False self._exceptions = {} self._start_time = time.time()
python
wandb/agents/pyagent.py
102
109
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
2,469
_register
def _register(self): logger.debug("Agent._register()") agent = self._api.register_agent(socket.gethostname(), sweep_id=self._sweep_id) self._agent_id = agent["id"] logger.debug(f"agent_id = {self._agent_id}")
python
wandb/agents/pyagent.py
111
115
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
2,470
_setup
def _setup(self): logger.debug("Agent._setup()") self._init() parts = dict(entity=self._entity, project=self._project, name=self._sweep_path) err = util.parse_sweep_id(parts) if err: wandb.termerror(err) return entity = parts.get("entity") or self....
python
wandb/agents/pyagent.py
117
136
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
2,471
_stop_run
def _stop_run(self, run_id): logger.debug(f"Stopping run {run_id}.") self._run_status[run_id] = RunStatus.STOPPED thread = self._run_threads.get(run_id) if thread: _terminate_thread(thread)
python
wandb/agents/pyagent.py
138
143
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
2,472
_stop_all_runs
def _stop_all_runs(self): logger.debug("Stopping all runs.") for run in list(self._run_threads.keys()): self._stop_run(run)
python
wandb/agents/pyagent.py
145
148
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
2,473
_exit
def _exit(self): self._stop_all_runs() self._exit_flag = True # _terminate_thread(self._main_thread)
python
wandb/agents/pyagent.py
150
153
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
2,474
_heartbeat
def _heartbeat(self): while True: if self._exit_flag: return # if not self._main_thread.is_alive(): # return run_status = { run: True for run, status in self._run_status.items() if status in (RunS...
python
wandb/agents/pyagent.py
155
178
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
2,475
_run_jobs_from_queue
def _run_jobs_from_queue(self): # noqa:C901 global _INSTANCES _INSTANCES += 1 try: waiting = False count = 0 while True: if self._exit_flag: return try: try: job =...
python
wandb/agents/pyagent.py
180
275
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
2,476
_run_job
def _run_job(self, job): try: run_id = job.run_id config_file = os.path.join( "wandb", "sweep-" + self._sweep_id, "config-" + run_id + ".yaml" ) os.environ[wandb.env.RUN_ID] = run_id base_dir = os.environ.get(wandb.env.DIR, "") ...
python
wandb/agents/pyagent.py
277
311
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
2,477
run
def run(self): logger.info( "Starting sweep agent: entity={}, project={}, count={}".format( self._entity, self._project, self._count ) ) self._setup() # self._main_thread = threading.Thread(target=self._run_jobs_from_queue) self._heartbeat_...
python
wandb/agents/pyagent.py
313
326
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
2,478
pyagent
def pyagent(sweep_id, function, entity=None, project=None, count=None): """Generic agent entrypoint, used for CLI or jupyter. Arguments: sweep_id (dict): Sweep ID generated by CLI or sweep API function (func, optional): A function to call instead of the "program" entity (str, optional):...
python
wandb/agents/pyagent.py
329
348
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
2,479
is_running
def is_running(): return bool(_INSTANCES)
python
wandb/agents/pyagent.py
354
355
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
2,480
wandb_dir
def wandb_dir(root_dir=None): if root_dir is None or root_dir == "": try: cwd = os.getcwd() except OSError: termwarn("os.getcwd() no longer exists, using system temp directory") cwd = tempfile.gettempdir() root_dir = env.get_dir(cwd) path = os.path.joi...
python
wandb/old/core.py
31
45
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
2,481
_set_stage_dir
def _set_stage_dir(stage_dir): # Used when initing a new project with "wandb init" global __stage_dir__ __stage_dir__ = stage_dir
python
wandb/old/core.py
48
51
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
2,482
__init__
def __init__(self, message): super().__init__(message) self.message = message
python
wandb/old/core.py
57
59
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
2,483
encode
def encode(self, encoding): return self.message
python
wandb/old/core.py
62
63
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
2,484
termlog
def termlog(string="", newline=True, repeat=True): """Log to standard error with formatting. Arguments: string (str, optional): The string to print newline (bool, optional): Print a newline at the end of the string repeat (bool, optional): If set to False only prints the string once per...
python
wandb/old/core.py
80
105
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
2,485
termwarn
def termwarn(string, **kwargs): string = "\n".join([f"{WARN_STRING} {s}" for s in string.split("\n")]) termlog(string=string, newline=True, **kwargs)
python
wandb/old/core.py
108
110
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
2,486
termerror
def termerror(string, **kwargs): string = "\n".join([f"{ERROR_STRING} {s}" for s in string.split("\n")]) termlog(string=string, newline=True, **kwargs)
python
wandb/old/core.py
113
115
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
2,487
__init__
def __init__(self, root=None, path=()): self._path = tuple(path) if root is None: self._root = self self._json_dict = {} else: self._root = root json_dict = root._json_dict for k in path: json_dict = json_dict[k] ...
python
wandb/old/summary.py
25
41
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
2,488
__setattr__
def __setattr__(self, k, v): k = k.strip() if k.startswith("_"): object.__setattr__(self, k, v) else: self[k] = v
python
wandb/old/summary.py
43
48
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
2,489
__getattr__
def __getattr__(self, k): k = k.strip() if k.startswith("_"): return object.__getattribute__(self, k) else: return self[k]
python
wandb/old/summary.py
50
55
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
2,490
_root_get
def _root_get(self, path, child_dict): """Load a value at a particular path from the root. This should only be implemented by the "_root" child class. We pass the child_dict so the item can be set on it or not as appropriate. Returning None for a nonexistant path wouldn't be di...
python
wandb/old/summary.py
57
66
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
2,491
_root_set
def _root_set(self, path, new_keys_values): """Set a value at a particular path in the root. This should only be implemented by the "_root" child class. """ raise NotImplementedError
python
wandb/old/summary.py
68
73
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
2,492
_root_del
def _root_del(self, path): """Delete a value at a particular path in the root. This should only be implemented by the "_root" child class. """ raise NotImplementedError
python
wandb/old/summary.py
75
80
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
2,493
_write
def _write(self, commit=False): # should only be implemented on the root summary raise NotImplementedError
python
wandb/old/summary.py
82
84
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
2,494
keys
def keys(self): # _json_dict has the full set of keys, including those for h5 objects # that may not have been loaded yet return self._json_dict.keys()
python
wandb/old/summary.py
86
89
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
2,495
get
def get(self, k, default=None): if isinstance(k, str): k = k.strip() if k not in self._dict: self._root._root_get(self._path + (k,), self._dict) return self._dict.get(k, default)
python
wandb/old/summary.py
91
96
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
2,496
items
def items(self): # not all items may be loaded into self._dict, so we # have to build the sequence of items from scratch for k in self.keys(): yield k, self[k]
python
wandb/old/summary.py
98
102
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
2,497
__getitem__
def __getitem__(self, k): if isinstance(k, str): k = k.strip() self.get(k) # load the value into _dict if it should be there res = self._dict[k] return res
python
wandb/old/summary.py
104
111
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
2,498
__contains__
def __contains__(self, k): if isinstance(k, str): k = k.strip() return k in self._json_dict
python
wandb/old/summary.py
113
117
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
2,499
__setitem__
def __setitem__(self, k, v): if isinstance(k, str): k = k.strip() path = self._path if isinstance(v, dict): self._dict[k] = SummarySubDict(self._root, path + (k,)) self._root._root_set(path, [(k, {})]) self._dict[k].update(v) else: ...
python
wandb/old/summary.py
119
137
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
2,500
__delitem__
def __delitem__(self, k): k = k.strip() del self._dict[k] self._root._root_del(self._path + (k,)) self._root._write()
python
wandb/old/summary.py
139
144
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }