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.
Files changed (228) hide show
  1. wandb/__init__.py +2 -3
  2. wandb/apis/__init__.py +1 -3
  3. wandb/apis/importers/__init__.py +4 -0
  4. wandb/apis/importers/base.py +312 -0
  5. wandb/apis/importers/mlflow.py +113 -0
  6. wandb/apis/internal.py +29 -2
  7. wandb/apis/normalize.py +6 -5
  8. wandb/apis/public.py +163 -180
  9. wandb/apis/reports/_templates.py +6 -12
  10. wandb/apis/reports/report.py +1 -1
  11. wandb/apis/reports/runset.py +1 -3
  12. wandb/apis/reports/util.py +12 -10
  13. wandb/beta/workflows.py +57 -34
  14. wandb/catboost/__init__.py +1 -2
  15. wandb/cli/cli.py +215 -133
  16. wandb/data_types.py +63 -56
  17. wandb/docker/__init__.py +78 -16
  18. wandb/docker/auth.py +21 -22
  19. wandb/env.py +0 -1
  20. wandb/errors/__init__.py +8 -116
  21. wandb/errors/term.py +1 -1
  22. wandb/fastai/__init__.py +1 -2
  23. wandb/filesync/dir_watcher.py +8 -5
  24. wandb/filesync/step_prepare.py +76 -75
  25. wandb/filesync/step_upload.py +1 -2
  26. wandb/integration/catboost/__init__.py +1 -3
  27. wandb/integration/catboost/catboost.py +8 -14
  28. wandb/integration/fastai/__init__.py +7 -13
  29. wandb/integration/gym/__init__.py +35 -4
  30. wandb/integration/keras/__init__.py +3 -3
  31. wandb/integration/keras/callbacks/metrics_logger.py +9 -8
  32. wandb/integration/keras/callbacks/model_checkpoint.py +9 -9
  33. wandb/integration/keras/callbacks/tables_builder.py +31 -19
  34. wandb/integration/kfp/kfp_patch.py +20 -17
  35. wandb/integration/kfp/wandb_logging.py +1 -2
  36. wandb/integration/lightgbm/__init__.py +21 -19
  37. wandb/integration/prodigy/prodigy.py +6 -7
  38. wandb/integration/sacred/__init__.py +9 -12
  39. wandb/integration/sagemaker/__init__.py +1 -3
  40. wandb/integration/sagemaker/auth.py +0 -1
  41. wandb/integration/sagemaker/config.py +1 -1
  42. wandb/integration/sagemaker/resources.py +1 -1
  43. wandb/integration/sb3/sb3.py +8 -4
  44. wandb/integration/tensorboard/__init__.py +1 -3
  45. wandb/integration/tensorboard/log.py +8 -8
  46. wandb/integration/tensorboard/monkeypatch.py +11 -9
  47. wandb/integration/tensorflow/__init__.py +1 -3
  48. wandb/integration/xgboost/__init__.py +4 -6
  49. wandb/integration/yolov8/__init__.py +7 -0
  50. wandb/integration/yolov8/yolov8.py +250 -0
  51. wandb/jupyter.py +31 -35
  52. wandb/lightgbm/__init__.py +1 -2
  53. wandb/old/settings.py +2 -2
  54. wandb/plot/bar.py +1 -2
  55. wandb/plot/confusion_matrix.py +1 -3
  56. wandb/plot/histogram.py +1 -2
  57. wandb/plot/line.py +1 -2
  58. wandb/plot/line_series.py +4 -4
  59. wandb/plot/pr_curve.py +17 -20
  60. wandb/plot/roc_curve.py +1 -3
  61. wandb/plot/scatter.py +1 -2
  62. wandb/proto/v3/wandb_server_pb2.py +85 -39
  63. wandb/proto/v3/wandb_telemetry_pb2.py +10 -10
  64. wandb/proto/v4/wandb_server_pb2.py +51 -39
  65. wandb/proto/v4/wandb_telemetry_pb2.py +10 -10
  66. wandb/sdk/__init__.py +1 -3
  67. wandb/sdk/backend/backend.py +1 -1
  68. wandb/sdk/data_types/_dtypes.py +38 -30
  69. wandb/sdk/data_types/base_types/json_metadata.py +1 -3
  70. wandb/sdk/data_types/base_types/media.py +17 -17
  71. wandb/sdk/data_types/base_types/wb_value.py +33 -26
  72. wandb/sdk/data_types/helper_types/bounding_boxes_2d.py +91 -125
  73. wandb/sdk/data_types/helper_types/classes.py +1 -1
  74. wandb/sdk/data_types/helper_types/image_mask.py +12 -12
  75. wandb/sdk/data_types/histogram.py +5 -4
  76. wandb/sdk/data_types/html.py +1 -2
  77. wandb/sdk/data_types/image.py +11 -11
  78. wandb/sdk/data_types/molecule.py +3 -6
  79. wandb/sdk/data_types/object_3d.py +1 -2
  80. wandb/sdk/data_types/plotly.py +1 -2
  81. wandb/sdk/data_types/saved_model.py +10 -8
  82. wandb/sdk/data_types/video.py +1 -1
  83. wandb/sdk/integration_utils/data_logging.py +5 -5
  84. wandb/sdk/interface/artifacts.py +288 -266
  85. wandb/sdk/interface/interface.py +2 -3
  86. wandb/sdk/interface/interface_grpc.py +1 -1
  87. wandb/sdk/interface/interface_queue.py +1 -1
  88. wandb/sdk/interface/interface_relay.py +1 -1
  89. wandb/sdk/interface/interface_shared.py +1 -2
  90. wandb/sdk/interface/interface_sock.py +1 -1
  91. wandb/sdk/interface/message_future.py +1 -1
  92. wandb/sdk/interface/message_future_poll.py +1 -1
  93. wandb/sdk/interface/router.py +1 -1
  94. wandb/sdk/interface/router_queue.py +1 -1
  95. wandb/sdk/interface/router_relay.py +1 -1
  96. wandb/sdk/interface/router_sock.py +1 -1
  97. wandb/sdk/interface/summary_record.py +1 -1
  98. wandb/sdk/internal/artifacts.py +1 -1
  99. wandb/sdk/internal/datastore.py +2 -3
  100. wandb/sdk/internal/file_pusher.py +5 -3
  101. wandb/sdk/internal/file_stream.py +22 -19
  102. wandb/sdk/internal/handler.py +5 -4
  103. wandb/sdk/internal/internal.py +1 -1
  104. wandb/sdk/internal/internal_api.py +115 -55
  105. wandb/sdk/internal/job_builder.py +1 -3
  106. wandb/sdk/internal/profiler.py +1 -1
  107. wandb/sdk/internal/progress.py +4 -6
  108. wandb/sdk/internal/sample.py +1 -3
  109. wandb/sdk/internal/sender.py +28 -16
  110. wandb/sdk/internal/settings_static.py +5 -5
  111. wandb/sdk/internal/system/assets/__init__.py +1 -0
  112. wandb/sdk/internal/system/assets/cpu.py +3 -9
  113. wandb/sdk/internal/system/assets/disk.py +2 -4
  114. wandb/sdk/internal/system/assets/gpu.py +6 -18
  115. wandb/sdk/internal/system/assets/gpu_apple.py +2 -4
  116. wandb/sdk/internal/system/assets/interfaces.py +50 -22
  117. wandb/sdk/internal/system/assets/ipu.py +1 -3
  118. wandb/sdk/internal/system/assets/memory.py +7 -13
  119. wandb/sdk/internal/system/assets/network.py +4 -8
  120. wandb/sdk/internal/system/assets/open_metrics.py +283 -0
  121. wandb/sdk/internal/system/assets/tpu.py +1 -4
  122. wandb/sdk/internal/system/assets/trainium.py +26 -14
  123. wandb/sdk/internal/system/system_info.py +2 -3
  124. wandb/sdk/internal/system/system_monitor.py +52 -20
  125. wandb/sdk/internal/tb_watcher.py +12 -13
  126. wandb/sdk/launch/_project_spec.py +54 -65
  127. wandb/sdk/launch/agent/agent.py +374 -90
  128. wandb/sdk/launch/builder/abstract.py +61 -7
  129. wandb/sdk/launch/builder/build.py +81 -110
  130. wandb/sdk/launch/builder/docker_builder.py +181 -0
  131. wandb/sdk/launch/builder/kaniko_builder.py +419 -0
  132. wandb/sdk/launch/builder/noop.py +31 -12
  133. wandb/sdk/launch/builder/templates/_wandb_bootstrap.py +70 -20
  134. wandb/sdk/launch/environment/abstract.py +28 -0
  135. wandb/sdk/launch/environment/aws_environment.py +276 -0
  136. wandb/sdk/launch/environment/gcp_environment.py +271 -0
  137. wandb/sdk/launch/environment/local_environment.py +65 -0
  138. wandb/sdk/launch/github_reference.py +3 -8
  139. wandb/sdk/launch/launch.py +38 -29
  140. wandb/sdk/launch/launch_add.py +6 -8
  141. wandb/sdk/launch/loader.py +230 -0
  142. wandb/sdk/launch/registry/abstract.py +54 -0
  143. wandb/sdk/launch/registry/elastic_container_registry.py +163 -0
  144. wandb/sdk/launch/registry/google_artifact_registry.py +203 -0
  145. wandb/sdk/launch/registry/local_registry.py +62 -0
  146. wandb/sdk/launch/runner/abstract.py +1 -16
  147. wandb/sdk/launch/runner/{kubernetes.py → kubernetes_runner.py} +83 -95
  148. wandb/sdk/launch/runner/local_container.py +46 -22
  149. wandb/sdk/launch/runner/local_process.py +1 -4
  150. wandb/sdk/launch/runner/{aws.py → sagemaker_runner.py} +53 -212
  151. wandb/sdk/launch/runner/{gcp_vertex.py → vertex_runner.py} +38 -55
  152. wandb/sdk/launch/sweeps/__init__.py +3 -2
  153. wandb/sdk/launch/sweeps/scheduler.py +132 -39
  154. wandb/sdk/launch/sweeps/scheduler_sweep.py +80 -89
  155. wandb/sdk/launch/utils.py +101 -30
  156. wandb/sdk/launch/wandb_reference.py +2 -7
  157. wandb/sdk/lib/_settings_toposort_generate.py +166 -0
  158. wandb/sdk/lib/_settings_toposort_generated.py +201 -0
  159. wandb/sdk/lib/apikey.py +2 -4
  160. wandb/sdk/lib/config_util.py +4 -1
  161. wandb/sdk/lib/console.py +1 -3
  162. wandb/sdk/lib/deprecate.py +3 -3
  163. wandb/sdk/lib/file_stream_utils.py +7 -5
  164. wandb/sdk/lib/filenames.py +1 -1
  165. wandb/sdk/lib/filesystem.py +61 -5
  166. wandb/sdk/lib/git.py +1 -3
  167. wandb/sdk/lib/import_hooks.py +4 -7
  168. wandb/sdk/lib/ipython.py +8 -5
  169. wandb/sdk/lib/lazyloader.py +1 -3
  170. wandb/sdk/lib/mailbox.py +14 -4
  171. wandb/sdk/lib/proto_util.py +10 -5
  172. wandb/sdk/lib/redirect.py +15 -22
  173. wandb/sdk/lib/reporting.py +1 -3
  174. wandb/sdk/lib/retry.py +4 -5
  175. wandb/sdk/lib/runid.py +1 -3
  176. wandb/sdk/lib/server.py +15 -9
  177. wandb/sdk/lib/sock_client.py +1 -1
  178. wandb/sdk/lib/sparkline.py +1 -1
  179. wandb/sdk/lib/wburls.py +1 -1
  180. wandb/sdk/service/port_file.py +1 -2
  181. wandb/sdk/service/service.py +36 -13
  182. wandb/sdk/service/service_base.py +12 -1
  183. wandb/sdk/verify/verify.py +5 -7
  184. wandb/sdk/wandb_artifacts.py +142 -177
  185. wandb/sdk/wandb_config.py +5 -8
  186. wandb/sdk/wandb_helper.py +1 -1
  187. wandb/sdk/wandb_init.py +24 -13
  188. wandb/sdk/wandb_login.py +9 -9
  189. wandb/sdk/wandb_manager.py +39 -4
  190. wandb/sdk/wandb_metric.py +2 -6
  191. wandb/sdk/wandb_require.py +4 -15
  192. wandb/sdk/wandb_require_helpers.py +1 -9
  193. wandb/sdk/wandb_run.py +95 -141
  194. wandb/sdk/wandb_save.py +1 -3
  195. wandb/sdk/wandb_settings.py +149 -54
  196. wandb/sdk/wandb_setup.py +66 -46
  197. wandb/sdk/wandb_summary.py +13 -10
  198. wandb/sdk/wandb_sweep.py +6 -7
  199. wandb/sdk/wandb_watch.py +1 -1
  200. wandb/sklearn/calculate/confusion_matrix.py +1 -1
  201. wandb/sklearn/calculate/learning_curve.py +1 -1
  202. wandb/sklearn/calculate/summary_metrics.py +1 -3
  203. wandb/sklearn/plot/__init__.py +1 -1
  204. wandb/sklearn/plot/classifier.py +27 -18
  205. wandb/sklearn/plot/clusterer.py +4 -5
  206. wandb/sklearn/plot/regressor.py +4 -4
  207. wandb/sklearn/plot/shared.py +2 -2
  208. wandb/sync/__init__.py +1 -3
  209. wandb/sync/sync.py +4 -5
  210. wandb/testing/relay.py +11 -10
  211. wandb/trigger.py +1 -1
  212. wandb/util.py +106 -81
  213. wandb/viz.py +4 -4
  214. wandb/wandb_agent.py +50 -50
  215. wandb/wandb_controller.py +2 -3
  216. wandb/wandb_run.py +1 -2
  217. wandb/wandb_torch.py +1 -1
  218. wandb/xgboost/__init__.py +1 -2
  219. {wandb-0.13.10.dist-info → wandb-0.14.0.dist-info}/METADATA +6 -2
  220. {wandb-0.13.10.dist-info → wandb-0.14.0.dist-info}/RECORD +224 -209
  221. {wandb-0.13.10.dist-info → wandb-0.14.0.dist-info}/WHEEL +1 -1
  222. wandb/sdk/launch/builder/docker.py +0 -80
  223. wandb/sdk/launch/builder/kaniko.py +0 -393
  224. wandb/sdk/launch/builder/loader.py +0 -32
  225. wandb/sdk/launch/runner/loader.py +0 -50
  226. {wandb-0.13.10.dist-info → wandb-0.14.0.dist-info}/LICENSE +0 -0
  227. {wandb-0.13.10.dist-info → wandb-0.14.0.dist-info}/entry_points.txt +0 -0
  228. {wandb-0.13.10.dist-info → wandb-0.14.0.dist-info}/top_level.txt +0 -0
@@ -22,9 +22,9 @@ if not _TYPES_STRIPPED:
22
22
 
23
23
 
24
24
  class TypeRegistry:
25
- """The TypeRegistry resolves python objects to Types as well as
26
- deserializes JSON dicts. Additional types can be registered via
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
- """This is the most generic type which all types are subclasses.
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, returning a new type representing
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: an instance of a subclass of the Type class.
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 equivalent to
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 `to_json` is equivalently overridden.
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
- """Explains why an item is not assignable to a type. Assumes that
270
- the caller has already validated that the assignment fails.
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
- depth (int, optional): depth of the type checking. Defaults to 0.
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
- """all assignments to a InvalidType result in a Never Type.
311
- InvalidType is basically the invalid case
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
- """all assignments to an AnyType result in the
323
- AnyType except None which will be InvalidType
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
- """all assignments to an UnknownType result in the type of the assigned object
339
- except none which will result in a InvalidType
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
- """Serves as a backup type by keeping track of the python object name"""
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
- """Represents a constant value (currently only primitives supported)"""
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
- """Represents an "or" of types"""
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
- which is just a Union[wb_type, NoneType]
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
- """Represents a list of homogenous types"""
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 that we store as a file outside JSON and show in a media panel
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
- that it gets uploaded.
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
- put the file associated with this object, from which other Runs can
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
- """Serializes the object into a JSON blob, using a run or artifact to store additional data. If `run_or_artifact`
150
- is a wandb.Run then `self.bind_to_run()` must have been previously been called.
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 this object should be generating
154
- JSON for - this is useful to to store additional data if needed.
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
- """Parent class for Media we treat specially in batches, like images and
276
- thumbnails.
276
+ """Media that is treated in batches.
277
277
 
278
- Apart from images, we just use these batches to help organize files by name
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
- that indicates how to interpret the other fields.
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
- """Serializes the object into a JSON blob, using a run or artifact to store additional data.
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 this object should be generating
83
- JSON for - this is useful to to store additional data if needed.
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. If additional resources were stored in the
95
- `run_or_artifact` artifact during the `to_json` call, then those resources are expected to be in
96
- the `source_artifact`.
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
- source_artifact (wandb.Artifact): An artifact which will hold any additional resources which were stored
101
- during the `to_json` function.
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
- """Helper function to return the name with suffix added if not already
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 filetype
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
- """Looks through all subclasses and tries to match the json obj with the class which created it. It will then
129
- call that subclass' `from_json` method. Importantly, this function will set the return object's `source_artifact`
130
- attribute to the passed in source artifact. This is critical for artifact bookkeeping. If you choose to create
131
- a wandb.Value via it's `from_json` method, make sure to properly set this `artifact_source` to avoid data duplication.
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` key. The value of
135
- this key is used to lookup the correct subclass to use.
136
- source_artifact (wandb.Artifact): An artifact which will hold any additional resources which were stored
137
- during the `to_json` function.
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
- """Returns a map from `_log_type` to subclass. Used to lookup correct types for deserialization.
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
- """Converts the object to a list of primitives representing the underlying data"""
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(