wandb 0.20.2rc20250616__py3-none-win_amd64.whl → 0.21.1__py3-none-win_amd64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- wandb/__init__.py +16 -14
- wandb/__init__.pyi +450 -472
- wandb/agents/pyagent.py +41 -12
- wandb/analytics/sentry.py +7 -2
- wandb/apis/importers/mlflow.py +1 -1
- wandb/apis/internal.py +3 -0
- wandb/apis/paginator.py +17 -4
- wandb/apis/public/__init__.py +1 -1
- wandb/apis/public/api.py +606 -359
- wandb/apis/public/artifacts.py +214 -16
- wandb/apis/public/automations.py +19 -3
- wandb/apis/public/files.py +177 -38
- wandb/apis/public/history.py +67 -15
- wandb/apis/public/integrations.py +25 -2
- wandb/apis/public/jobs.py +90 -2
- wandb/apis/public/projects.py +161 -69
- wandb/apis/public/query_generator.py +11 -1
- wandb/apis/public/registries/registries_search.py +7 -15
- wandb/apis/public/reports.py +147 -13
- wandb/apis/public/runs.py +315 -128
- wandb/apis/public/sweeps.py +222 -22
- wandb/apis/public/teams.py +41 -4
- wandb/apis/public/users.py +45 -4
- wandb/automations/__init__.py +10 -10
- wandb/automations/_filters/run_metrics.py +0 -2
- wandb/automations/_utils.py +0 -2
- wandb/automations/actions.py +0 -2
- wandb/automations/automations.py +0 -2
- wandb/automations/events.py +0 -2
- wandb/beta/workflows.py +66 -30
- wandb/bin/gpu_stats.exe +0 -0
- wandb/bin/wandb-core +0 -0
- wandb/cli/cli.py +80 -1
- wandb/env.py +8 -0
- wandb/errors/errors.py +4 -1
- wandb/integration/catboost/catboost.py +6 -2
- wandb/integration/kfp/kfp_patch.py +3 -1
- wandb/integration/lightning/fabric/logger.py +3 -4
- wandb/integration/metaflow/__init__.py +6 -0
- wandb/integration/metaflow/data_pandas.py +74 -0
- wandb/integration/metaflow/errors.py +13 -0
- wandb/integration/metaflow/metaflow.py +205 -190
- wandb/integration/openai/fine_tuning.py +1 -2
- wandb/integration/sb3/sb3.py +3 -3
- wandb/integration/ultralytics/callback.py +6 -2
- wandb/jupyter.py +5 -5
- wandb/plot/__init__.py +2 -0
- wandb/plot/bar.py +30 -29
- wandb/plot/confusion_matrix.py +75 -71
- wandb/plot/custom_chart.py +30 -7
- wandb/plot/histogram.py +26 -25
- wandb/plot/line.py +33 -32
- wandb/plot/line_series.py +100 -103
- wandb/plot/pr_curve.py +33 -32
- wandb/plot/roc_curve.py +38 -38
- wandb/plot/scatter.py +27 -27
- wandb/proto/v3/wandb_internal_pb2.py +366 -385
- wandb/proto/v3/wandb_settings_pb2.py +2 -2
- wandb/proto/v3/wandb_telemetry_pb2.py +4 -4
- wandb/proto/v4/wandb_internal_pb2.py +352 -356
- wandb/proto/v4/wandb_settings_pb2.py +2 -2
- wandb/proto/v4/wandb_telemetry_pb2.py +4 -4
- wandb/proto/v5/wandb_internal_pb2.py +352 -356
- wandb/proto/v5/wandb_settings_pb2.py +2 -2
- wandb/proto/v5/wandb_telemetry_pb2.py +4 -4
- wandb/proto/v6/wandb_internal_pb2.py +352 -356
- wandb/proto/v6/wandb_settings_pb2.py +2 -2
- wandb/proto/v6/wandb_telemetry_pb2.py +4 -4
- wandb/proto/wandb_deprecated.py +6 -0
- wandb/sdk/artifacts/_generated/__init__.py +12 -1
- wandb/sdk/artifacts/_generated/input_types.py +20 -2
- wandb/sdk/artifacts/_generated/link_artifact.py +21 -0
- wandb/sdk/artifacts/_generated/operations.py +9 -0
- wandb/sdk/artifacts/_internal_artifact.py +19 -8
- wandb/sdk/artifacts/_validators.py +48 -2
- wandb/sdk/artifacts/artifact.py +269 -96
- wandb/sdk/data_types/audio.py +38 -10
- wandb/sdk/data_types/base_types/media.py +15 -63
- wandb/sdk/data_types/base_types/wb_value.py +6 -6
- wandb/sdk/data_types/graph.py +48 -14
- wandb/sdk/data_types/helper_types/bounding_boxes_2d.py +1 -3
- wandb/sdk/data_types/helper_types/image_mask.py +1 -3
- wandb/sdk/data_types/histogram.py +34 -21
- wandb/sdk/data_types/html.py +35 -12
- wandb/sdk/data_types/image.py +104 -68
- wandb/sdk/data_types/molecule.py +32 -19
- wandb/sdk/data_types/object_3d.py +36 -17
- wandb/sdk/data_types/plotly.py +18 -5
- wandb/sdk/data_types/saved_model.py +7 -9
- wandb/sdk/data_types/table.py +99 -70
- wandb/sdk/data_types/trace_tree.py +12 -12
- wandb/sdk/data_types/video.py +53 -26
- wandb/sdk/integration_utils/auto_logging.py +2 -2
- wandb/sdk/interface/interface.py +8 -19
- wandb/sdk/interface/interface_shared.py +7 -16
- wandb/sdk/internal/datastore.py +18 -18
- wandb/sdk/internal/handler.py +3 -5
- wandb/sdk/internal/internal_api.py +60 -0
- wandb/sdk/internal/job_builder.py +6 -0
- wandb/sdk/internal/sender.py +23 -3
- wandb/sdk/internal/sender_config.py +9 -0
- wandb/sdk/launch/_project_spec.py +3 -3
- wandb/sdk/launch/agent/agent.py +11 -4
- wandb/sdk/launch/agent/job_status_tracker.py +3 -1
- wandb/sdk/launch/agent/run_queue_item_file_saver.py +2 -2
- wandb/sdk/launch/create_job.py +3 -1
- wandb/sdk/launch/inputs/internal.py +3 -4
- wandb/sdk/launch/inputs/schema.py +1 -0
- wandb/sdk/launch/runner/kubernetes_monitor.py +1 -0
- wandb/sdk/launch/runner/kubernetes_runner.py +328 -1
- wandb/sdk/launch/sweeps/scheduler.py +2 -3
- wandb/sdk/launch/utils.py +3 -3
- wandb/sdk/lib/asyncio_compat.py +3 -0
- wandb/sdk/lib/console_capture.py +66 -19
- wandb/sdk/lib/deprecate.py +1 -7
- wandb/sdk/lib/disabled.py +1 -1
- wandb/sdk/lib/hashutil.py +14 -1
- wandb/sdk/lib/module.py +7 -13
- wandb/sdk/lib/progress.py +0 -19
- wandb/sdk/lib/sock_client.py +0 -4
- wandb/sdk/wandb_init.py +67 -93
- wandb/sdk/wandb_login.py +18 -14
- wandb/sdk/wandb_metric.py +2 -0
- wandb/sdk/wandb_require.py +0 -1
- wandb/sdk/wandb_run.py +429 -527
- wandb/sdk/wandb_settings.py +364 -74
- wandb/sdk/wandb_setup.py +28 -28
- wandb/sdk/wandb_sweep.py +14 -13
- wandb/sdk/wandb_watch.py +4 -6
- wandb/sync/sync.py +10 -0
- wandb/util.py +57 -0
- wandb/wandb_run.py +1 -2
- {wandb-0.20.2rc20250616.dist-info → wandb-0.21.1.dist-info}/METADATA +1 -1
- {wandb-0.20.2rc20250616.dist-info → wandb-0.21.1.dist-info}/RECORD +137 -137
- wandb/sdk/wandb_metadata.py +0 -623
- wandb/vendor/pynvml/__init__.py +0 -0
- wandb/vendor/pynvml/pynvml.py +0 -4779
- {wandb-0.20.2rc20250616.dist-info → wandb-0.21.1.dist-info}/WHEEL +0 -0
- {wandb-0.20.2rc20250616.dist-info → wandb-0.21.1.dist-info}/entry_points.txt +0 -0
- {wandb-0.20.2rc20250616.dist-info → wandb-0.21.1.dist-info}/licenses/LICENSE +0 -0
wandb/sdk/data_types/image.py
CHANGED
@@ -28,8 +28,6 @@ if TYPE_CHECKING: # pragma: no cover
|
|
28
28
|
|
29
29
|
from wandb.sdk.artifacts.artifact import Artifact
|
30
30
|
|
31
|
-
from ..wandb_run import Run as LocalRun
|
32
|
-
|
33
31
|
ImageDataType = Union[
|
34
32
|
"matplotlib.artist.Artist", "PILImage", "TorchTensorType", "np.ndarray"
|
35
33
|
]
|
@@ -101,7 +99,7 @@ def _convert_to_uint8(data: "np.ndarray") -> "np.ndarray":
|
|
101
99
|
return data.astype(np.uint8)
|
102
100
|
|
103
101
|
|
104
|
-
def _server_accepts_image_filenames(run: "
|
102
|
+
def _server_accepts_image_filenames(run: "wandb.Run") -> bool:
|
105
103
|
if run.offline:
|
106
104
|
return True
|
107
105
|
|
@@ -117,7 +115,7 @@ def _server_accepts_image_filenames(run: "LocalRun") -> bool:
|
|
117
115
|
return accepts_image_filenames
|
118
116
|
|
119
117
|
|
120
|
-
def _server_accepts_artifact_path(run: "
|
118
|
+
def _server_accepts_artifact_path(run: "wandb.Run") -> bool:
|
121
119
|
if run.offline:
|
122
120
|
return False
|
123
121
|
|
@@ -161,19 +159,18 @@ class Image(BatchableMedia):
|
|
161
159
|
file_type: Optional[str] = None,
|
162
160
|
normalize: bool = True,
|
163
161
|
) -> None:
|
164
|
-
"""Initialize a wandb.Image object.
|
162
|
+
"""Initialize a `wandb.Image` object.
|
165
163
|
|
166
164
|
Args:
|
167
|
-
data_or_path: Accepts
|
168
|
-
a PIL image object, or a path to an image file.
|
169
|
-
|
170
|
-
If a numpy array or pytorch tensor is provided,
|
165
|
+
data_or_path: Accepts NumPy array/pytorch tensor of image data,
|
166
|
+
a PIL image object, or a path to an image file. If a NumPy
|
167
|
+
array or pytorch tensor is provided,
|
171
168
|
the image data will be saved to the given file type.
|
172
169
|
If the values are not in the range [0, 255] or all values are in the range [0, 1],
|
173
170
|
the image pixel values will be normalized to the range [0, 255]
|
174
171
|
unless `normalize` is set to False.
|
175
|
-
|
176
|
-
|
172
|
+
- pytorch tensor should be in the format (channel, height, width)
|
173
|
+
- NumPy array should be in the format (height, width, channel)
|
177
174
|
mode: The PIL mode for an image. Most common are "L", "RGB",
|
178
175
|
"RGBA". Full explanation at https://pillow.readthedocs.io/en/stable/handbook/concepts.html#modes
|
179
176
|
caption: Label for display of image.
|
@@ -190,53 +187,56 @@ class Image(BatchableMedia):
|
|
190
187
|
Normalize is only applied if data_or_path is a numpy array or pytorch tensor.
|
191
188
|
|
192
189
|
Examples:
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
190
|
+
Create a wandb.Image from a numpy array
|
191
|
+
|
192
|
+
```python
|
193
|
+
import numpy as np
|
194
|
+
import wandb
|
195
|
+
|
196
|
+
with wandb.init() as run:
|
197
|
+
examples = []
|
198
|
+
for i in range(3):
|
199
|
+
pixels = np.random.randint(low=0, high=256, size=(100, 100, 3))
|
200
|
+
image = wandb.Image(pixels, caption=f"random field {i}")
|
201
|
+
examples.append(image)
|
202
|
+
run.log({"examples": examples})
|
203
|
+
```
|
204
|
+
|
205
|
+
Create a wandb.Image from a PILImage
|
206
|
+
|
207
|
+
```python
|
208
|
+
import numpy as np
|
209
|
+
from PIL import Image as PILImage
|
210
|
+
import wandb
|
211
|
+
|
212
|
+
with wandb.init() as run:
|
213
|
+
examples = []
|
214
|
+
for i in range(3):
|
215
|
+
pixels = np.random.randint(
|
216
|
+
low=0, high=256, size=(100, 100, 3), dtype=np.uint8
|
217
|
+
)
|
218
|
+
pil_image = PILImage.fromarray(pixels, mode="RGB")
|
219
|
+
image = wandb.Image(pil_image, caption=f"random field {i}")
|
220
|
+
examples.append(image)
|
221
|
+
run.log({"examples": examples})
|
222
|
+
```
|
223
|
+
|
224
|
+
Log .jpg rather than .png (default)
|
225
|
+
|
226
|
+
```python
|
227
|
+
import numpy as np
|
228
|
+
import wandb
|
229
|
+
|
230
|
+
with wandb.init() as run:
|
231
|
+
examples = []
|
232
|
+
for i in range(3):
|
233
|
+
pixels = np.random.randint(low=0, high=256, size=(100, 100, 3))
|
234
|
+
image = wandb.Image(
|
235
|
+
pixels, caption=f"random field {i}", file_type="jpg"
|
236
|
+
)
|
237
|
+
examples.append(image)
|
238
|
+
run.log({"examples": examples})
|
239
|
+
```
|
240
240
|
"""
|
241
241
|
super().__init__(caption=caption)
|
242
242
|
# TODO: We should remove grouping, it's a terrible name and I don't
|
@@ -442,6 +442,10 @@ class Image(BatchableMedia):
|
|
442
442
|
def from_json(
|
443
443
|
cls: Type["Image"], json_obj: dict, source_artifact: "Artifact"
|
444
444
|
) -> "Image":
|
445
|
+
"""Factory method to create an Audio object from a JSON object.
|
446
|
+
|
447
|
+
"<!-- lazydoc-ignore-classmethod: internal -->
|
448
|
+
"""
|
445
449
|
classes: Optional[Classes] = None
|
446
450
|
if json_obj.get("classes") is not None:
|
447
451
|
value = source_artifact.get(json_obj["classes"]["path"])
|
@@ -476,16 +480,24 @@ class Image(BatchableMedia):
|
|
476
480
|
|
477
481
|
@classmethod
|
478
482
|
def get_media_subdir(cls: Type["Image"]) -> str:
|
483
|
+
"""Get media subdirectory.
|
484
|
+
|
485
|
+
"<!-- lazydoc-ignore-classmethod: internal -->
|
486
|
+
"""
|
479
487
|
return os.path.join("media", "images")
|
480
488
|
|
481
489
|
def bind_to_run(
|
482
490
|
self,
|
483
|
-
run: "
|
491
|
+
run: "wandb.Run",
|
484
492
|
key: Union[int, str],
|
485
493
|
step: Union[int, str],
|
486
494
|
id_: Optional[Union[int, str]] = None,
|
487
495
|
ignore_copy_err: Optional[bool] = None,
|
488
496
|
) -> None:
|
497
|
+
"""Bind this object to a run.
|
498
|
+
|
499
|
+
<!-- lazydoc-ignore: internal -->
|
500
|
+
"""
|
489
501
|
# For Images, we are going to avoid copying the image file to the run.
|
490
502
|
# We should make this common functionality for all media types, but that
|
491
503
|
# requires a broader UI refactor. This model can easily be moved to the
|
@@ -519,9 +531,11 @@ class Image(BatchableMedia):
|
|
519
531
|
run, key, step, id_, ignore_copy_err=ignore_copy_err
|
520
532
|
)
|
521
533
|
|
522
|
-
def to_json(self, run_or_artifact: Union["
|
523
|
-
|
534
|
+
def to_json(self, run_or_artifact: Union["wandb.Run", "Artifact"]) -> dict:
|
535
|
+
"""Returns the JSON representation expected by the backend.
|
524
536
|
|
537
|
+
<!-- lazydoc-ignore: internal -->
|
538
|
+
"""
|
525
539
|
json_dict = super().to_json(run_or_artifact)
|
526
540
|
json_dict["_type"] = Image._log_type
|
527
541
|
json_dict["format"] = self.format
|
@@ -558,8 +572,8 @@ class Image(BatchableMedia):
|
|
558
572
|
"digest": classes_entry.digest,
|
559
573
|
}
|
560
574
|
|
561
|
-
elif not isinstance(run_or_artifact, Run):
|
562
|
-
raise TypeError("to_json accepts
|
575
|
+
elif not isinstance(run_or_artifact, wandb.Run):
|
576
|
+
raise TypeError("to_json accepts wandb.Run or wandb_artifact.Artifact")
|
563
577
|
|
564
578
|
if self._boxes:
|
565
579
|
json_dict["boxes"] = {
|
@@ -576,7 +590,10 @@ class Image(BatchableMedia):
|
|
576
590
|
data: Union["np.ndarray", "torch.Tensor"],
|
577
591
|
file_type: Optional[str] = None,
|
578
592
|
) -> str:
|
579
|
-
"""Guess what type of image the np.array is representing.
|
593
|
+
"""Guess what type of image the np.array is representing.
|
594
|
+
|
595
|
+
<!-- lazydoc-ignore: internal -->
|
596
|
+
"""
|
580
597
|
# TODO: do we want to support dimensions being at the beginning of the array?
|
581
598
|
ndims = data.ndim
|
582
599
|
if util.is_pytorch_tensor_typename(util.get_full_typename(data)):
|
@@ -608,11 +625,14 @@ class Image(BatchableMedia):
|
|
608
625
|
def seq_to_json(
|
609
626
|
cls: Type["Image"],
|
610
627
|
seq: Sequence["BatchableMedia"],
|
611
|
-
run: "
|
628
|
+
run: "wandb.Run",
|
612
629
|
key: str,
|
613
630
|
step: Union[int, str],
|
614
631
|
) -> dict:
|
615
|
-
"""
|
632
|
+
"""Convert a sequence of Image objects to a JSON representation.
|
633
|
+
|
634
|
+
"<!-- lazydoc-ignore-classmethod: internal -->
|
635
|
+
"""
|
616
636
|
if TYPE_CHECKING:
|
617
637
|
seq = cast(Sequence["Image"], seq)
|
618
638
|
|
@@ -682,10 +702,14 @@ class Image(BatchableMedia):
|
|
682
702
|
def all_masks(
|
683
703
|
cls: Type["Image"],
|
684
704
|
images: Sequence["Image"],
|
685
|
-
run: "
|
705
|
+
run: "wandb.Run",
|
686
706
|
run_key: str,
|
687
707
|
step: Union[int, str],
|
688
708
|
) -> Union[List[Optional[dict]], bool]:
|
709
|
+
"""Collect all masks from a list of images.
|
710
|
+
|
711
|
+
"<!-- lazydoc-ignore-classmethod: internal -->
|
712
|
+
"""
|
689
713
|
all_mask_groups: List[Optional[dict]] = []
|
690
714
|
for image in images:
|
691
715
|
if image._masks:
|
@@ -705,10 +729,14 @@ class Image(BatchableMedia):
|
|
705
729
|
def all_boxes(
|
706
730
|
cls: Type["Image"],
|
707
731
|
images: Sequence["Image"],
|
708
|
-
run: "
|
732
|
+
run: "wandb.Run",
|
709
733
|
run_key: str,
|
710
734
|
step: Union[int, str],
|
711
735
|
) -> Union[List[Optional[dict]], bool]:
|
736
|
+
"""Collect all boxes from a list of images.
|
737
|
+
|
738
|
+
"<!-- lazydoc-ignore-classmethod: internal -->
|
739
|
+
"""
|
712
740
|
all_box_groups: List[Optional[dict]] = []
|
713
741
|
for image in images:
|
714
742
|
if image._boxes:
|
@@ -728,6 +756,10 @@ class Image(BatchableMedia):
|
|
728
756
|
def all_captions(
|
729
757
|
cls: Type["Image"], images: Sequence["Media"]
|
730
758
|
) -> Union[bool, Sequence[Optional[str]]]:
|
759
|
+
"""Get captions from a list of images.
|
760
|
+
|
761
|
+
"<!-- lazydoc-ignore-classmethod: internal -->
|
762
|
+
"""
|
731
763
|
return cls.captions(images)
|
732
764
|
|
733
765
|
def __ne__(self, other: object) -> bool:
|
@@ -758,6 +790,10 @@ class Image(BatchableMedia):
|
|
758
790
|
)
|
759
791
|
|
760
792
|
def to_data_array(self) -> List[Any]:
|
793
|
+
"""Convert to data array.
|
794
|
+
|
795
|
+
<!-- lazydoc-ignore: internal -->
|
796
|
+
"""
|
761
797
|
res = []
|
762
798
|
if self.image is not None:
|
763
799
|
data = list(self.image.getdata())
|
wandb/sdk/data_types/molecule.py
CHANGED
@@ -23,14 +23,7 @@ if TYPE_CHECKING: # pragma: no cover
|
|
23
23
|
|
24
24
|
|
25
25
|
class Molecule(BatchableMedia):
|
26
|
-
"""
|
27
|
-
|
28
|
-
Args:
|
29
|
-
data_or_path: (pathlib.Path, string, io)
|
30
|
-
Molecule can be initialized from a file name or an io object.
|
31
|
-
caption: (string)
|
32
|
-
Caption associated with the molecule for display.
|
33
|
-
"""
|
26
|
+
"""W&B class for 3D Molecular data."""
|
34
27
|
|
35
28
|
SUPPORTED_TYPES = {
|
36
29
|
"pdb",
|
@@ -53,6 +46,12 @@ class Molecule(BatchableMedia):
|
|
53
46
|
caption: Optional[str] = None,
|
54
47
|
**kwargs: str,
|
55
48
|
) -> None:
|
49
|
+
"""Initialize a Molecule object.
|
50
|
+
|
51
|
+
Args:
|
52
|
+
data_or_path: Molecule can be initialized from a file name or an io object.
|
53
|
+
caption: Caption associated with the molecule for display.
|
54
|
+
"""
|
56
55
|
super().__init__(caption=caption)
|
57
56
|
|
58
57
|
if hasattr(data_or_path, "name"):
|
@@ -116,6 +115,8 @@ class Molecule(BatchableMedia):
|
|
116
115
|
This is an expensive operation that may take a long time for complicated molecules.
|
117
116
|
mmff_optimize_molecule_max_iterations: (int)
|
118
117
|
Number of iterations to use in rdkit.Chem.AllChem.MMFFOptimizeMolecule
|
118
|
+
|
119
|
+
<!-- lazydoc-ignore-classmethod: internal -->
|
119
120
|
"""
|
120
121
|
rdkit_chem = util.get_module(
|
121
122
|
"rdkit.Chem",
|
@@ -172,17 +173,17 @@ class Molecule(BatchableMedia):
|
|
172
173
|
"""Convert SMILES string to wandb.Molecule.
|
173
174
|
|
174
175
|
Args:
|
175
|
-
data:
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
176
|
+
data: SMILES string.
|
177
|
+
caption: Caption associated with the molecule for display.
|
178
|
+
sanitize: Check if the molecule is chemically reasonable by
|
179
|
+
the RDKit's definition.
|
180
|
+
convert_to_3d_and_optimize: Convert to rdkit.Chem.rdchem.Mol
|
181
|
+
with 3D coordinates. This is a computationally intensive
|
182
|
+
operation that may take a long time for complicated molecules.
|
183
|
+
mmff_optimize_molecule_max_iterations: Number of iterations to
|
184
|
+
use in rdkit.Chem.AllChem.MMFFOptimizeMolecule.
|
185
|
+
|
186
|
+
<!-- lazydoc-ignore-classmethod: internal -->
|
186
187
|
"""
|
187
188
|
rdkit_chem = util.get_module(
|
188
189
|
"rdkit.Chem",
|
@@ -201,9 +202,17 @@ class Molecule(BatchableMedia):
|
|
201
202
|
|
202
203
|
@classmethod
|
203
204
|
def get_media_subdir(cls: Type["Molecule"]) -> str:
|
205
|
+
"""Get media subdirectory.
|
206
|
+
|
207
|
+
<!-- lazydoc-ignore-classmethod: internal -->
|
208
|
+
"""
|
204
209
|
return os.path.join("media", "molecule")
|
205
210
|
|
206
211
|
def to_json(self, run_or_artifact: Union["LocalRun", "Artifact"]) -> dict:
|
212
|
+
"""Returns the JSON representation expected by the backend.
|
213
|
+
|
214
|
+
<!-- lazydoc-ignore: internal -->
|
215
|
+
"""
|
207
216
|
json_dict = super().to_json(run_or_artifact)
|
208
217
|
json_dict["_type"] = self._log_type
|
209
218
|
return json_dict
|
@@ -216,6 +225,10 @@ class Molecule(BatchableMedia):
|
|
216
225
|
key: str,
|
217
226
|
step: Union[int, str],
|
218
227
|
) -> dict:
|
228
|
+
"""Convert a sequence of Molecule objects to a JSON representation.
|
229
|
+
|
230
|
+
<!-- lazydoc-ignore-classmethod: internal -->
|
231
|
+
"""
|
219
232
|
seq = list(seq)
|
220
233
|
|
221
234
|
jsons = [obj.to_json(run) for obj in seq]
|
@@ -185,22 +185,7 @@ def box3d(
|
|
185
185
|
|
186
186
|
|
187
187
|
class Object3D(BatchableMedia):
|
188
|
-
"""
|
189
|
-
|
190
|
-
Args:
|
191
|
-
data_or_path: (numpy array, pathlib.Path, string, io)
|
192
|
-
Object3D can be initialized from a file or a numpy array.
|
193
|
-
|
194
|
-
You can pass a path to a file or an io object and a file_type
|
195
|
-
which must be one of SUPPORTED_TYPES
|
196
|
-
|
197
|
-
The shape of the numpy array must be one of either:
|
198
|
-
```
|
199
|
-
[[x y z], ...] nx3
|
200
|
-
[[x y z c], ...] nx4 where c is a category with supported range [1, 14]
|
201
|
-
[[x y z r g b], ...] nx6 where is rgb is color
|
202
|
-
```
|
203
|
-
"""
|
188
|
+
"""W&B class for 3D point clouds."""
|
204
189
|
|
205
190
|
SUPPORTED_TYPES: ClassVar[Set[str]] = {
|
206
191
|
"obj",
|
@@ -219,6 +204,21 @@ class Object3D(BatchableMedia):
|
|
219
204
|
caption: Optional[str] = None,
|
220
205
|
**kwargs: Optional[Union[str, "FileFormat3D"]],
|
221
206
|
) -> None:
|
207
|
+
"""Creates a W&B Object3D object.
|
208
|
+
|
209
|
+
Args:
|
210
|
+
data_or_path: Object3D can be initialized from a file or a numpy array.
|
211
|
+
caption: Caption associated with the object for display.
|
212
|
+
|
213
|
+
Examples:
|
214
|
+
The shape of the numpy array must be one of either
|
215
|
+
|
216
|
+
```text
|
217
|
+
[[x y z], ...] nx3
|
218
|
+
[[x y z c], ...] nx4 where c is a category with supported range [1, 14]
|
219
|
+
[[x y z r g b], ...] nx6 where is rgb is color
|
220
|
+
```
|
221
|
+
"""
|
222
222
|
super().__init__(caption=caption)
|
223
223
|
|
224
224
|
if hasattr(data_or_path, "name") and not isinstance(data_or_path, pathlib.Path):
|
@@ -347,6 +347,8 @@ class Object3D(BatchableMedia):
|
|
347
347
|
data_or_path (Union["TextIO", str]): A path to a file or a `TextIO` stream.
|
348
348
|
file_type (str): Specifies the data format passed to `data_or_path`. Required when `data_or_path` is a
|
349
349
|
`TextIO` stream. This parameter is ignored if a file path is provided. The type is taken from the file extension.
|
350
|
+
|
351
|
+
<!-- lazydoc-ignore-classmethod: internal -->
|
350
352
|
"""
|
351
353
|
# if file_type is not None and file_type not in cls.SUPPORTED_TYPES:
|
352
354
|
# raise ValueError(
|
@@ -364,11 +366,14 @@ class Object3D(BatchableMedia):
|
|
364
366
|
|
365
367
|
|
366
368
|
The shape of the numpy array must be one of either:
|
367
|
-
|
369
|
+
|
370
|
+
```text
|
368
371
|
[[x y z], ...] # nx3.
|
369
372
|
[[x y z c], ...] # nx4 where c is a category with supported range [1, 14].
|
370
373
|
[[x y z r g b], ...] # nx6 where is rgb is color.
|
371
374
|
```
|
375
|
+
|
376
|
+
<!-- lazydoc-ignore-classmethod: internal -->
|
372
377
|
"""
|
373
378
|
if not util.is_numpy_array(data):
|
374
379
|
raise ValueError("`data` must be a numpy array")
|
@@ -403,6 +408,8 @@ class Object3D(BatchableMedia):
|
|
403
408
|
vectors (Optional[Sequence["Vector3D"]]): Each vector is displayed in the point cloud
|
404
409
|
visualization. Can be used to indicate directionality of bounding boxes. Defaults to None.
|
405
410
|
point_cloud_type ("lidar/beta"): At this time, only the "lidar/beta" type is supported. Defaults to "lidar/beta".
|
411
|
+
|
412
|
+
<!-- lazydoc-ignore-classmethod: internal -->
|
406
413
|
"""
|
407
414
|
if point_cloud_type not in cls.SUPPORTED_POINT_CLOUD_TYPES:
|
408
415
|
raise ValueError("Point cloud type not supported")
|
@@ -423,9 +430,17 @@ class Object3D(BatchableMedia):
|
|
423
430
|
|
424
431
|
@classmethod
|
425
432
|
def get_media_subdir(cls: Type["Object3D"]) -> str:
|
433
|
+
"""Get media subdirectory.
|
434
|
+
|
435
|
+
<!-- lazydoc-ignore-classmethod: internal -->
|
436
|
+
"""
|
426
437
|
return os.path.join("media", "object3D")
|
427
438
|
|
428
439
|
def to_json(self, run_or_artifact: Union["LocalRun", "Artifact"]) -> dict:
|
440
|
+
"""Returns the JSON representation expected by the backend.
|
441
|
+
|
442
|
+
<!-- lazydoc-ignore: internal -->
|
443
|
+
"""
|
429
444
|
json_dict = super().to_json(run_or_artifact)
|
430
445
|
json_dict["_type"] = Object3D._log_type
|
431
446
|
|
@@ -445,6 +460,10 @@ class Object3D(BatchableMedia):
|
|
445
460
|
key: str,
|
446
461
|
step: Union[int, str],
|
447
462
|
) -> dict:
|
463
|
+
"""Convert a sequence of Audio objects to a JSON representation.
|
464
|
+
|
465
|
+
<!-- lazydoc-ignore-classmethod: internal -->
|
466
|
+
"""
|
448
467
|
seq = list(seq)
|
449
468
|
|
450
469
|
jsons = [obj.to_json(run) for obj in seq]
|
wandb/sdk/data_types/plotly.py
CHANGED
@@ -31,11 +31,7 @@ if TYPE_CHECKING: # pragma: no cover
|
|
31
31
|
|
32
32
|
|
33
33
|
class Plotly(Media):
|
34
|
-
"""
|
35
|
-
|
36
|
-
Args:
|
37
|
-
val: matplotlib or plotly figure
|
38
|
-
"""
|
34
|
+
"""W&B class for Plotly plots."""
|
39
35
|
|
40
36
|
_log_type = "plotly-file"
|
41
37
|
|
@@ -43,6 +39,10 @@ class Plotly(Media):
|
|
43
39
|
def make_plot_media(
|
44
40
|
cls: Type["Plotly"], val: Union["plotly.Figure", "matplotlib.artist.Artist"]
|
45
41
|
) -> Union[Image, "Plotly"]:
|
42
|
+
"""Create a Plotly object from a Plotly figure or a matplotlib artist.
|
43
|
+
|
44
|
+
<!-- lazydoc-ignore-classmethod: internal -->
|
45
|
+
"""
|
46
46
|
if util.is_matplotlib_typename(util.get_full_typename(val)):
|
47
47
|
if util.matplotlib_contains_images(val):
|
48
48
|
return Image(val)
|
@@ -50,6 +50,11 @@ class Plotly(Media):
|
|
50
50
|
return cls(val)
|
51
51
|
|
52
52
|
def __init__(self, val: Union["plotly.Figure", "matplotlib.artist.Artist"]):
|
53
|
+
"""Initialize a Plotly object.
|
54
|
+
|
55
|
+
Args:
|
56
|
+
val: Matplotlib or Plotly figure.
|
57
|
+
"""
|
53
58
|
super().__init__()
|
54
59
|
# First, check to see if the incoming `val` object is a plotfly figure
|
55
60
|
if not util.is_plotly_figure_typename(util.get_full_typename(val)):
|
@@ -74,9 +79,17 @@ class Plotly(Media):
|
|
74
79
|
|
75
80
|
@classmethod
|
76
81
|
def get_media_subdir(cls: Type["Plotly"]) -> str:
|
82
|
+
"""Returns the media subdirectory for Plotly plots.
|
83
|
+
|
84
|
+
<!-- lazydoc-ignore-classmethod: internal -->
|
85
|
+
"""
|
77
86
|
return os.path.join("media", "plotly")
|
78
87
|
|
79
88
|
def to_json(self, run_or_artifact: Union["LocalRun", "Artifact"]) -> dict:
|
89
|
+
"""Convert the Plotly object to a JSON representation.
|
90
|
+
|
91
|
+
<!-- lazydoc-ignore: internal -->
|
92
|
+
"""
|
80
93
|
json_dict = super().to_json(run_or_artifact)
|
81
94
|
json_dict["_type"] = self._log_type
|
82
95
|
return json_dict
|
@@ -23,7 +23,6 @@ if TYPE_CHECKING:
|
|
23
23
|
from typing_extensions import Self
|
24
24
|
|
25
25
|
from wandb.sdk.artifacts.artifact import Artifact
|
26
|
-
from wandb.sdk.wandb_run import Run as LocalRun
|
27
26
|
|
28
27
|
|
29
28
|
DEBUG_MODE = False
|
@@ -137,15 +136,14 @@ class _SavedModel(WBValue, Generic[SavedModelObjType]):
|
|
137
136
|
# and specified adapter.
|
138
137
|
return cls(dl_path)
|
139
138
|
|
140
|
-
def to_json(self, run_or_artifact:
|
139
|
+
def to_json(self, run_or_artifact: wandb.Run | Artifact) -> dict:
|
141
140
|
# Unlike other data types, we do not allow adding to a Run directly. There is a
|
142
141
|
# bit of tech debt in the other data types which requires the input to `to_json`
|
143
142
|
# to accept a Run or Artifact. However, Run additions should be deprecated in the future.
|
144
143
|
# This check helps ensure we do not add to the debt.
|
145
|
-
|
146
|
-
|
147
|
-
if isinstance(run_or_artifact, Run):
|
144
|
+
if isinstance(run_or_artifact, wandb.Run):
|
148
145
|
raise TypeError("SavedModel cannot be added to run - must use artifact")
|
146
|
+
|
149
147
|
artifact = run_or_artifact
|
150
148
|
json_obj = {
|
151
149
|
"type": self._log_type,
|
@@ -257,9 +255,9 @@ class _SavedModel(WBValue, Generic[SavedModelObjType]):
|
|
257
255
|
self._model_obj = None
|
258
256
|
|
259
257
|
def _set_obj(self, model_obj: Any) -> None:
|
260
|
-
assert model_obj is not None and self._validate_obj(
|
261
|
-
model_obj
|
262
|
-
)
|
258
|
+
assert model_obj is not None and self._validate_obj(model_obj), (
|
259
|
+
f"Invalid model object {model_obj}"
|
260
|
+
)
|
263
261
|
self._model_obj = model_obj
|
264
262
|
|
265
263
|
def _dump(self, target_path: str) -> None:
|
@@ -329,7 +327,7 @@ class _PicklingSavedModel(_SavedModel[SavedModelObjType]):
|
|
329
327
|
|
330
328
|
return inst # type: ignore
|
331
329
|
|
332
|
-
def to_json(self, run_or_artifact:
|
330
|
+
def to_json(self, run_or_artifact: wandb.Run | Artifact) -> dict:
|
333
331
|
json_obj = super().to_json(run_or_artifact)
|
334
332
|
assert isinstance(run_or_artifact, wandb.Artifact)
|
335
333
|
if self._dep_py_files_path is not None:
|