wandb 0.15.4__py3-none-any.whl → 0.15.5__py3-none-any.whl

Sign up to get free protection for your applications and to get access to all the features.
Files changed (102) hide show
  1. wandb/__init__.py +1 -1
  2. wandb/analytics/sentry.py +1 -0
  3. wandb/apis/internal.py +3 -0
  4. wandb/apis/public.py +18 -20
  5. wandb/beta/workflows.py +5 -6
  6. wandb/cli/cli.py +27 -27
  7. wandb/data_types.py +2 -0
  8. wandb/integration/langchain/wandb_tracer.py +16 -179
  9. wandb/integration/sagemaker/config.py +2 -2
  10. wandb/integration/tensorboard/log.py +4 -4
  11. wandb/proto/v3/wandb_telemetry_pb2.py +10 -10
  12. wandb/proto/v4/wandb_telemetry_pb2.py +10 -10
  13. wandb/proto/wandb_deprecated.py +3 -1
  14. wandb/sdk/__init__.py +1 -4
  15. wandb/sdk/artifacts/__init__.py +0 -14
  16. wandb/sdk/artifacts/artifact.py +1757 -277
  17. wandb/sdk/artifacts/artifact_manifest_entry.py +26 -6
  18. wandb/sdk/artifacts/artifact_state.py +10 -0
  19. wandb/sdk/artifacts/artifacts_cache.py +7 -8
  20. wandb/sdk/artifacts/exceptions.py +4 -4
  21. wandb/sdk/artifacts/storage_handler.py +2 -2
  22. wandb/sdk/artifacts/storage_handlers/azure_handler.py +16 -6
  23. wandb/sdk/artifacts/storage_handlers/gcs_handler.py +2 -2
  24. wandb/sdk/artifacts/storage_handlers/http_handler.py +2 -2
  25. wandb/sdk/artifacts/storage_handlers/local_file_handler.py +2 -2
  26. wandb/sdk/artifacts/storage_handlers/multi_handler.py +2 -2
  27. wandb/sdk/artifacts/storage_handlers/s3_handler.py +35 -32
  28. wandb/sdk/artifacts/storage_handlers/tracking_handler.py +2 -2
  29. wandb/sdk/artifacts/storage_handlers/wb_artifact_handler.py +5 -9
  30. wandb/sdk/artifacts/storage_handlers/wb_local_artifact_handler.py +2 -2
  31. wandb/sdk/artifacts/storage_policies/s3_bucket_policy.py +2 -2
  32. wandb/sdk/artifacts/storage_policies/wandb_storage_policy.py +24 -16
  33. wandb/sdk/artifacts/storage_policy.py +3 -3
  34. wandb/sdk/data_types/_dtypes.py +7 -12
  35. wandb/sdk/data_types/base_types/json_metadata.py +2 -2
  36. wandb/sdk/data_types/base_types/media.py +5 -6
  37. wandb/sdk/data_types/base_types/wb_value.py +12 -13
  38. wandb/sdk/data_types/helper_types/bounding_boxes_2d.py +4 -5
  39. wandb/sdk/data_types/helper_types/classes.py +5 -8
  40. wandb/sdk/data_types/helper_types/image_mask.py +4 -5
  41. wandb/sdk/data_types/histogram.py +3 -3
  42. wandb/sdk/data_types/html.py +3 -4
  43. wandb/sdk/data_types/image.py +4 -5
  44. wandb/sdk/data_types/molecule.py +2 -2
  45. wandb/sdk/data_types/object_3d.py +3 -3
  46. wandb/sdk/data_types/plotly.py +2 -2
  47. wandb/sdk/data_types/saved_model.py +7 -8
  48. wandb/sdk/data_types/trace_tree.py +4 -4
  49. wandb/sdk/data_types/video.py +4 -4
  50. wandb/sdk/interface/interface.py +8 -10
  51. wandb/sdk/internal/file_stream.py +2 -3
  52. wandb/sdk/internal/internal_api.py +99 -4
  53. wandb/sdk/internal/job_builder.py +15 -7
  54. wandb/sdk/internal/sender.py +4 -0
  55. wandb/sdk/internal/settings_static.py +1 -0
  56. wandb/sdk/launch/_project_spec.py +9 -7
  57. wandb/sdk/launch/agent/agent.py +115 -58
  58. wandb/sdk/launch/agent/job_status_tracker.py +34 -0
  59. wandb/sdk/launch/agent/run_queue_item_file_saver.py +45 -0
  60. wandb/sdk/launch/builder/abstract.py +5 -1
  61. wandb/sdk/launch/builder/build.py +16 -10
  62. wandb/sdk/launch/builder/docker_builder.py +9 -2
  63. wandb/sdk/launch/builder/kaniko_builder.py +108 -22
  64. wandb/sdk/launch/builder/noop.py +3 -1
  65. wandb/sdk/launch/environment/aws_environment.py +2 -1
  66. wandb/sdk/launch/environment/azure_environment.py +124 -0
  67. wandb/sdk/launch/github_reference.py +30 -18
  68. wandb/sdk/launch/launch.py +1 -1
  69. wandb/sdk/launch/loader.py +15 -0
  70. wandb/sdk/launch/registry/azure_container_registry.py +132 -0
  71. wandb/sdk/launch/registry/elastic_container_registry.py +38 -4
  72. wandb/sdk/launch/registry/google_artifact_registry.py +46 -7
  73. wandb/sdk/launch/runner/abstract.py +19 -3
  74. wandb/sdk/launch/runner/kubernetes_runner.py +111 -47
  75. wandb/sdk/launch/runner/local_container.py +101 -48
  76. wandb/sdk/launch/runner/sagemaker_runner.py +59 -9
  77. wandb/sdk/launch/runner/vertex_runner.py +8 -4
  78. wandb/sdk/launch/sweeps/scheduler.py +102 -27
  79. wandb/sdk/launch/sweeps/utils.py +21 -0
  80. wandb/sdk/launch/utils.py +19 -7
  81. wandb/sdk/lib/_settings_toposort_generated.py +3 -0
  82. wandb/sdk/service/server.py +22 -9
  83. wandb/sdk/service/service.py +27 -8
  84. wandb/sdk/verify/verify.py +6 -9
  85. wandb/sdk/wandb_config.py +2 -4
  86. wandb/sdk/wandb_init.py +2 -0
  87. wandb/sdk/wandb_require.py +7 -0
  88. wandb/sdk/wandb_run.py +32 -35
  89. wandb/sdk/wandb_settings.py +10 -3
  90. wandb/testing/relay.py +15 -2
  91. wandb/util.py +55 -23
  92. {wandb-0.15.4.dist-info → wandb-0.15.5.dist-info}/METADATA +11 -8
  93. {wandb-0.15.4.dist-info → wandb-0.15.5.dist-info}/RECORD +97 -97
  94. wandb/integration/langchain/util.py +0 -191
  95. wandb/sdk/artifacts/invalid_artifact.py +0 -23
  96. wandb/sdk/artifacts/lazy_artifact.py +0 -162
  97. wandb/sdk/artifacts/local_artifact.py +0 -719
  98. wandb/sdk/artifacts/public_artifact.py +0 -1188
  99. {wandb-0.15.4.dist-info → wandb-0.15.5.dist-info}/LICENSE +0 -0
  100. {wandb-0.15.4.dist-info → wandb-0.15.5.dist-info}/WHEEL +0 -0
  101. {wandb-0.15.4.dist-info → wandb-0.15.5.dist-info}/entry_points.txt +0 -0
  102. {wandb-0.15.4.dist-info → wandb-0.15.5.dist-info}/top_level.txt +0 -0
@@ -13,8 +13,7 @@ from wandb.util import (
13
13
  np = get_module("numpy") # intentionally not required
14
14
 
15
15
  if t.TYPE_CHECKING:
16
- from wandb.sdk.artifacts.local_artifact import Artifact as ArtifactInCreation
17
- from wandb.sdk.artifacts.public_artifact import Artifact as DownloadedArtifact
16
+ from wandb.sdk.artifacts.artifact import Artifact
18
17
 
19
18
  _TYPES_STRIPPED = not (sys.version_info.major == 3 and sys.version_info.minor >= 6)
20
19
  if not _TYPES_STRIPPED:
@@ -77,7 +76,7 @@ class TypeRegistry:
77
76
 
78
77
  @staticmethod
79
78
  def type_from_dict(
80
- json_dict: t.Dict[str, t.Any], artifact: t.Optional["DownloadedArtifact"] = None
79
+ json_dict: t.Dict[str, t.Any], artifact: t.Optional["Artifact"] = None
81
80
  ) -> "Type":
82
81
  wb_type = json_dict.get("wb_type")
83
82
  if wb_type is None:
@@ -135,7 +134,7 @@ class TypeRegistry:
135
134
 
136
135
  def _params_obj_to_json_obj(
137
136
  params_obj: t.Any,
138
- artifact: t.Optional["ArtifactInCreation"] = None,
137
+ artifact: t.Optional["Artifact"] = None,
139
138
  ) -> t.Any:
140
139
  """Helper method."""
141
140
  if params_obj.__class__ == dict:
@@ -152,7 +151,7 @@ def _params_obj_to_json_obj(
152
151
 
153
152
 
154
153
  def _json_obj_to_params_obj(
155
- json_obj: t.Any, artifact: t.Optional["DownloadedArtifact"] = None
154
+ json_obj: t.Any, artifact: t.Optional["Artifact"] = None
156
155
  ) -> t.Any:
157
156
  """Helper method."""
158
157
  if json_obj.__class__ == dict:
@@ -222,9 +221,7 @@ class Type:
222
221
  else:
223
222
  return InvalidType()
224
223
 
225
- def to_json(
226
- self, artifact: t.Optional["ArtifactInCreation"] = None
227
- ) -> t.Dict[str, t.Any]:
224
+ def to_json(self, artifact: t.Optional["Artifact"] = None) -> t.Dict[str, t.Any]:
228
225
  """Generate a jsonable dictionary serialization the type.
229
226
 
230
227
  If overridden by subclass, ensure that `from_json` is equivalently overridden.
@@ -249,7 +246,7 @@ class Type:
249
246
  def from_json(
250
247
  cls,
251
248
  json_dict: t.Dict[str, t.Any],
252
- artifact: t.Optional["DownloadedArtifact"] = None,
249
+ artifact: t.Optional["Artifact"] = None,
253
250
  ) -> "Type":
254
251
  """Construct a new instance of the type using a JSON dictionary.
255
252
 
@@ -756,9 +753,7 @@ class NDArrayType(Type):
756
753
 
757
754
  return InvalidType()
758
755
 
759
- def to_json(
760
- self, artifact: t.Optional["ArtifactInCreation"] = None
761
- ) -> t.Dict[str, t.Any]:
756
+ def to_json(self, artifact: t.Optional["Artifact"] = None) -> t.Dict[str, t.Any]:
762
757
  # custom override to support serialization path outside of params internal dict
763
758
  res = {
764
759
  "wb_type": self.name,
@@ -9,7 +9,7 @@ from .._private import MEDIA_TMP
9
9
  from .media import Media
10
10
 
11
11
  if TYPE_CHECKING: # pragma: no cover
12
- from wandb.sdk.artifacts.local_artifact import Artifact as LocalArtifact
12
+ from wandb.sdk.artifacts.artifact import Artifact
13
13
 
14
14
  from ...wandb_run import Run as LocalRun
15
15
 
@@ -40,7 +40,7 @@ class JSONMetadata(Media):
40
40
  def get_media_subdir(cls: Type["JSONMetadata"]) -> str:
41
41
  return os.path.join("media", "metadata", cls.type_name())
42
42
 
43
- def to_json(self, run_or_artifact: Union["LocalRun", "LocalArtifact"]) -> dict:
43
+ def to_json(self, run_or_artifact: Union["LocalRun", "Artifact"]) -> dict:
44
44
  json_dict = super().to_json(run_or_artifact)
45
45
  json_dict["_type"] = self.type_name()
46
46
 
@@ -14,10 +14,9 @@ from wandb.sdk.lib.paths import LogicalPath
14
14
  from .wb_value import WBValue
15
15
 
16
16
  if TYPE_CHECKING: # pragma: no cover
17
- import numpy as np # type: ignore
17
+ import numpy as np
18
18
 
19
- from wandb.sdk.artifacts.local_artifact import Artifact as LocalArtifact
20
- from wandb.sdk.artifacts.public_artifact import Artifact as PublicArtifact
19
+ from wandb.sdk.artifacts.artifact import Artifact
21
20
 
22
21
  from ...wandb_run import Run as LocalRun
23
22
 
@@ -144,7 +143,7 @@ class Media(WBValue):
144
143
  self._path = new_path
145
144
  _datatypes_callback(media_path)
146
145
 
147
- def to_json(self, run: Union["LocalRun", "LocalArtifact"]) -> dict:
146
+ def to_json(self, run: Union["LocalRun", "Artifact"]) -> dict:
148
147
  """Serialize the object into a JSON blob.
149
148
 
150
149
  Uses run or artifact to store additional data. If `run_or_artifact` is a
@@ -254,7 +253,7 @@ class Media(WBValue):
254
253
 
255
254
  @classmethod
256
255
  def from_json(
257
- cls: Type["Media"], json_obj: dict, source_artifact: "PublicArtifact"
256
+ cls: Type["Media"], json_obj: dict, source_artifact: "Artifact"
258
257
  ) -> "Media":
259
258
  """Likely will need to override for any more complicated media objects."""
260
259
  return cls(source_artifact.get_path(json_obj["path"]).download())
@@ -316,4 +315,4 @@ def _numpy_arrays_to_lists(
316
315
  # Protects against logging non serializable objects
317
316
  elif isinstance(payload, Media):
318
317
  return str(payload.__class__.__name__)
319
- return payload
318
+ return payload # type: ignore
@@ -3,8 +3,7 @@ from typing import TYPE_CHECKING, Any, ClassVar, Dict, List, Optional, Type, Uni
3
3
  from wandb import util
4
4
 
5
5
  if TYPE_CHECKING: # pragma: no cover
6
- from wandb.sdk.artifacts.local_artifact import Artifact as LocalArtifact
7
- from wandb.sdk.artifacts.public_artifact import Artifact as PublicArtifact
6
+ from wandb.sdk.artifacts.artifact import Artifact
8
7
 
9
8
  from ...wandb_run import Run as LocalRun
10
9
 
@@ -36,19 +35,19 @@ def _server_accepts_client_ids() -> bool:
36
35
 
37
36
 
38
37
  class _WBValueArtifactSource:
39
- artifact: "PublicArtifact"
38
+ artifact: "Artifact"
40
39
  name: Optional[str]
41
40
 
42
- def __init__(self, artifact: "PublicArtifact", name: Optional[str] = None) -> None:
41
+ def __init__(self, artifact: "Artifact", name: Optional[str] = None) -> None:
43
42
  self.artifact = artifact
44
43
  self.name = name
45
44
 
46
45
 
47
46
  class _WBValueArtifactTarget:
48
- artifact: "LocalArtifact"
47
+ artifact: "Artifact"
49
48
  name: Optional[str]
50
49
 
51
- def __init__(self, artifact: "LocalArtifact", name: Optional[str] = None) -> None:
50
+ def __init__(self, artifact: "Artifact", name: Optional[str] = None) -> None:
52
51
  self.artifact = artifact
53
52
  self.name = name
54
53
 
@@ -73,7 +72,7 @@ class WBValue:
73
72
  self._artifact_source = None
74
73
  self._artifact_target = None
75
74
 
76
- def to_json(self, run_or_artifact: Union["LocalRun", "LocalArtifact"]) -> dict:
75
+ def to_json(self, run_or_artifact: Union["LocalRun", "Artifact"]) -> dict:
77
76
  """Serialize the object into a JSON blob.
78
77
 
79
78
  Uses current run or artifact to store additional data.
@@ -90,7 +89,7 @@ class WBValue:
90
89
 
91
90
  @classmethod
92
91
  def from_json(
93
- cls: Type["WBValue"], json_obj: dict, source_artifact: "PublicArtifact"
92
+ cls: Type["WBValue"], json_obj: dict, source_artifact: "Artifact"
94
93
  ) -> "WBValue":
95
94
  """Deserialize a `json_obj` into it's class representation.
96
95
 
@@ -126,7 +125,7 @@ class WBValue:
126
125
 
127
126
  @staticmethod
128
127
  def init_from_json(
129
- json_obj: dict, source_artifact: "PublicArtifact"
128
+ json_obj: dict, source_artifact: "Artifact"
130
129
  ) -> Optional["WBValue"]:
131
130
  """Initialize a `WBValue` from a JSON blob based on the class that creatd it.
132
131
 
@@ -186,7 +185,7 @@ class WBValue:
186
185
  raise NotImplementedError
187
186
 
188
187
  def _set_artifact_source(
189
- self, artifact: "PublicArtifact", name: Optional[str] = None
188
+ self, artifact: "Artifact", name: Optional[str] = None
190
189
  ) -> None:
191
190
  assert (
192
191
  self._artifact_source is None
@@ -196,7 +195,7 @@ class WBValue:
196
195
  self._artifact_source = _WBValueArtifactSource(artifact, name)
197
196
 
198
197
  def _set_artifact_target(
199
- self, artifact: "LocalArtifact", name: Optional[str] = None
198
+ self, artifact: "Artifact", name: Optional[str] = None
200
199
  ) -> None:
201
200
  assert (
202
201
  self._artifact_target is None
@@ -232,7 +231,7 @@ class WBValue:
232
231
  elif (
233
232
  self._artifact_target
234
233
  and self._artifact_target.name
235
- and self._artifact_target.artifact._logged_artifact is not None
234
+ and self._artifact_target.artifact._is_draft_save_started()
236
235
  and not util._is_offline()
237
236
  and not _server_accepts_client_ids()
238
237
  ):
@@ -263,7 +262,7 @@ class WBValue:
263
262
  elif (
264
263
  self._artifact_target
265
264
  and self._artifact_target.name
266
- and self._artifact_target.artifact._logged_artifact is not None
265
+ and self._artifact_target.artifact._is_draft_save_started()
267
266
  and not util._is_offline()
268
267
  and not _server_accepts_client_ids()
269
268
  ):
@@ -8,8 +8,7 @@ from wandb.util import has_num
8
8
  from ..base_types.json_metadata import JSONMetadata
9
9
 
10
10
  if TYPE_CHECKING: # pragma: no cover
11
- from wandb.sdk.artifacts.local_artifact import Artifact as LocalArtifact
12
- from wandb.sdk.artifacts.public_artifact import Artifact as PublicArtifact
11
+ from wandb.sdk.artifacts.artifact import Artifact
13
12
 
14
13
  from ...wandb_run import Run as LocalRun
15
14
 
@@ -274,7 +273,7 @@ class BoundingBoxes2D(JSONMetadata):
274
273
  raise TypeError("A box's caption must be a string")
275
274
  return True
276
275
 
277
- def to_json(self, run_or_artifact: Union["LocalRun", "LocalArtifact"]) -> dict:
276
+ def to_json(self, run_or_artifact: Union["LocalRun", "Artifact"]) -> dict:
278
277
  if isinstance(run_or_artifact, wandb.wandb_sdk.wandb_run.Run):
279
278
  return super().to_json(run_or_artifact)
280
279
  elif isinstance(run_or_artifact, wandb.Artifact):
@@ -283,10 +282,10 @@ class BoundingBoxes2D(JSONMetadata):
283
282
  # an object with a _type key. Will need to push this change to the UI first to ensure backwards compat
284
283
  return self._val
285
284
  else:
286
- raise ValueError("to_json accepts wandb_run.Run or wandb_artifact.Artifact")
285
+ raise ValueError("to_json accepts wandb_run.Run or wandb.Artifact")
287
286
 
288
287
  @classmethod
289
288
  def from_json(
290
- cls: Type["BoundingBoxes2D"], json_obj: dict, source_artifact: "PublicArtifact"
289
+ cls: Type["BoundingBoxes2D"], json_obj: dict, source_artifact: "Artifact"
291
290
  ) -> "BoundingBoxes2D":
292
291
  return cls({"box_data": json_obj}, "")
@@ -5,8 +5,7 @@ from .. import _dtypes
5
5
  from ..base_types.media import Media
6
6
 
7
7
  if TYPE_CHECKING: # pragma: no cover
8
- from wandb.sdk.artifacts.local_artifact import Artifact as LocalArtifact
9
- from wandb.sdk.artifacts.public_artifact import Artifact as PublicArtifact
8
+ from wandb.sdk.artifacts.artifact import Artifact
10
9
 
11
10
  from ...wandb_run import Run as LocalRun
12
11
 
@@ -31,13 +30,11 @@ class Classes(Media):
31
30
  def from_json(
32
31
  cls: Type["Classes"],
33
32
  json_obj: dict,
34
- source_artifact: Optional["PublicArtifact"],
33
+ source_artifact: Optional["Artifact"],
35
34
  ) -> "Classes":
36
35
  return cls(json_obj.get("class_set")) # type: ignore
37
36
 
38
- def to_json(
39
- self, run_or_artifact: Optional[Union["LocalRun", "LocalArtifact"]]
40
- ) -> dict:
37
+ def to_json(self, run_or_artifact: Optional[Union["LocalRun", "Artifact"]]) -> dict:
41
38
  json_obj = {}
42
39
  # This is a bit of a hack to allow _ClassesIdType to
43
40
  # be able to operate fully without an artifact in play.
@@ -116,7 +113,7 @@ class _ClassesIdType(_dtypes.Type):
116
113
  def from_obj(cls, py_obj: Optional[Any] = None) -> "_dtypes.Type":
117
114
  return cls(py_obj)
118
115
 
119
- def to_json(self, artifact: Optional["LocalArtifact"] = None) -> Dict[str, Any]:
116
+ def to_json(self, artifact: Optional["Artifact"] = None) -> Dict[str, Any]:
120
117
  cl_dict = super().to_json(artifact)
121
118
  # TODO (tss): Refactor this block with the similar one in wandb.Image.
122
119
  # This is a bit of a smell that the classes object does not follow
@@ -137,7 +134,7 @@ class _ClassesIdType(_dtypes.Type):
137
134
  def from_json(
138
135
  cls,
139
136
  json_dict: Dict[str, Any],
140
- artifact: Optional["PublicArtifact"] = None,
137
+ artifact: Optional["Artifact"] = None,
141
138
  ) -> "_dtypes.Type":
142
139
  classes_obj = None
143
140
  if (
@@ -10,8 +10,7 @@ from .._private import MEDIA_TMP
10
10
  from ..base_types.media import Media
11
11
 
12
12
  if TYPE_CHECKING: # pragma: no cover
13
- from wandb.sdk.artifacts.local_artifact import Artifact as LocalArtifact
14
- from wandb.sdk.artifacts.public_artifact import Artifact as PublicArtifact
13
+ from wandb.sdk.artifacts.artifact import Artifact
15
14
 
16
15
  from ...wandb_run import Run as LocalRun
17
16
 
@@ -184,14 +183,14 @@ class ImageMask(Media):
184
183
 
185
184
  @classmethod
186
185
  def from_json(
187
- cls: Type["ImageMask"], json_obj: dict, source_artifact: "PublicArtifact"
186
+ cls: Type["ImageMask"], json_obj: dict, source_artifact: "Artifact"
188
187
  ) -> "ImageMask":
189
188
  return cls(
190
189
  {"path": source_artifact.get_path(json_obj["path"]).download()},
191
190
  key="",
192
191
  )
193
192
 
194
- def to_json(self, run_or_artifact: Union["LocalRun", "LocalArtifact"]) -> dict:
193
+ def to_json(self, run_or_artifact: Union["LocalRun", "Artifact"]) -> dict:
195
194
  json_dict = super().to_json(run_or_artifact)
196
195
 
197
196
  if isinstance(run_or_artifact, wandb.wandb_sdk.wandb_run.Run):
@@ -201,7 +200,7 @@ class ImageMask(Media):
201
200
  # Nothing special to add (used to add "digest", but no longer used.)
202
201
  return json_dict
203
202
  else:
204
- raise ValueError("to_json accepts wandb_run.Run or wandb_artifact.Artifact")
203
+ raise ValueError("to_json accepts wandb_run.Run or wandb.Artifact")
205
204
 
206
205
  @classmethod
207
206
  def type_name(cls: Type["ImageMask"]) -> str:
@@ -6,9 +6,9 @@ from wandb import util
6
6
  from .base_types.wb_value import WBValue
7
7
 
8
8
  if TYPE_CHECKING: # pragma: no cover
9
- import numpy as np # type: ignore
9
+ import numpy as np
10
10
 
11
- from wandb.sdk.artifacts.local_artifact import Artifact as LocalArtifact
11
+ from wandb.sdk.artifacts.artifact import Artifact
12
12
 
13
13
  from ..wandb_run import Run as LocalRun
14
14
 
@@ -84,7 +84,7 @@ class Histogram(WBValue):
84
84
  if len(self.histogram) + 1 != len(self.bins):
85
85
  raise ValueError("len(bins) must be len(histogram) + 1")
86
86
 
87
- def to_json(self, run: Optional[Union["LocalRun", "LocalArtifact"]] = None) -> dict:
87
+ def to_json(self, run: Optional[Union["LocalRun", "Artifact"]] = None) -> dict:
88
88
  return {"_type": self._log_type, "values": self.histogram, "bins": self.bins}
89
89
 
90
90
  def __sizeof__(self) -> int:
@@ -10,8 +10,7 @@ from .base_types.media import BatchableMedia
10
10
  if TYPE_CHECKING: # pragma: no cover
11
11
  from typing import TextIO
12
12
 
13
- from wandb.sdk.artifacts.local_artifact import Artifact as LocalArtifact
14
- from wandb.sdk.artifacts.public_artifact import Artifact as PublicArtifact
13
+ from wandb.sdk.artifacts.artifact import Artifact
15
14
 
16
15
  from ..wandb_run import Run as LocalRun
17
16
 
@@ -78,14 +77,14 @@ class Html(BatchableMedia):
78
77
  def get_media_subdir(cls: Type["Html"]) -> str:
79
78
  return os.path.join("media", "html")
80
79
 
81
- def to_json(self, run_or_artifact: Union["LocalRun", "LocalArtifact"]) -> dict:
80
+ def to_json(self, run_or_artifact: Union["LocalRun", "Artifact"]) -> dict:
82
81
  json_dict = super().to_json(run_or_artifact)
83
82
  json_dict["_type"] = self._log_type
84
83
  return json_dict
85
84
 
86
85
  @classmethod
87
86
  def from_json(
88
- cls: Type["Html"], json_obj: dict, source_artifact: "PublicArtifact"
87
+ cls: Type["Html"], json_obj: dict, source_artifact: "Artifact"
89
88
  ) -> "Html":
90
89
  return cls(source_artifact.get_path(json_obj["path"]).download(), inject=False)
91
90
 
@@ -18,12 +18,11 @@ from .helper_types.image_mask import ImageMask
18
18
 
19
19
  if TYPE_CHECKING: # pragma: no cover
20
20
  import matplotlib # type: ignore
21
- import numpy as np # type: ignore
21
+ import numpy as np
22
22
  import torch # type: ignore
23
23
  from PIL.Image import Image as PILImage
24
24
 
25
- from wandb.sdk.artifacts.local_artifact import Artifact as LocalArtifact
26
- from wandb.sdk.artifacts.public_artifact import Artifact as PublicArtifact
25
+ from wandb.sdk.artifacts.artifact import Artifact
27
26
 
28
27
  from ..wandb_run import Run as LocalRun
29
28
 
@@ -309,7 +308,7 @@ class Image(BatchableMedia):
309
308
 
310
309
  @classmethod
311
310
  def from_json(
312
- cls: Type["Image"], json_obj: dict, source_artifact: "PublicArtifact"
311
+ cls: Type["Image"], json_obj: dict, source_artifact: "Artifact"
313
312
  ) -> "Image":
314
313
  classes: Optional[Classes] = None
315
314
  if json_obj.get("classes") is not None:
@@ -388,7 +387,7 @@ class Image(BatchableMedia):
388
387
  run, key, step, id_, ignore_copy_err=ignore_copy_err
389
388
  )
390
389
 
391
- def to_json(self, run_or_artifact: Union["LocalRun", "LocalArtifact"]) -> dict:
390
+ def to_json(self, run_or_artifact: Union["LocalRun", "Artifact"]) -> dict:
392
391
  json_dict = super().to_json(run_or_artifact)
393
392
  json_dict["_type"] = Image._log_type
394
393
  json_dict["format"] = self.format
@@ -15,7 +15,7 @@ if TYPE_CHECKING: # pragma: no cover
15
15
 
16
16
  import rdkit.Chem # type: ignore
17
17
 
18
- from wandb.sdk.artifacts.local_artifact import Artifact as LocalArtifact
18
+ from wandb.sdk.artifacts.artifact import Artifact
19
19
 
20
20
  from ..wandb_run import Run as LocalRun
21
21
 
@@ -205,7 +205,7 @@ class Molecule(BatchableMedia):
205
205
  def get_media_subdir(cls: Type["Molecule"]) -> str:
206
206
  return os.path.join("media", "molecule")
207
207
 
208
- def to_json(self, run_or_artifact: Union["LocalRun", "LocalArtifact"]) -> dict:
208
+ def to_json(self, run_or_artifact: Union["LocalRun", "Artifact"]) -> dict:
209
209
  json_dict = super().to_json(run_or_artifact)
210
210
  json_dict["_type"] = self._log_type
211
211
  if self._caption:
@@ -30,9 +30,9 @@ from ._private import MEDIA_TMP
30
30
  from .base_types.media import BatchableMedia
31
31
 
32
32
  if TYPE_CHECKING: # pragma: no cover
33
- import numpy as np # type: ignore
33
+ import numpy as np
34
34
 
35
- from wandb.sdk.artifacts.local_artifact import Artifact as LocalArtifact
35
+ from wandb.sdk.artifacts.artifact import Artifact
36
36
 
37
37
  from ..wandb_run import Run as LocalRun
38
38
 
@@ -312,7 +312,7 @@ class Object3D(BatchableMedia):
312
312
  def get_media_subdir(cls: Type["Object3D"]) -> str:
313
313
  return os.path.join("media", "object3D")
314
314
 
315
- def to_json(self, run_or_artifact: Union["LocalRun", "LocalArtifact"]) -> dict:
315
+ def to_json(self, run_or_artifact: Union["LocalRun", "Artifact"]) -> dict:
316
316
  json_dict = super().to_json(run_or_artifact)
317
317
  json_dict["_type"] = Object3D._log_type
318
318
 
@@ -15,7 +15,7 @@ if TYPE_CHECKING: # pragma: no cover
15
15
  import pandas as pd
16
16
  import plotly # type: ignore
17
17
 
18
- from wandb.sdk.artifacts.local_artifact import Artifact as LocalArtifact
18
+ from wandb.sdk.artifacts.artifact import Artifact
19
19
 
20
20
  from ..wandb_run import Run as LocalRun
21
21
 
@@ -76,7 +76,7 @@ class Plotly(Media):
76
76
  def get_media_subdir(cls: Type["Plotly"]) -> str:
77
77
  return os.path.join("media", "plotly")
78
78
 
79
- def to_json(self, run_or_artifact: Union["LocalRun", "LocalArtifact"]) -> dict:
79
+ def to_json(self, run_or_artifact: Union["LocalRun", "Artifact"]) -> dict:
80
80
  json_dict = super().to_json(run_or_artifact)
81
81
  json_dict["_type"] = self._log_type
82
82
  return json_dict
@@ -29,8 +29,7 @@ if TYPE_CHECKING: # pragma: no cover
29
29
  import tensorflow # type: ignore
30
30
  import torch # type: ignore
31
31
 
32
- from wandb.sdk.artifacts.local_artifact import Artifact as LocalArtifact
33
- from wandb.sdk.artifacts.public_artifact import Artifact as PublicArtifact
32
+ from wandb.sdk.artifacts.artifact import Artifact
34
33
 
35
34
  from ..wandb_run import Run as LocalRun
36
35
 
@@ -39,7 +38,7 @@ DEBUG_MODE = False
39
38
 
40
39
 
41
40
  def _add_deterministic_dir_to_artifact(
42
- artifact: "LocalArtifact", dir_name: str, target_dir_root: str
41
+ artifact: "Artifact", dir_name: str, target_dir_root: str
43
42
  ) -> str:
44
43
  file_paths = []
45
44
  for dirpath, _, filenames in os.walk(dir_name, topdown=True):
@@ -51,7 +50,7 @@ def _add_deterministic_dir_to_artifact(
51
50
  return target_path
52
51
 
53
52
 
54
- def _load_dir_from_artifact(source_artifact: "PublicArtifact", path: str) -> str:
53
+ def _load_dir_from_artifact(source_artifact: "Artifact", path: str) -> str:
55
54
  dl_path = None
56
55
 
57
56
  # Look through the entire manifest to find all of the files in the directory.
@@ -126,7 +125,7 @@ class _SavedModel(WBValue, Generic[SavedModelObjType]):
126
125
 
127
126
  @classmethod
128
127
  def from_json(
129
- cls: Type["_SavedModel"], json_obj: dict, source_artifact: "PublicArtifact"
128
+ cls: Type["_SavedModel"], json_obj: dict, source_artifact: "Artifact"
130
129
  ) -> "_SavedModel":
131
130
  path = json_obj["path"]
132
131
 
@@ -144,7 +143,7 @@ class _SavedModel(WBValue, Generic[SavedModelObjType]):
144
143
  # and specified adapter.
145
144
  return cls(dl_path)
146
145
 
147
- def to_json(self, run_or_artifact: Union["LocalRun", "LocalArtifact"]) -> dict:
146
+ def to_json(self, run_or_artifact: Union["LocalRun", "Artifact"]) -> dict:
148
147
  # Unlike other data types, we do not allow adding to a Run directly. There is a
149
148
  # bit of tech debt in the other data types which requires the input to `to_json`
150
149
  # to accept a Run or Artifact. However, Run additions should be deprecated in the future.
@@ -320,7 +319,7 @@ class _PicklingSavedModel(_SavedModel[SavedModelObjType]):
320
319
 
321
320
  @classmethod
322
321
  def from_json(
323
- cls: Type["_SavedModel"], json_obj: dict, source_artifact: "PublicArtifact"
322
+ cls: Type["_SavedModel"], json_obj: dict, source_artifact: "Artifact"
324
323
  ) -> "_PicklingSavedModel":
325
324
  backup_path = [p for p in sys.path]
326
325
  if (
@@ -337,7 +336,7 @@ class _PicklingSavedModel(_SavedModel[SavedModelObjType]):
337
336
 
338
337
  return inst # type: ignore
339
338
 
340
- def to_json(self, run_or_artifact: Union["LocalRun", "LocalArtifact"]) -> dict:
339
+ def to_json(self, run_or_artifact: Union["LocalRun", "Artifact"]) -> dict:
341
340
  json_obj = super().to_json(run_or_artifact)
342
341
  assert isinstance(run_or_artifact, wandb.Artifact)
343
342
  if self._dep_py_files_path is not None:
@@ -13,12 +13,12 @@ from dataclasses import dataclass, field
13
13
  from enum import Enum
14
14
  from typing import TYPE_CHECKING, Any, Dict, List, Optional, Union
15
15
 
16
- from wandb.data_types import _json_helper
16
+ import wandb.data_types
17
17
  from wandb.sdk.data_types import _dtypes
18
18
  from wandb.sdk.data_types.base_types.media import Media
19
19
 
20
20
  if TYPE_CHECKING: # pragma: no cover
21
- from wandb.sdk.artifacts.local_artifact import Artifact as LocalArtifact
21
+ from wandb.sdk.artifacts.artifact import Artifact
22
22
 
23
23
  from ..wandb_run import Run as LocalRun
24
24
 
@@ -103,7 +103,7 @@ class WBTraceTree(Media):
103
103
  def get_media_subdir(cls) -> str:
104
104
  return "media/wb_trace_tree"
105
105
 
106
- def to_json(self, run: Optional[Union["LocalRun", "LocalArtifact"]]) -> dict:
106
+ def to_json(self, run: Optional[Union["LocalRun", "Artifact"]]) -> dict:
107
107
  res = {}
108
108
  res["_type"] = self._log_type
109
109
  # Here we use `dumps` to put things into string format. This is because
@@ -142,7 +142,7 @@ def _fallback_serialize(obj: Any) -> str:
142
142
  def _safe_serialize(obj: dict) -> str:
143
143
  try:
144
144
  return json.dumps(
145
- _json_helper(obj, None),
145
+ wandb.data_types._json_helper(obj, None),
146
146
  skipkeys=True,
147
147
  default=_fallback_serialize,
148
148
  )
@@ -13,9 +13,9 @@ from .base_types.media import BatchableMedia
13
13
  if TYPE_CHECKING: # pragma: no cover
14
14
  from typing import TextIO
15
15
 
16
- import numpy as np # type: ignore
16
+ import numpy as np
17
17
 
18
- from wandb.sdk.artifacts.local_artifact import Artifact as LocalArtifact
18
+ from wandb.sdk.artifacts.artifact import Artifact
19
19
 
20
20
  from ..wandb_run import Run as LocalRun
21
21
 
@@ -133,7 +133,7 @@ class Video(BatchableMedia):
133
133
  required='wandb.Video requires moviepy and imageio when passing raw data. Install with "pip install moviepy imageio"',
134
134
  )
135
135
  tensor = self._prepare_video(self.data)
136
- _, self._height, self._width, self._channels = tensor.shape
136
+ _, self._height, self._width, self._channels = tensor.shape # type: ignore
137
137
 
138
138
  # encode sequence of images into gif string
139
139
  clip = mpy.ImageSequenceClip(list(tensor), fps=self._fps)
@@ -170,7 +170,7 @@ class Video(BatchableMedia):
170
170
  def get_media_subdir(cls: Type["Video"]) -> str:
171
171
  return os.path.join("media", "videos")
172
172
 
173
- def to_json(self, run_or_artifact: Union["LocalRun", "LocalArtifact"]) -> dict:
173
+ def to_json(self, run_or_artifact: Union["LocalRun", "Artifact"]) -> dict:
174
174
  json_dict = super().to_json(run_or_artifact)
175
175
  json_dict["_type"] = self._log_type
176
176