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
3,701
_load_dir_from_artifact
def _load_dir_from_artifact(source_artifact: "PublicArtifact", path: str) -> str: dl_path = None # Look through the entire manifest to find all of the files in the directory. # Construct the directory path by inspecting the target download location. for p, _ in source_artifact.manifest.entries.items():...
python
wandb/sdk/data_types/saved_model.py
53
67
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
3,702
__init__
def __init__( self, obj_or_path: Union[SavedModelObjType, str], **kwargs: Any ) -> None: super().__init__() if self.__class__ == _SavedModel: raise TypeError( "Cannot instantiate abstract SavedModel class - please use SavedModel.init(...) instead." ) ...
python
wandb/sdk/data_types/saved_model.py
87
115
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
3,703
init
def init(obj_or_path: Any, **kwargs: Any) -> "_SavedModel": maybe_instance = _SavedModel._maybe_init(obj_or_path, **kwargs) if maybe_instance is None: raise ValueError( f"No suitable SavedModel subclass constructor found for obj_or_path: {obj_or_path}" ) r...
python
wandb/sdk/data_types/saved_model.py
118
124
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
3,704
from_json
def from_json( cls: Type["_SavedModel"], json_obj: dict, source_artifact: "PublicArtifact" ) -> "_SavedModel": path = json_obj["path"] # First, if the entry is a file, the download it. entry = source_artifact.manifest.entries.get(path) if entry is not None: dl_pa...
python
wandb/sdk/data_types/saved_model.py
127
144
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
3,705
to_json
def to_json(self, run_or_artifact: Union["LocalRun", "LocalArtifact"]) -> dict: # Unlike other data types, we do not allow adding to a Run directly. There is a # bit of tech debt in the other data types which requires the input to `to_json` # to accept a Run or Artifact. However, Run additions s...
python
wandb/sdk/data_types/saved_model.py
146
183
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
3,706
model_obj
def model_obj(self) -> SavedModelObjType: """Return the model object.""" if self._model_obj is None: assert self._path is not None, "Cannot load model object without path" self._set_obj(self._deserialize(self._path)) assert self._model_obj is not None, "Model object is N...
python
wandb/sdk/data_types/saved_model.py
185
192
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
3,707
_deserialize
def _deserialize(path: str) -> SavedModelObjType: """Return the model object from a path. Allowed to throw errors.""" raise NotImplementedError
python
wandb/sdk/data_types/saved_model.py
196
198
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
3,708
_validate_obj
def _validate_obj(obj: Any) -> bool: """Validate the model object. Allowed to throw errors.""" raise NotImplementedError
python
wandb/sdk/data_types/saved_model.py
201
203
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
3,709
_serialize
def _serialize(obj: SavedModelObjType, dir_or_file_path: str) -> None: """Save the model to disk. The method will receive a directory path which all files needed for deserialization should be saved. A directory will always be passed if _path_extension is an empty string, else a single f...
python
wandb/sdk/data_types/saved_model.py
206
214
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
3,710
_maybe_init
def _maybe_init( cls: Type["_SavedModel"], obj_or_path: Any, **kwargs: Any ) -> Optional["_SavedModel"]: # _maybe_init is an exception-safe method that will return an instance of this class # (or any subclass of this class - recursively) OR None if no subclass constructor is found. #...
python
wandb/sdk/data_types/saved_model.py
218
240
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
3,711
_tmp_path
def _tmp_path(cls: Type["_SavedModel"]) -> str: # Generates a tmp path under our MEDIA_TMP directory which confirms to the file # or folder preferences of the class. assert isinstance(cls._path_extension, str), "_path_extension must be a string" tmp_path = os.path.abspath(os.path.join(ME...
python
wandb/sdk/data_types/saved_model.py
243
250
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
3,712
_copy_to_disk
def _copy_to_disk(self) -> None: # Creates a temporary path and writes a fresh copy of the # model to disk - updating the _path appropriately. tmp_path = self._tmp_path() self._dump(tmp_path) self._path = tmp_path
python
wandb/sdk/data_types/saved_model.py
253
258
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
3,713
_unset_obj
def _unset_obj(self) -> None: assert self._path is not None, "Cannot unset object if path is None" self._model_obj = None
python
wandb/sdk/data_types/saved_model.py
260
262
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
3,714
_set_obj
def _set_obj(self, model_obj: Any) -> None: assert model_obj is not None and self._validate_obj( model_obj ), f"Invalid model object {model_obj}" self._model_obj = model_obj
python
wandb/sdk/data_types/saved_model.py
264
268
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
3,715
_dump
def _dump(self, target_path: str) -> None: assert self._model_obj is not None, "Cannot dump if model object is None" self._serialize(self._model_obj, target_path)
python
wandb/sdk/data_types/saved_model.py
270
272
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
3,716
_get_cloudpickle
def _get_cloudpickle() -> "cloudpickle": return cast( "cloudpickle", util.get_module("cloudpickle", "ModelAdapter requires `cloudpickle`"), )
python
wandb/sdk/data_types/saved_model.py
275
279
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
3,717
__init__
def __init__( self, obj_or_path: Union[SavedModelObjType, str], dep_py_files: Optional[List[str]] = None, ): super().__init__(obj_or_path) if self.__class__ == _PicklingSavedModel: raise TypeError( "Cannot instantiate abstract _PicklingSavedModel c...
python
wandb/sdk/data_types/saved_model.py
291
318
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
3,718
from_json
def from_json( cls: Type["_SavedModel"], json_obj: dict, source_artifact: "PublicArtifact" ) -> "_PicklingSavedModel": backup_path = [p for p in sys.path] if ( "dep_py_files_path" in json_obj and json_obj["dep_py_files_path"] is not None ): dl_path...
python
wandb/sdk/data_types/saved_model.py
321
337
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
3,719
to_json
def to_json(self, run_or_artifact: Union["LocalRun", "LocalArtifact"]) -> dict: json_obj = super().to_json(run_or_artifact) assert isinstance(run_or_artifact, wandb.wandb_sdk.wandb_artifacts.Artifact) if self._dep_py_files_path is not None: json_obj["dep_py_files_path"] = _add_determ...
python
wandb/sdk/data_types/saved_model.py
339
348
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
3,720
_get_torch
def _get_torch() -> "torch": return cast( "torch", util.get_module("torch", "ModelAdapter requires `torch`"), )
python
wandb/sdk/data_types/saved_model.py
351
355
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
3,721
_deserialize
def _deserialize(dir_or_file_path: str) -> "torch.nn.Module": return _get_torch().load(dir_or_file_path)
python
wandb/sdk/data_types/saved_model.py
363
364
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
3,722
_validate_obj
def _validate_obj(obj: Any) -> bool: return isinstance(obj, _get_torch().nn.Module)
python
wandb/sdk/data_types/saved_model.py
367
368
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
3,723
_serialize
def _serialize(model_obj: "torch.nn.Module", dir_or_file_path: str) -> None: _get_torch().save( model_obj, dir_or_file_path, pickle_module=_get_cloudpickle(), )
python
wandb/sdk/data_types/saved_model.py
371
376
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
3,724
_get_sklearn
def _get_sklearn() -> "sklearn": return cast( "sklearn", util.get_module("sklearn", "ModelAdapter requires `sklearn`"), )
python
wandb/sdk/data_types/saved_model.py
379
383
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
3,725
_deserialize
def _deserialize( dir_or_file_path: str, ) -> "sklearn.base.BaseEstimator": with open(dir_or_file_path, "rb") as file: model = _get_cloudpickle().load(file) return model
python
wandb/sdk/data_types/saved_model.py
391
396
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
3,726
_validate_obj
def _validate_obj(obj: Any) -> bool: dynamic_sklearn = _get_sklearn() return cast( bool, ( dynamic_sklearn.base.is_classifier(obj) or dynamic_sklearn.base.is_outlier_detector(obj) or dynamic_sklearn.base.is_regressor(obj) ...
python
wandb/sdk/data_types/saved_model.py
399
408
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
3,727
_serialize
def _serialize( model_obj: "sklearn.base.BaseEstimator", dir_or_file_path: str ) -> None: dynamic_cloudpickle = _get_cloudpickle() with open(dir_or_file_path, "wb") as file: dynamic_cloudpickle.dump(model_obj, file)
python
wandb/sdk/data_types/saved_model.py
411
416
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
3,728
_get_tf_keras
def _get_tf_keras() -> "tensorflow.keras": return cast( "tensorflow", util.get_module("tensorflow", "ModelAdapter requires `tensorflow`"), ).keras
python
wandb/sdk/data_types/saved_model.py
419
423
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
3,729
_deserialize
def _deserialize( dir_or_file_path: str, ) -> "tensorflow.keras.Model": return _get_tf_keras().models.load_model(dir_or_file_path)
python
wandb/sdk/data_types/saved_model.py
431
434
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
3,730
_validate_obj
def _validate_obj(obj: Any) -> bool: return isinstance(obj, _get_tf_keras().models.Model)
python
wandb/sdk/data_types/saved_model.py
437
438
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
3,731
_serialize
def _serialize(model_obj: "tensorflow.keras.Model", dir_or_file_path: str) -> None: _get_tf_keras().models.save_model( model_obj, dir_or_file_path, include_optimizer=True )
python
wandb/sdk/data_types/saved_model.py
441
444
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
3,732
make_plot_media
def make_plot_media( cls: Type["Plotly"], val: Union["plotly.Figure", "matplotlib.artist.Artist"] ) -> Union[Image, "Plotly"]: if util.is_matplotlib_typename(util.get_full_typename(val)): if util.matplotlib_contains_images(val): return Image(val) val = util.ma...
python
wandb/sdk/data_types/plotly.py
42
49
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
3,733
__init__
def __init__(self, val: Union["plotly.Figure", "matplotlib.artist.Artist"]): super().__init__() # First, check to see if the incoming `val` object is a plotfly figure if not util.is_plotly_figure_typename(util.get_full_typename(val)): # If it is not, but it is a matplotlib figure, th...
python
wandb/sdk/data_types/plotly.py
51
72
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
3,734
get_media_subdir
def get_media_subdir(cls: Type["Plotly"]) -> str: return os.path.join("media", "plotly")
python
wandb/sdk/data_types/plotly.py
75
76
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
3,735
to_json
def to_json(self, run_or_artifact: Union["LocalRun", "LocalArtifact"]) -> dict: json_dict = super().to_json(run_or_artifact) json_dict["_type"] = self._log_type return json_dict
python
wandb/sdk/data_types/plotly.py
78
81
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
3,736
write_gif_with_image_io
def write_gif_with_image_io( clip: Any, filename: str, fps: Optional[int] = None ) -> None: imageio = util.get_module( "imageio", required='wandb.Video requires imageio when passing raw data. Install with "pip install imageio"', ) writer = imageio.save( filename, duration=1.0 / ...
python
wandb/sdk/data_types/video.py
31
46
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
3,737
__init__
def __init__( self, data_or_path: Union["np.ndarray", str, "TextIO", "BytesIO"], caption: Optional[str] = None, fps: int = 4, format: Optional[str] = None, ): super().__init__() self._fps = fps self._format = format or "gif" self._width = None...
python
wandb/sdk/data_types/video.py
84
127
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
3,738
encode
def encode(self) -> None: mpy = util.get_module( "moviepy.editor", required='wandb.Video requires moviepy and imageio when passing raw data. Install with "pip install moviepy imageio"', ) tensor = self._prepare_video(self.data) _, self._height, self._width, self....
python
wandb/sdk/data_types/video.py
129
166
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
3,739
get_media_subdir
def get_media_subdir(cls: Type["Video"]) -> str: return os.path.join("media", "videos")
python
wandb/sdk/data_types/video.py
169
170
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
3,740
to_json
def to_json(self, run_or_artifact: Union["LocalRun", "LocalArtifact"]) -> dict: json_dict = super().to_json(run_or_artifact) json_dict["_type"] = self._log_type if self._width is not None: json_dict["width"] = self._width if self._height is not None: json_dict["h...
python
wandb/sdk/data_types/video.py
172
183
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
3,741
_prepare_video
def _prepare_video(self, video: "np.ndarray") -> "np.ndarray": """This logic was mostly taken from tensorboardX.""" np = util.get_module( "numpy", required='wandb.Video requires numpy when passing raw data. To get it, run "pip install numpy".', ) if video.ndim < 4...
python
wandb/sdk/data_types/video.py
185
219
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
3,742
is_power2
def is_power2(num: int) -> bool: return num != 0 and ((num & (num - 1)) == 0)
python
wandb/sdk/data_types/video.py
203
204
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
3,743
seq_to_json
def seq_to_json( cls: Type["Video"], seq: Sequence["BatchableMedia"], run: "LocalRun", key: str, step: Union[int, str], ) -> dict: base_path = os.path.join(run.dir, cls.get_media_subdir()) filesystem.mkdir_exists_ok(base_path) meta = { "_t...
python
wandb/sdk/data_types/video.py
222
238
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
3,744
_server_accepts_image_filenames
def _server_accepts_image_filenames() -> bool: if util._is_offline(): return True # Newer versions of wandb accept large image filenames arrays # but older versions would have issues with this. max_cli_version = util._get_max_cli_version() if max_cli_version is None: return False ...
python
wandb/sdk/data_types/image.py
36
50
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
3,745
_server_accepts_artifact_path
def _server_accepts_artifact_path() -> bool: from pkg_resources import parse_version target_version = "0.12.14" max_cli_version = util._get_max_cli_version() if not util._is_offline() else None accepts_artifact_path: bool = max_cli_version is not None and parse_version( target_version ) <= ...
python
wandb/sdk/data_types/image.py
53
61
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
3,746
__init__
def __init__( self, data_or_path: "ImageDataOrPathType", mode: Optional[str] = None, caption: Optional[str] = None, grouping: Optional[int] = None, classes: Optional[Union["Classes", Sequence[dict]]] = None, boxes: Optional[Union[Dict[str, "BoundingBoxes2D"], Dict...
python
wandb/sdk/data_types/image.py
128
163
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
3,747
_set_initialization_meta
def _set_initialization_meta( self, grouping: Optional[int] = None, caption: Optional[str] = None, classes: Optional[Union["Classes", Sequence[dict]]] = None, boxes: Optional[Union[Dict[str, "BoundingBoxes2D"], Dict[str, dict]]] = None, masks: Optional[Union[Dict[str, "Im...
python
wandb/sdk/data_types/image.py
165
227
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
3,748
_initialize_from_wbimage
def _initialize_from_wbimage(self, wbimage: "Image") -> None: self._grouping = wbimage._grouping self._caption = wbimage._caption self._width = wbimage._width self._height = wbimage._height self._image = wbimage._image self._classes = wbimage._classes self._path =...
python
wandb/sdk/data_types/image.py
229
247
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
3,749
_initialize_from_path
def _initialize_from_path(self, path: str) -> None: pil_image = util.get_module( "PIL.Image", required='wandb.Image needs the PIL package. To get it, run "pip install pillow".', ) self._set_file(path, is_tmp=False) self._image = pil_image.open(path) assert...
python
wandb/sdk/data_types/image.py
249
259
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
3,750
_initialize_from_reference
def _initialize_from_reference(self, path: str) -> None: self._path = path self._is_tmp = False self._sha256 = hashlib.sha256(path.encode("utf-8")).hexdigest() path = parse.urlparse(path).path ext = path.split("/")[-1].split(".")[-1] self.format = ext
python
wandb/sdk/data_types/image.py
261
267
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
3,751
_initialize_from_data
def _initialize_from_data( self, data: "ImageDataType", mode: Optional[str] = None, ) -> None: pil_image = util.get_module( "PIL.Image", required='wandb.Image needs the PIL package. To get it, run "pip install pillow".', ) if util.is_matplotlib...
python
wandb/sdk/data_types/image.py
269
307
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
3,752
from_json
def from_json( cls: Type["Image"], json_obj: dict, source_artifact: "PublicArtifact" ) -> "Image": classes = None if json_obj.get("classes") is not None: classes = source_artifact.get(json_obj["classes"]["path"]) masks = json_obj.get("masks") _masks: Optional[Dic...
python
wandb/sdk/data_types/image.py
310
341
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
3,753
get_media_subdir
def get_media_subdir(cls: Type["Image"]) -> str: return os.path.join("media", "images")
python
wandb/sdk/data_types/image.py
344
345
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
3,754
bind_to_run
def bind_to_run( self, run: "LocalRun", key: Union[int, str], step: Union[int, str], id_: Optional[Union[int, str]] = None, ignore_copy_err: Optional[bool] = None, ) -> None: # For Images, we are going to avoid copying the image file to the run. # We s...
python
wandb/sdk/data_types/image.py
347
386
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
3,755
to_json
def to_json(self, run_or_artifact: Union["LocalRun", "LocalArtifact"]) -> dict: json_dict = super().to_json(run_or_artifact) json_dict["_type"] = Image._log_type json_dict["format"] = self.format if self._width is not None: json_dict["width"] = self._width if self._h...
python
wandb/sdk/data_types/image.py
388
438
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
3,756
guess_mode
def guess_mode(self, data: "np.ndarray") -> str: """Guess what type of image the np.array is representing.""" # TODO: do we want to support dimensions being at the beginning of the array? if data.ndim == 2: return "L" elif data.shape[-1] == 3: return "RGB" ...
python
wandb/sdk/data_types/image.py
440
452
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
3,757
to_uint8
def to_uint8(cls, data: "np.ndarray") -> "np.ndarray": """Convert image data to uint8. Convert floating point image on the range [0,1] and integer images on the range [0,255] to uint8, clipping if necessary. """ np = util.get_module( "numpy", required="wa...
python
wandb/sdk/data_types/image.py
455
477
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
3,758
seq_to_json
def seq_to_json( cls: Type["Image"], seq: Sequence["BatchableMedia"], run: "LocalRun", key: str, step: Union[int, str], ) -> dict: """Combine a list of images into a meta dictionary object describing the child images.""" if TYPE_CHECKING: seq = cas...
python
wandb/sdk/data_types/image.py
480
551
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
3,759
size_equals_image
def size_equals_image(image: "Image") -> bool: img_width, img_height = image.image.size # type: ignore return img_width == width and img_height == height
python
wandb/sdk/data_types/image.py
508
510
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
3,760
all_masks
def all_masks( cls: Type["Image"], images: Sequence["Image"], run: "LocalRun", run_key: str, step: Union[int, str], ) -> Union[List[Optional[dict]], bool]: all_mask_groups: List[Optional[dict]] = [] for image in images: if image._masks: ...
python
wandb/sdk/data_types/image.py
554
574
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
3,761
all_boxes
def all_boxes( cls: Type["Image"], images: Sequence["Image"], run: "LocalRun", run_key: str, step: Union[int, str], ) -> Union[List[Optional[dict]], bool]: all_box_groups: List[Optional[dict]] = [] for image in images: if image._boxes: ...
python
wandb/sdk/data_types/image.py
577
597
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
3,762
all_captions
def all_captions( cls: Type["Image"], images: Sequence["Media"] ) -> Union[bool, Sequence[Optional[str]]]: return cls.captions(images)
python
wandb/sdk/data_types/image.py
600
603
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
3,763
__ne__
def __ne__(self, other: object) -> bool: return not self.__eq__(other)
python
wandb/sdk/data_types/image.py
605
606
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
3,764
__eq__
def __eq__(self, other: object) -> bool: if not isinstance(other, Image): return False else: if self.path_is_reference(self._path) and self.path_is_reference( other._path ): return self._path == other._path self_image = self...
python
wandb/sdk/data_types/image.py
608
630
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
3,765
to_data_array
def to_data_array(self) -> List[Any]: res = [] if self.image is not None: data = list(self.image.getdata()) for i in range(self.image.height): res.append(data[i * self.image.width : (i + 1) * self.image.width]) self._free_ram() return res
python
wandb/sdk/data_types/image.py
632
639
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
3,766
_free_ram
def _free_ram(self) -> None: if self._path is not None: self._image = None
python
wandb/sdk/data_types/image.py
641
643
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
3,767
image
def image(self) -> Optional["PILImage"]: if self._image is None: if self._path is not None and not self.path_is_reference(self._path): pil_image = util.get_module( "PIL.Image", required='wandb.Image needs the PIL package. To get it, run "pip in...
python
wandb/sdk/data_types/image.py
646
655
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
3,768
_wb_filename
def _wb_filename( key: Union[str, int], step: Union[str, int], id: Union[str, int], extension: str ) -> str: return f"{str(key)}_{str(step)}_{str(id)}{extension}"
python
wandb/sdk/data_types/base_types/media.py
27
30
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
3,769
__init__
def __init__(self, caption: Optional[str] = None) -> None: super().__init__() self._path = None # The run under which this object is bound, if any. self._run = None self._caption = caption
python
wandb/sdk/data_types/base_types/media.py
48
53
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
3,770
_set_file
def _set_file( self, path: str, is_tmp: bool = False, extension: Optional[str] = None ) -> None: self._path = path self._is_tmp = is_tmp self._extension = extension assert extension is None or path.endswith( extension ), 'Media file extension "{}" must occ...
python
wandb/sdk/data_types/base_types/media.py
55
69
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
3,771
get_media_subdir
def get_media_subdir(cls: Type["Media"]) -> str: raise NotImplementedError
python
wandb/sdk/data_types/base_types/media.py
72
73
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
3,772
captions
def captions( media_items: Sequence["Media"], ) -> Union[bool, Sequence[Optional[str]]]: if media_items[0]._caption is not None: return [m._caption for m in media_items] else: return False
python
wandb/sdk/data_types/base_types/media.py
76
82
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
3,773
is_bound
def is_bound(self) -> bool: return self._run is not None
python
wandb/sdk/data_types/base_types/media.py
84
85
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
3,774
file_is_set
def file_is_set(self) -> bool: return self._path is not None and self._sha256 is not None
python
wandb/sdk/data_types/base_types/media.py
87
88
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
3,775
bind_to_run
def bind_to_run( self, run: "LocalRun", key: Union[int, str], step: Union[int, str], id_: Optional[Union[int, str]] = None, ignore_copy_err: Optional[bool] = None, ) -> None: """Bind this object to a particular Run. Calling this function is necessary ...
python
wandb/sdk/data_types/base_types/media.py
90
144
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
3,776
to_json
def to_json(self, run: Union["LocalRun", "LocalArtifact"]) -> dict: """Serialize the object into a JSON blob. Uses run or artifact to store additional data. If `run_or_artifact` is a wandb.Run then `self.bind_to_run()` must have been previously been called. Args: run_or_art...
python
wandb/sdk/data_types/base_types/media.py
146
252
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
3,777
from_json
def from_json( cls: Type["Media"], json_obj: dict, source_artifact: "PublicArtifact" ) -> "Media": """Likely will need to override for any more complicated media objects.""" return cls(source_artifact.get_path(json_obj["path"]).download())
python
wandb/sdk/data_types/base_types/media.py
255
259
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
3,778
__eq__
def __eq__(self, other: object) -> bool: """Likely will need to override for any more complicated media objects.""" return ( isinstance(other, self.__class__) and hasattr(self, "_sha256") and hasattr(other, "_sha256") and self._sha256 == other._sha256 ...
python
wandb/sdk/data_types/base_types/media.py
261
268
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
3,779
path_is_reference
def path_is_reference(path: Optional[str]) -> bool: return bool(path and re.match(r"^(gs|s3|https?)://", path))
python
wandb/sdk/data_types/base_types/media.py
271
272
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
3,780
__init__
def __init__(self) -> None: super().__init__()
python
wandb/sdk/data_types/base_types/media.py
282
283
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
3,781
seq_to_json
def seq_to_json( cls: Type["BatchableMedia"], seq: Sequence["BatchableMedia"], run: "LocalRun", key: str, step: Union[int, str], ) -> dict: raise NotImplementedError
python
wandb/sdk/data_types/base_types/media.py
286
293
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
3,782
_numpy_arrays_to_lists
def _numpy_arrays_to_lists( payload: Union[dict, Sequence, "np.ndarray"] ) -> Union[Sequence, dict, str, int, float, bool]: # Casts all numpy arrays to lists so we don't convert them to histograms, primarily for Plotly if isinstance(payload, dict): res = {} for key, val in payload.items(): ...
python
wandb/sdk/data_types/base_types/media.py
296
318
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
3,783
__init__
def __init__(self, val: dict) -> None: super().__init__() self.validate(val) self._val = val ext = "." + self.type_name() + ".json" tmp_path = os.path.join(MEDIA_TMP.name, runid.generate_id() + ext) with codecs.open(tmp_path, "w", encoding="utf-8") as fp: ut...
python
wandb/sdk/data_types/base_types/json_metadata.py
26
36
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
3,784
get_media_subdir
def get_media_subdir(cls: Type["JSONMetadata"]) -> str: return os.path.join("media", "metadata", cls.type_name())
python
wandb/sdk/data_types/base_types/json_metadata.py
39
40
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
3,785
to_json
def to_json(self, run_or_artifact: Union["LocalRun", "LocalArtifact"]) -> dict: json_dict = super().to_json(run_or_artifact) json_dict["_type"] = self.type_name() return json_dict
python
wandb/sdk/data_types/base_types/json_metadata.py
42
46
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
3,786
type_name
def type_name(cls) -> str: return "metadata"
python
wandb/sdk/data_types/base_types/json_metadata.py
50
51
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
3,787
validate
def validate(self, val: dict) -> bool: return True
python
wandb/sdk/data_types/base_types/json_metadata.py
53
54
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
3,788
_server_accepts_client_ids
def _server_accepts_client_ids() -> bool: from pkg_resources import parse_version # First, if we are offline, assume the backend server cannot # accept client IDs. Unfortunately, this is the best we can do # until we are sure that all local versions are > "0.11.0" max_cli_version. # The practical i...
python
wandb/sdk/data_types/base_types/wb_value.py
14
35
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
3,789
__init__
def __init__(self, artifact: "PublicArtifact", name: Optional[str] = None) -> None: self.artifact = artifact self.name = name
python
wandb/sdk/data_types/base_types/wb_value.py
42
44
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
3,790
__init__
def __init__(self, artifact: "LocalArtifact", name: Optional[str] = None) -> None: self.artifact = artifact self.name = name
python
wandb/sdk/data_types/base_types/wb_value.py
51
53
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
3,791
__init__
def __init__(self) -> None: self._artifact_source = None self._artifact_target = None
python
wandb/sdk/data_types/base_types/wb_value.py
72
74
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
3,792
to_json
def to_json(self, run_or_artifact: Union["LocalRun", "LocalArtifact"]) -> dict: """Serialize the object into a JSON blob. Uses current run or artifact to store additional data. Args: run_or_artifact (wandb.Run | wandb.Artifact): the Run or Artifact for which this ob...
python
wandb/sdk/data_types/base_types/wb_value.py
76
89
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
3,793
from_json
def from_json( cls: Type["WBValue"], json_obj: dict, source_artifact: "PublicArtifact" ) -> "WBValue": """Deserialize a `json_obj` into it's class representation. If additional resources were stored in the `run_or_artifact` artifact during the `to_json` call, then those resources sh...
python
wandb/sdk/data_types/base_types/wb_value.py
92
105
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
3,794
with_suffix
def with_suffix(cls: Type["WBValue"], name: str, filetype: str = "json") -> str: """Get the name with the appropriate suffix. Args: name (str): the name of the file filetype (str, optional): the filetype to use. Defaults to "json". Returns: str: a filename w...
python
wandb/sdk/data_types/base_types/wb_value.py
108
125
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
3,795
init_from_json
def init_from_json( json_obj: dict, source_artifact: "PublicArtifact" ) -> Optional["WBValue"]: """Initialize a `WBValue` from a JSON blob based on the class that creatd it. Looks through all subclasses and tries to match the json obj with the class which created it. It will then ca...
python
wandb/sdk/data_types/base_types/wb_value.py
128
155
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
3,796
type_mapping
def type_mapping() -> "TypeMappingType": """Return a map from `_log_type` to subclass. Used to lookup correct types for deserialization. Returns: dict: dictionary of str:class """ if WBValue._type_mapping is None: WBValue._type_mapping = {} frontier =...
python
wandb/sdk/data_types/base_types/wb_value.py
158
176
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
3,797
__eq__
def __eq__(self, other: object) -> bool: return id(self) == id(other)
python
wandb/sdk/data_types/base_types/wb_value.py
178
179
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
3,798
__ne__
def __ne__(self, other: object) -> bool: return not self.__eq__(other)
python
wandb/sdk/data_types/base_types/wb_value.py
181
182
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
3,799
to_data_array
def to_data_array(self) -> List[Any]: """Convert the object to a list of primitives representing the underlying data.""" raise NotImplementedError
python
wandb/sdk/data_types/base_types/wb_value.py
184
186
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
3,800
_set_artifact_source
def _set_artifact_source( self, artifact: "PublicArtifact", name: Optional[str] = None ) -> None: assert ( self._artifact_source is None ), "Cannot update artifact_source. Existing source: {}/{}".format( self._artifact_source.artifact, self._artifact_source.name ...
python
wandb/sdk/data_types/base_types/wb_value.py
188
196
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }