wandb 0.13.10__py3-none-any.whl → 0.14.0__py3-none-any.whl
Sign up to get free protection for your applications and to get access to all the features.
- wandb/__init__.py +2 -3
- wandb/apis/__init__.py +1 -3
- wandb/apis/importers/__init__.py +4 -0
- wandb/apis/importers/base.py +312 -0
- wandb/apis/importers/mlflow.py +113 -0
- wandb/apis/internal.py +29 -2
- wandb/apis/normalize.py +6 -5
- wandb/apis/public.py +163 -180
- wandb/apis/reports/_templates.py +6 -12
- wandb/apis/reports/report.py +1 -1
- wandb/apis/reports/runset.py +1 -3
- wandb/apis/reports/util.py +12 -10
- wandb/beta/workflows.py +57 -34
- wandb/catboost/__init__.py +1 -2
- wandb/cli/cli.py +215 -133
- wandb/data_types.py +63 -56
- wandb/docker/__init__.py +78 -16
- wandb/docker/auth.py +21 -22
- wandb/env.py +0 -1
- wandb/errors/__init__.py +8 -116
- wandb/errors/term.py +1 -1
- wandb/fastai/__init__.py +1 -2
- wandb/filesync/dir_watcher.py +8 -5
- wandb/filesync/step_prepare.py +76 -75
- wandb/filesync/step_upload.py +1 -2
- wandb/integration/catboost/__init__.py +1 -3
- wandb/integration/catboost/catboost.py +8 -14
- wandb/integration/fastai/__init__.py +7 -13
- wandb/integration/gym/__init__.py +35 -4
- wandb/integration/keras/__init__.py +3 -3
- wandb/integration/keras/callbacks/metrics_logger.py +9 -8
- wandb/integration/keras/callbacks/model_checkpoint.py +9 -9
- wandb/integration/keras/callbacks/tables_builder.py +31 -19
- wandb/integration/kfp/kfp_patch.py +20 -17
- wandb/integration/kfp/wandb_logging.py +1 -2
- wandb/integration/lightgbm/__init__.py +21 -19
- wandb/integration/prodigy/prodigy.py +6 -7
- wandb/integration/sacred/__init__.py +9 -12
- wandb/integration/sagemaker/__init__.py +1 -3
- wandb/integration/sagemaker/auth.py +0 -1
- wandb/integration/sagemaker/config.py +1 -1
- wandb/integration/sagemaker/resources.py +1 -1
- wandb/integration/sb3/sb3.py +8 -4
- wandb/integration/tensorboard/__init__.py +1 -3
- wandb/integration/tensorboard/log.py +8 -8
- wandb/integration/tensorboard/monkeypatch.py +11 -9
- wandb/integration/tensorflow/__init__.py +1 -3
- wandb/integration/xgboost/__init__.py +4 -6
- wandb/integration/yolov8/__init__.py +7 -0
- wandb/integration/yolov8/yolov8.py +250 -0
- wandb/jupyter.py +31 -35
- wandb/lightgbm/__init__.py +1 -2
- wandb/old/settings.py +2 -2
- wandb/plot/bar.py +1 -2
- wandb/plot/confusion_matrix.py +1 -3
- wandb/plot/histogram.py +1 -2
- wandb/plot/line.py +1 -2
- wandb/plot/line_series.py +4 -4
- wandb/plot/pr_curve.py +17 -20
- wandb/plot/roc_curve.py +1 -3
- wandb/plot/scatter.py +1 -2
- wandb/proto/v3/wandb_server_pb2.py +85 -39
- wandb/proto/v3/wandb_telemetry_pb2.py +10 -10
- wandb/proto/v4/wandb_server_pb2.py +51 -39
- wandb/proto/v4/wandb_telemetry_pb2.py +10 -10
- wandb/sdk/__init__.py +1 -3
- wandb/sdk/backend/backend.py +1 -1
- wandb/sdk/data_types/_dtypes.py +38 -30
- wandb/sdk/data_types/base_types/json_metadata.py +1 -3
- wandb/sdk/data_types/base_types/media.py +17 -17
- wandb/sdk/data_types/base_types/wb_value.py +33 -26
- wandb/sdk/data_types/helper_types/bounding_boxes_2d.py +91 -125
- wandb/sdk/data_types/helper_types/classes.py +1 -1
- wandb/sdk/data_types/helper_types/image_mask.py +12 -12
- wandb/sdk/data_types/histogram.py +5 -4
- wandb/sdk/data_types/html.py +1 -2
- wandb/sdk/data_types/image.py +11 -11
- wandb/sdk/data_types/molecule.py +3 -6
- wandb/sdk/data_types/object_3d.py +1 -2
- wandb/sdk/data_types/plotly.py +1 -2
- wandb/sdk/data_types/saved_model.py +10 -8
- wandb/sdk/data_types/video.py +1 -1
- wandb/sdk/integration_utils/data_logging.py +5 -5
- wandb/sdk/interface/artifacts.py +288 -266
- wandb/sdk/interface/interface.py +2 -3
- wandb/sdk/interface/interface_grpc.py +1 -1
- wandb/sdk/interface/interface_queue.py +1 -1
- wandb/sdk/interface/interface_relay.py +1 -1
- wandb/sdk/interface/interface_shared.py +1 -2
- wandb/sdk/interface/interface_sock.py +1 -1
- wandb/sdk/interface/message_future.py +1 -1
- wandb/sdk/interface/message_future_poll.py +1 -1
- wandb/sdk/interface/router.py +1 -1
- wandb/sdk/interface/router_queue.py +1 -1
- wandb/sdk/interface/router_relay.py +1 -1
- wandb/sdk/interface/router_sock.py +1 -1
- wandb/sdk/interface/summary_record.py +1 -1
- wandb/sdk/internal/artifacts.py +1 -1
- wandb/sdk/internal/datastore.py +2 -3
- wandb/sdk/internal/file_pusher.py +5 -3
- wandb/sdk/internal/file_stream.py +22 -19
- wandb/sdk/internal/handler.py +5 -4
- wandb/sdk/internal/internal.py +1 -1
- wandb/sdk/internal/internal_api.py +115 -55
- wandb/sdk/internal/job_builder.py +1 -3
- wandb/sdk/internal/profiler.py +1 -1
- wandb/sdk/internal/progress.py +4 -6
- wandb/sdk/internal/sample.py +1 -3
- wandb/sdk/internal/sender.py +28 -16
- wandb/sdk/internal/settings_static.py +5 -5
- wandb/sdk/internal/system/assets/__init__.py +1 -0
- wandb/sdk/internal/system/assets/cpu.py +3 -9
- wandb/sdk/internal/system/assets/disk.py +2 -4
- wandb/sdk/internal/system/assets/gpu.py +6 -18
- wandb/sdk/internal/system/assets/gpu_apple.py +2 -4
- wandb/sdk/internal/system/assets/interfaces.py +50 -22
- wandb/sdk/internal/system/assets/ipu.py +1 -3
- wandb/sdk/internal/system/assets/memory.py +7 -13
- wandb/sdk/internal/system/assets/network.py +4 -8
- wandb/sdk/internal/system/assets/open_metrics.py +283 -0
- wandb/sdk/internal/system/assets/tpu.py +1 -4
- wandb/sdk/internal/system/assets/trainium.py +26 -14
- wandb/sdk/internal/system/system_info.py +2 -3
- wandb/sdk/internal/system/system_monitor.py +52 -20
- wandb/sdk/internal/tb_watcher.py +12 -13
- wandb/sdk/launch/_project_spec.py +54 -65
- wandb/sdk/launch/agent/agent.py +374 -90
- wandb/sdk/launch/builder/abstract.py +61 -7
- wandb/sdk/launch/builder/build.py +81 -110
- wandb/sdk/launch/builder/docker_builder.py +181 -0
- wandb/sdk/launch/builder/kaniko_builder.py +419 -0
- wandb/sdk/launch/builder/noop.py +31 -12
- wandb/sdk/launch/builder/templates/_wandb_bootstrap.py +70 -20
- wandb/sdk/launch/environment/abstract.py +28 -0
- wandb/sdk/launch/environment/aws_environment.py +276 -0
- wandb/sdk/launch/environment/gcp_environment.py +271 -0
- wandb/sdk/launch/environment/local_environment.py +65 -0
- wandb/sdk/launch/github_reference.py +3 -8
- wandb/sdk/launch/launch.py +38 -29
- wandb/sdk/launch/launch_add.py +6 -8
- wandb/sdk/launch/loader.py +230 -0
- wandb/sdk/launch/registry/abstract.py +54 -0
- wandb/sdk/launch/registry/elastic_container_registry.py +163 -0
- wandb/sdk/launch/registry/google_artifact_registry.py +203 -0
- wandb/sdk/launch/registry/local_registry.py +62 -0
- wandb/sdk/launch/runner/abstract.py +1 -16
- wandb/sdk/launch/runner/{kubernetes.py → kubernetes_runner.py} +83 -95
- wandb/sdk/launch/runner/local_container.py +46 -22
- wandb/sdk/launch/runner/local_process.py +1 -4
- wandb/sdk/launch/runner/{aws.py → sagemaker_runner.py} +53 -212
- wandb/sdk/launch/runner/{gcp_vertex.py → vertex_runner.py} +38 -55
- wandb/sdk/launch/sweeps/__init__.py +3 -2
- wandb/sdk/launch/sweeps/scheduler.py +132 -39
- wandb/sdk/launch/sweeps/scheduler_sweep.py +80 -89
- wandb/sdk/launch/utils.py +101 -30
- wandb/sdk/launch/wandb_reference.py +2 -7
- wandb/sdk/lib/_settings_toposort_generate.py +166 -0
- wandb/sdk/lib/_settings_toposort_generated.py +201 -0
- wandb/sdk/lib/apikey.py +2 -4
- wandb/sdk/lib/config_util.py +4 -1
- wandb/sdk/lib/console.py +1 -3
- wandb/sdk/lib/deprecate.py +3 -3
- wandb/sdk/lib/file_stream_utils.py +7 -5
- wandb/sdk/lib/filenames.py +1 -1
- wandb/sdk/lib/filesystem.py +61 -5
- wandb/sdk/lib/git.py +1 -3
- wandb/sdk/lib/import_hooks.py +4 -7
- wandb/sdk/lib/ipython.py +8 -5
- wandb/sdk/lib/lazyloader.py +1 -3
- wandb/sdk/lib/mailbox.py +14 -4
- wandb/sdk/lib/proto_util.py +10 -5
- wandb/sdk/lib/redirect.py +15 -22
- wandb/sdk/lib/reporting.py +1 -3
- wandb/sdk/lib/retry.py +4 -5
- wandb/sdk/lib/runid.py +1 -3
- wandb/sdk/lib/server.py +15 -9
- wandb/sdk/lib/sock_client.py +1 -1
- wandb/sdk/lib/sparkline.py +1 -1
- wandb/sdk/lib/wburls.py +1 -1
- wandb/sdk/service/port_file.py +1 -2
- wandb/sdk/service/service.py +36 -13
- wandb/sdk/service/service_base.py +12 -1
- wandb/sdk/verify/verify.py +5 -7
- wandb/sdk/wandb_artifacts.py +142 -177
- wandb/sdk/wandb_config.py +5 -8
- wandb/sdk/wandb_helper.py +1 -1
- wandb/sdk/wandb_init.py +24 -13
- wandb/sdk/wandb_login.py +9 -9
- wandb/sdk/wandb_manager.py +39 -4
- wandb/sdk/wandb_metric.py +2 -6
- wandb/sdk/wandb_require.py +4 -15
- wandb/sdk/wandb_require_helpers.py +1 -9
- wandb/sdk/wandb_run.py +95 -141
- wandb/sdk/wandb_save.py +1 -3
- wandb/sdk/wandb_settings.py +149 -54
- wandb/sdk/wandb_setup.py +66 -46
- wandb/sdk/wandb_summary.py +13 -10
- wandb/sdk/wandb_sweep.py +6 -7
- wandb/sdk/wandb_watch.py +1 -1
- wandb/sklearn/calculate/confusion_matrix.py +1 -1
- wandb/sklearn/calculate/learning_curve.py +1 -1
- wandb/sklearn/calculate/summary_metrics.py +1 -3
- wandb/sklearn/plot/__init__.py +1 -1
- wandb/sklearn/plot/classifier.py +27 -18
- wandb/sklearn/plot/clusterer.py +4 -5
- wandb/sklearn/plot/regressor.py +4 -4
- wandb/sklearn/plot/shared.py +2 -2
- wandb/sync/__init__.py +1 -3
- wandb/sync/sync.py +4 -5
- wandb/testing/relay.py +11 -10
- wandb/trigger.py +1 -1
- wandb/util.py +106 -81
- wandb/viz.py +4 -4
- wandb/wandb_agent.py +50 -50
- wandb/wandb_controller.py +2 -3
- wandb/wandb_run.py +1 -2
- wandb/wandb_torch.py +1 -1
- wandb/xgboost/__init__.py +1 -2
- {wandb-0.13.10.dist-info → wandb-0.14.0.dist-info}/METADATA +6 -2
- {wandb-0.13.10.dist-info → wandb-0.14.0.dist-info}/RECORD +224 -209
- {wandb-0.13.10.dist-info → wandb-0.14.0.dist-info}/WHEEL +1 -1
- wandb/sdk/launch/builder/docker.py +0 -80
- wandb/sdk/launch/builder/kaniko.py +0 -393
- wandb/sdk/launch/builder/loader.py +0 -32
- wandb/sdk/launch/runner/loader.py +0 -50
- {wandb-0.13.10.dist-info → wandb-0.14.0.dist-info}/LICENSE +0 -0
- {wandb-0.13.10.dist-info → wandb-0.14.0.dist-info}/entry_points.txt +0 -0
- {wandb-0.13.10.dist-info → wandb-0.14.0.dist-info}/top_level.txt +0 -0
wandb/sdk/data_types/_dtypes.py
CHANGED
@@ -22,9 +22,9 @@ if not _TYPES_STRIPPED:
|
|
22
22
|
|
23
23
|
|
24
24
|
class TypeRegistry:
|
25
|
-
"""
|
26
|
-
|
27
|
-
the .add call.
|
25
|
+
"""A resolver for python objects that can deserialize JSON dicts.
|
26
|
+
|
27
|
+
Additional types can be registered via the .add call.
|
28
28
|
"""
|
29
29
|
|
30
30
|
_types_by_name = None
|
@@ -137,7 +137,7 @@ def _params_obj_to_json_obj(
|
|
137
137
|
params_obj: t.Any,
|
138
138
|
artifact: t.Optional["ArtifactInCreation"] = None,
|
139
139
|
) -> t.Any:
|
140
|
-
"""Helper method"""
|
140
|
+
"""Helper method."""
|
141
141
|
if params_obj.__class__ == dict:
|
142
142
|
return {
|
143
143
|
key: _params_obj_to_json_obj(params_obj[key], artifact)
|
@@ -154,7 +154,7 @@ def _params_obj_to_json_obj(
|
|
154
154
|
def _json_obj_to_params_obj(
|
155
155
|
json_obj: t.Any, artifact: t.Optional["DownloadedArtifact"] = None
|
156
156
|
) -> t.Any:
|
157
|
-
"""Helper method"""
|
157
|
+
"""Helper method."""
|
158
158
|
if json_obj.__class__ == dict:
|
159
159
|
if "wb_type" in json_obj:
|
160
160
|
return TypeRegistry.type_from_dict(json_obj, artifact)
|
@@ -170,7 +170,8 @@ def _json_obj_to_params_obj(
|
|
170
170
|
|
171
171
|
|
172
172
|
class Type:
|
173
|
-
"""
|
173
|
+
"""The most generic type that all types subclass.
|
174
|
+
|
174
175
|
It provides simple serialization and deserialization as well as equality checks.
|
175
176
|
A name class-level property must be uniquely set by subclasses.
|
176
177
|
"""
|
@@ -201,8 +202,7 @@ class Type:
|
|
201
202
|
return self._params
|
202
203
|
|
203
204
|
def assign(self, py_obj: t.Optional[t.Any] = None) -> "Type":
|
204
|
-
"""Assign a python object to the type
|
205
|
-
the result of the assignment.
|
205
|
+
"""Assign a python object to the type.
|
206
206
|
|
207
207
|
May to be overridden by subclasses
|
208
208
|
|
@@ -211,7 +211,7 @@ class Type:
|
|
211
211
|
this type
|
212
212
|
|
213
213
|
Returns:
|
214
|
-
Type:
|
214
|
+
Type: a new type representing the result of the assignment.
|
215
215
|
"""
|
216
216
|
return self.assign_type(TypeRegistry.type_of(py_obj))
|
217
217
|
|
@@ -251,10 +251,10 @@ class Type:
|
|
251
251
|
json_dict: t.Dict[str, t.Any],
|
252
252
|
artifact: t.Optional["DownloadedArtifact"] = None,
|
253
253
|
) -> "Type":
|
254
|
-
"""Construct a new instance of the type using a JSON dictionary
|
255
|
-
the kind output by `to_json`.
|
254
|
+
"""Construct a new instance of the type using a JSON dictionary.
|
256
255
|
|
257
|
-
If overridden by subclass, ensure that
|
256
|
+
The mirror function of `to_json`. If overridden by subclass, ensure that
|
257
|
+
`to_json` is equivalently overridden.
|
258
258
|
|
259
259
|
Returns:
|
260
260
|
_Type: an instance of a subclass of the _Type class.
|
@@ -266,12 +266,13 @@ class Type:
|
|
266
266
|
return cls()
|
267
267
|
|
268
268
|
def explain(self, other: t.Any, depth=0) -> str:
|
269
|
-
"""
|
270
|
-
|
269
|
+
"""Explain why an item is not assignable to a type.
|
270
|
+
|
271
|
+
Assumes that the caller has already validated that the assignment fails.
|
271
272
|
|
272
273
|
Args:
|
273
|
-
other (any): Any object
|
274
|
-
|
274
|
+
other (any): Any object depth (int, optional): depth of the type checking.
|
275
|
+
Defaults to 0.
|
275
276
|
|
276
277
|
Returns:
|
277
278
|
str: human-readable explanation
|
@@ -307,8 +308,10 @@ class Type:
|
|
307
308
|
|
308
309
|
|
309
310
|
class InvalidType(Type):
|
310
|
-
"""
|
311
|
-
|
311
|
+
"""A disallowed type.
|
312
|
+
|
313
|
+
Assignments to a InvalidType result in a Never Type. InvalidType is basically the
|
314
|
+
invalid case.
|
312
315
|
"""
|
313
316
|
|
314
317
|
name = "invalid"
|
@@ -319,8 +322,10 @@ class InvalidType(Type):
|
|
319
322
|
|
320
323
|
|
321
324
|
class AnyType(Type):
|
322
|
-
"""
|
323
|
-
|
325
|
+
"""An object that can be any type.
|
326
|
+
|
327
|
+
Assignments to an AnyType result in the AnyType except None which results in an
|
328
|
+
InvalidType.
|
324
329
|
"""
|
325
330
|
|
326
331
|
name = "any"
|
@@ -335,8 +340,10 @@ class AnyType(Type):
|
|
335
340
|
|
336
341
|
|
337
342
|
class UnknownType(Type):
|
338
|
-
"""
|
339
|
-
|
343
|
+
"""An object with an unknown type.
|
344
|
+
|
345
|
+
All assignments to an UnknownType result in the type of the assigned object except
|
346
|
+
`None` which results in a InvalidType.
|
340
347
|
"""
|
341
348
|
|
342
349
|
name = "unknown"
|
@@ -416,7 +423,7 @@ if np:
|
|
416
423
|
|
417
424
|
|
418
425
|
class PythonObjectType(Type):
|
419
|
-
"""
|
426
|
+
"""A backup type that keeps track of the python object name."""
|
420
427
|
|
421
428
|
name = "pythonObject"
|
422
429
|
legacy_names = ["object"]
|
@@ -431,7 +438,7 @@ class PythonObjectType(Type):
|
|
431
438
|
|
432
439
|
|
433
440
|
class ConstType(Type):
|
434
|
-
"""
|
441
|
+
"""A constant value (currently only primitives supported)."""
|
435
442
|
|
436
443
|
name = "const"
|
437
444
|
types: t.ClassVar[t.List[type]] = []
|
@@ -524,7 +531,7 @@ def _union_assigner(
|
|
524
531
|
|
525
532
|
|
526
533
|
class UnionType(Type):
|
527
|
-
"""
|
534
|
+
"""An "or" of types."""
|
528
535
|
|
529
536
|
name = "union"
|
530
537
|
types: t.ClassVar[t.List[type]] = []
|
@@ -580,8 +587,9 @@ class UnionType(Type):
|
|
580
587
|
|
581
588
|
|
582
589
|
def OptionalType(dtype: ConvertableToType) -> UnionType: # noqa: N802
|
583
|
-
"""Function that mimics the Type class API for constructing an "Optional Type"
|
584
|
-
|
590
|
+
"""Function that mimics the Type class API for constructing an "Optional Type".
|
591
|
+
|
592
|
+
This is just a Union[wb_type, NoneType].
|
585
593
|
|
586
594
|
Args:
|
587
595
|
dtype (Type): type to be optional
|
@@ -593,7 +601,7 @@ def OptionalType(dtype: ConvertableToType) -> UnionType: # noqa: N802
|
|
593
601
|
|
594
602
|
|
595
603
|
class ListType(Type):
|
596
|
-
"""
|
604
|
+
"""A list of homogenous types."""
|
597
605
|
|
598
606
|
name = "list"
|
599
607
|
types: t.ClassVar[t.List[type]] = [list, tuple, set, frozenset]
|
@@ -693,7 +701,7 @@ class ListType(Type):
|
|
693
701
|
|
694
702
|
|
695
703
|
class NDArrayType(Type):
|
696
|
-
"""Represents a list of homogenous types"""
|
704
|
+
"""Represents a list of homogenous types."""
|
697
705
|
|
698
706
|
name = "ndarray"
|
699
707
|
types: t.ClassVar[t.List[type]] = [] # will manually add type if np is available
|
@@ -782,7 +790,7 @@ if np:
|
|
782
790
|
|
783
791
|
|
784
792
|
class TypedDictType(Type):
|
785
|
-
"""Represents a dictionary object where each key can have a type"""
|
793
|
+
"""Represents a dictionary object where each key can have a type."""
|
786
794
|
|
787
795
|
name = "typedDict"
|
788
796
|
legacy_names = ["dictionary"]
|
@@ -21,9 +21,7 @@ if TYPE_CHECKING: # pragma: no cover
|
|
21
21
|
|
22
22
|
|
23
23
|
class JSONMetadata(Media):
|
24
|
-
"""
|
25
|
-
JSONMetadata is a type for encoding arbitrary metadata as files.
|
26
|
-
"""
|
24
|
+
"""JSONMetadata is a type for encoding arbitrary metadata as files."""
|
27
25
|
|
28
26
|
def __init__(self, val: dict) -> None:
|
29
27
|
super().__init__()
|
@@ -31,11 +31,10 @@ def _wb_filename(
|
|
31
31
|
|
32
32
|
|
33
33
|
class Media(WBValue):
|
34
|
-
"""A WBValue
|
35
|
-
on the front end.
|
34
|
+
"""A WBValue stored as a file outside JSON that can be rendered in a media panel.
|
36
35
|
|
37
|
-
If necessary, we move or copy the file into the Run's media directory so
|
38
|
-
|
36
|
+
If necessary, we move or copy the file into the Run's media directory so that it
|
37
|
+
gets uploaded.
|
39
38
|
"""
|
40
39
|
|
41
40
|
_path: Optional[str]
|
@@ -98,9 +97,8 @@ class Media(WBValue):
|
|
98
97
|
) -> None:
|
99
98
|
"""Bind this object to a particular Run.
|
100
99
|
|
101
|
-
Calling this function is necessary so that we have somewhere specific to
|
102
|
-
|
103
|
-
refer to it.
|
100
|
+
Calling this function is necessary so that we have somewhere specific to put the
|
101
|
+
file associated with this object, from which other Runs can refer to it.
|
104
102
|
"""
|
105
103
|
assert self.file_is_set(), "bind_to_run called before _set_file"
|
106
104
|
|
@@ -146,12 +144,15 @@ class Media(WBValue):
|
|
146
144
|
_datatypes_callback(media_path)
|
147
145
|
|
148
146
|
def to_json(self, run: Union["LocalRun", "LocalArtifact"]) -> dict:
|
149
|
-
"""
|
150
|
-
|
147
|
+
"""Serialize the object into a JSON blob.
|
148
|
+
|
149
|
+
Uses run or artifact to store additional data. If `run_or_artifact` is a
|
150
|
+
wandb.Run then `self.bind_to_run()` must have been previously been called.
|
151
151
|
|
152
152
|
Args:
|
153
|
-
run_or_artifact (wandb.Run | wandb.Artifact): the Run or Artifact for which
|
154
|
-
|
153
|
+
run_or_artifact (wandb.Run | wandb.Artifact): the Run or Artifact for which
|
154
|
+
this object should be generating JSON for - this is useful to to store
|
155
|
+
additional data if needed.
|
155
156
|
|
156
157
|
Returns:
|
157
158
|
dict: JSON representation
|
@@ -254,11 +255,11 @@ class Media(WBValue):
|
|
254
255
|
def from_json(
|
255
256
|
cls: Type["Media"], json_obj: dict, source_artifact: "PublicArtifact"
|
256
257
|
) -> "Media":
|
257
|
-
"""Likely will need to override for any more complicated media objects"""
|
258
|
+
"""Likely will need to override for any more complicated media objects."""
|
258
259
|
return cls(source_artifact.get_path(json_obj["path"]).download())
|
259
260
|
|
260
261
|
def __eq__(self, other: object) -> bool:
|
261
|
-
"""Likely will need to override for any more complicated media objects"""
|
262
|
+
"""Likely will need to override for any more complicated media objects."""
|
262
263
|
return (
|
263
264
|
isinstance(other, self.__class__)
|
264
265
|
and hasattr(self, "_sha256")
|
@@ -272,11 +273,10 @@ class Media(WBValue):
|
|
272
273
|
|
273
274
|
|
274
275
|
class BatchableMedia(Media):
|
275
|
-
"""
|
276
|
-
thumbnails.
|
276
|
+
"""Media that is treated in batches.
|
277
277
|
|
278
|
-
Apart from images, we just use these batches to help
|
279
|
-
in the media directory.
|
278
|
+
E.g. images and thumbnails. Apart from images, we just use these batches to help
|
279
|
+
organize files by name in the media directory.
|
280
280
|
"""
|
281
281
|
|
282
282
|
def __init__(self) -> None:
|
@@ -54,12 +54,10 @@ class _WBValueArtifactTarget:
|
|
54
54
|
|
55
55
|
|
56
56
|
class WBValue:
|
57
|
-
"""
|
58
|
-
Abstract parent class for things that can be logged by `wandb.log()` and
|
59
|
-
visualized by wandb.
|
57
|
+
"""Typed objects that can be logged with `wandb.log()` and visualized by wandb.
|
60
58
|
|
61
|
-
The objects will be serialized as JSON and always have a _type attribute
|
62
|
-
|
59
|
+
The objects will be serialized as JSON and always have a _type attribute that
|
60
|
+
indicates how to interpret the other fields.
|
63
61
|
"""
|
64
62
|
|
65
63
|
# Class Attributes
|
@@ -76,11 +74,14 @@ class WBValue:
|
|
76
74
|
self._artifact_target = None
|
77
75
|
|
78
76
|
def to_json(self, run_or_artifact: Union["LocalRun", "LocalArtifact"]) -> dict:
|
79
|
-
"""
|
77
|
+
"""Serialize the object into a JSON blob.
|
78
|
+
|
79
|
+
Uses current run or artifact to store additional data.
|
80
80
|
|
81
81
|
Args:
|
82
|
-
run_or_artifact (wandb.Run | wandb.Artifact): the Run or Artifact for which
|
83
|
-
|
82
|
+
run_or_artifact (wandb.Run | wandb.Artifact): the Run or Artifact for which
|
83
|
+
this object should be generating JSON for - this is useful to to store
|
84
|
+
additional data if needed.
|
84
85
|
|
85
86
|
Returns:
|
86
87
|
dict: JSON representation
|
@@ -91,27 +92,29 @@ class WBValue:
|
|
91
92
|
def from_json(
|
92
93
|
cls: Type["WBValue"], json_obj: dict, source_artifact: "PublicArtifact"
|
93
94
|
) -> "WBValue":
|
94
|
-
"""Deserialize a `json_obj` into it's class representation.
|
95
|
-
|
96
|
-
the `
|
95
|
+
"""Deserialize a `json_obj` into it's class representation.
|
96
|
+
|
97
|
+
If additional resources were stored in the `run_or_artifact` artifact during the
|
98
|
+
`to_json` call, then those resources should be in the `source_artifact`.
|
97
99
|
|
98
100
|
Args:
|
99
|
-
json_obj (dict): A JSON dictionary to deserialize
|
100
|
-
|
101
|
-
|
101
|
+
json_obj (dict): A JSON dictionary to deserialize source_artifact
|
102
|
+
(wandb.Artifact): An artifact which will hold any additional
|
103
|
+
resources which were stored during the `to_json` function.
|
102
104
|
"""
|
103
105
|
raise NotImplementedError
|
104
106
|
|
105
107
|
@classmethod
|
106
108
|
def with_suffix(cls: Type["WBValue"], name: str, filetype: str = "json") -> str:
|
107
|
-
"""
|
109
|
+
"""Get the name with the appropriate suffix.
|
108
110
|
|
109
111
|
Args:
|
110
112
|
name (str): the name of the file
|
111
113
|
filetype (str, optional): the filetype to use. Defaults to "json".
|
112
114
|
|
113
115
|
Returns:
|
114
|
-
str: a filename which is suffixed with it's `_log_type` followed by the
|
116
|
+
str: a filename which is suffixed with it's `_log_type` followed by the
|
117
|
+
filetype.
|
115
118
|
"""
|
116
119
|
if cls._log_type is not None:
|
117
120
|
suffix = cls._log_type + "." + filetype
|
@@ -125,16 +128,20 @@ class WBValue:
|
|
125
128
|
def init_from_json(
|
126
129
|
json_obj: dict, source_artifact: "PublicArtifact"
|
127
130
|
) -> Optional["WBValue"]:
|
128
|
-
"""
|
129
|
-
|
130
|
-
|
131
|
-
|
131
|
+
"""Initialize a `WBValue` from a JSON blob based on the class that creatd it.
|
132
|
+
|
133
|
+
Looks through all subclasses and tries to match the json obj with the class
|
134
|
+
which created it. It will then call that subclass' `from_json` method.
|
135
|
+
Importantly, this function will set the return object's `source_artifact`
|
136
|
+
attribute to the passed in source artifact. This is critical for artifact
|
137
|
+
bookkeeping. If you choose to create a wandb.Value via it's `from_json` method,
|
138
|
+
make sure to properly set this `artifact_source` to avoid data duplication.
|
132
139
|
|
133
140
|
Args:
|
134
|
-
json_obj (dict): A JSON dictionary to deserialize. It must contain a `_type`
|
135
|
-
|
136
|
-
source_artifact (wandb.Artifact): An artifact which will hold any additional
|
137
|
-
|
141
|
+
json_obj (dict): A JSON dictionary to deserialize. It must contain a `_type`
|
142
|
+
key. This is used to lookup the correct subclass to use.
|
143
|
+
source_artifact (wandb.Artifact): An artifact which will hold any additional
|
144
|
+
resources which were stored during the `to_json` function.
|
138
145
|
|
139
146
|
Returns:
|
140
147
|
wandb.Value: a newly created instance of a subclass of wandb.Value
|
@@ -149,7 +156,7 @@ class WBValue:
|
|
149
156
|
|
150
157
|
@staticmethod
|
151
158
|
def type_mapping() -> "TypeMappingType":
|
152
|
-
"""
|
159
|
+
"""Return a map from `_log_type` to subclass. Used to lookup correct types for deserialization.
|
153
160
|
|
154
161
|
Returns:
|
155
162
|
dict: dictionary of str:class
|
@@ -175,7 +182,7 @@ class WBValue:
|
|
175
182
|
return not self.__eq__(other)
|
176
183
|
|
177
184
|
def to_data_array(self) -> List[Any]:
|
178
|
-
"""
|
185
|
+
"""Convert the object to a list of primitives representing the underlying data."""
|
179
186
|
raise NotImplementedError
|
180
187
|
|
181
188
|
def _set_artifact_source(
|