wandb 0.21.0__py3-none-macosx_11_0_arm64.whl → 0.21.1__py3-none-macosx_11_0_arm64.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 +427 -450
- wandb/agents/pyagent.py +41 -12
- wandb/analytics/sentry.py +7 -2
- wandb/apis/importers/mlflow.py +1 -1
- wandb/apis/public/__init__.py +1 -1
- wandb/apis/public/api.py +526 -360
- wandb/apis/public/artifacts.py +204 -8
- wandb/apis/public/automations.py +19 -3
- wandb/apis/public/files.py +172 -33
- 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 +130 -79
- wandb/apis/public/query_generator.py +11 -1
- wandb/apis/public/registries/registries_search.py +7 -15
- wandb/apis/public/reports.py +83 -5
- wandb/apis/public/runs.py +299 -105
- wandb/apis/public/sweeps.py +222 -22
- wandb/apis/public/teams.py +41 -4
- wandb/apis/public/users.py +45 -4
- wandb/beta/workflows.py +66 -30
- wandb/bin/gpu_stats +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/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/jupyter.py +5 -5
- wandb/plot/custom_chart.py +30 -7
- wandb/proto/v3/wandb_internal_pb2.py +280 -280
- wandb/proto/v3/wandb_telemetry_pb2.py +4 -4
- wandb/proto/v4/wandb_internal_pb2.py +280 -280
- wandb/proto/v4/wandb_telemetry_pb2.py +4 -4
- wandb/proto/v5/wandb_internal_pb2.py +280 -280
- wandb/proto/v5/wandb_telemetry_pb2.py +4 -4
- wandb/proto/v6/wandb_internal_pb2.py +280 -280
- wandb/proto/v6/wandb_telemetry_pb2.py +4 -4
- wandb/proto/wandb_deprecated.py +6 -0
- wandb/sdk/artifacts/_internal_artifact.py +19 -8
- wandb/sdk/artifacts/_validators.py +8 -0
- wandb/sdk/artifacts/artifact.py +106 -75
- wandb/sdk/data_types/audio.py +38 -10
- wandb/sdk/data_types/base_types/media.py +6 -56
- 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 +4 -6
- wandb/sdk/data_types/table.py +59 -30
- wandb/sdk/data_types/video.py +53 -26
- wandb/sdk/integration_utils/auto_logging.py +2 -2
- wandb/sdk/internal/internal_api.py +6 -0
- wandb/sdk/internal/job_builder.py +6 -0
- wandb/sdk/launch/agent/agent.py +8 -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/lib/asyncio_compat.py +3 -0
- 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 +66 -91
- wandb/sdk/wandb_login.py +18 -14
- wandb/sdk/wandb_metric.py +2 -0
- wandb/sdk/wandb_run.py +406 -414
- wandb/sdk/wandb_settings.py +130 -2
- 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.21.0.dist-info → wandb-0.21.1.dist-info}/METADATA +1 -1
- {wandb-0.21.0.dist-info → wandb-0.21.1.dist-info}/RECORD +95 -95
- wandb/vendor/pynvml/__init__.py +0 -0
- wandb/vendor/pynvml/pynvml.py +0 -4779
- {wandb-0.21.0.dist-info → wandb-0.21.1.dist-info}/WHEEL +0 -0
- {wandb-0.21.0.dist-info → wandb-0.21.1.dist-info}/entry_points.txt +0 -0
- {wandb-0.21.0.dist-info → wandb-0.21.1.dist-info}/licenses/LICENSE +0 -0
wandb/apis/public/api.py
CHANGED
@@ -51,6 +51,7 @@ from wandb.apis.public.utils import (
|
|
51
51
|
)
|
52
52
|
from wandb.proto.wandb_deprecated import Deprecated
|
53
53
|
from wandb.proto.wandb_internal_pb2 import ServerFeature
|
54
|
+
from wandb.sdk import wandb_login
|
54
55
|
from wandb.sdk.artifacts._validators import is_artifact_registry_project
|
55
56
|
from wandb.sdk.internal.internal_api import Api as InternalApi
|
56
57
|
from wandb.sdk.internal.thread_local_settings import _thread_local_api_settings
|
@@ -75,6 +76,11 @@ logger = logging.getLogger(__name__)
|
|
75
76
|
|
76
77
|
|
77
78
|
class RetryingClient:
|
79
|
+
"""A GraphQL client that retries requests on failure.
|
80
|
+
|
81
|
+
<!-- lazydoc-ignore-class: internal -->
|
82
|
+
"""
|
83
|
+
|
78
84
|
INFO_QUERY = gql(
|
79
85
|
"""
|
80
86
|
query ServerInfo{
|
@@ -135,16 +141,14 @@ class RetryingClient:
|
|
135
141
|
|
136
142
|
|
137
143
|
class Api:
|
138
|
-
"""Used for querying the
|
144
|
+
"""Used for querying the W&B server.
|
139
145
|
|
140
146
|
Examples:
|
141
|
-
|
142
|
-
|
147
|
+
```python
|
148
|
+
import wandb
|
143
149
|
|
144
|
-
|
145
|
-
|
146
|
-
other than https://api.wandb.ai.
|
147
|
-
You can also set defaults for `entity`, `project`, and `run`.
|
150
|
+
wandb.Api()
|
151
|
+
```
|
148
152
|
"""
|
149
153
|
|
150
154
|
_HTTP_TIMEOUT = env.get_http_timeout(19)
|
@@ -275,6 +279,17 @@ class Api:
|
|
275
279
|
timeout: Optional[int] = None,
|
276
280
|
api_key: Optional[str] = None,
|
277
281
|
) -> None:
|
282
|
+
"""Initialize the API.
|
283
|
+
|
284
|
+
Args:
|
285
|
+
overrides: You can set `base_url` if you are
|
286
|
+
using a W&B server other than `https://api.wandb.ai`. You can also
|
287
|
+
set defaults for `entity`, `project`, and `run`.
|
288
|
+
timeout: HTTP timeout in seconds for API requests. If not
|
289
|
+
specified, the default timeout will be used.
|
290
|
+
api_key: API key to use for authentication. If not provided,
|
291
|
+
the API key from the current environment or configuration will be used.
|
292
|
+
"""
|
278
293
|
self.settings = InternalApi().settings()
|
279
294
|
|
280
295
|
_overrides = overrides or {}
|
@@ -289,8 +304,18 @@ class Api:
|
|
289
304
|
self.settings["entity"] = _overrides["username"]
|
290
305
|
|
291
306
|
self._api_key = api_key
|
292
|
-
if
|
293
|
-
|
307
|
+
if _thread_local_api_settings.cookies is None:
|
308
|
+
wandb_login._login(
|
309
|
+
host=self.settings["base_url"],
|
310
|
+
key=self.api_key,
|
311
|
+
verify=True,
|
312
|
+
_silent=(
|
313
|
+
self.settings.get("silent", False)
|
314
|
+
or self.settings.get("quiet", False)
|
315
|
+
),
|
316
|
+
update_api_key=False,
|
317
|
+
_disable_warning=True,
|
318
|
+
)
|
294
319
|
|
295
320
|
self._viewer = None
|
296
321
|
self._projects = {}
|
@@ -323,13 +348,32 @@ class Api:
|
|
323
348
|
)
|
324
349
|
)
|
325
350
|
self._client = RetryingClient(self._base_client)
|
351
|
+
self._sentry = wandb.analytics.sentry.Sentry()
|
352
|
+
self._configure_sentry()
|
353
|
+
|
354
|
+
def _configure_sentry(self) -> None:
|
355
|
+
try:
|
356
|
+
viewer = self.viewer
|
357
|
+
except (ValueError, requests.RequestException):
|
358
|
+
# we need the viewer to configure the entity, and user email
|
359
|
+
return
|
360
|
+
|
361
|
+
email = viewer.email if viewer else None
|
362
|
+
entity = self.default_entity
|
363
|
+
|
364
|
+
self._sentry.configure_scope(
|
365
|
+
tags={
|
366
|
+
"entity": entity,
|
367
|
+
"email": email,
|
368
|
+
},
|
369
|
+
)
|
326
370
|
|
327
371
|
def create_project(self, name: str, entity: str) -> None:
|
328
372
|
"""Create a new project.
|
329
373
|
|
330
374
|
Args:
|
331
|
-
name:
|
332
|
-
entity:
|
375
|
+
name: The name of the new project.
|
376
|
+
entity: The entity of the new project.
|
333
377
|
"""
|
334
378
|
self.client.execute(self.CREATE_PROJECT, {"entityName": entity, "name": name})
|
335
379
|
|
@@ -343,10 +387,12 @@ class Api:
|
|
343
387
|
"""Create a new run.
|
344
388
|
|
345
389
|
Args:
|
346
|
-
run_id:
|
347
|
-
|
348
|
-
project:
|
349
|
-
|
390
|
+
run_id: The ID to assign to the run. If not specified, W&B
|
391
|
+
creates a random ID.
|
392
|
+
project: The project where to log the run to. If no project is specified,
|
393
|
+
log the run to a project called "Uncategorized".
|
394
|
+
entity: The entity that owns the project. If no entity is
|
395
|
+
specified, log the run to the default entity.
|
350
396
|
|
351
397
|
Returns:
|
352
398
|
The newly created `Run`.
|
@@ -364,33 +410,28 @@ class Api:
|
|
364
410
|
config: Optional[dict] = None,
|
365
411
|
template_variables: Optional[dict] = None,
|
366
412
|
) -> "public.RunQueue":
|
367
|
-
"""Create a new run queue
|
413
|
+
"""Create a new run queue in W&B Launch.
|
368
414
|
|
369
415
|
Args:
|
370
|
-
name:
|
371
|
-
type:
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
"maximum": (optional maximum),
|
383
|
-
"enum": [..."(options)"]
|
384
|
-
}
|
385
|
-
}
|
386
|
-
}`
|
416
|
+
name: Name of the queue to create
|
417
|
+
type: Type of resource to be used for the queue. One of
|
418
|
+
"local-container", "local-process", "kubernetes","sagemaker",
|
419
|
+
or "gcp-vertex".
|
420
|
+
entity: Name of the entity to create the queue. If `None`, use
|
421
|
+
the configured or default entity.
|
422
|
+
prioritization_mode: Version of prioritization to use.
|
423
|
+
Either "V0" or `None`.
|
424
|
+
config: Default resource configuration to be used for the queue.
|
425
|
+
Use handlebars (eg. `{{var}}`) to specify template variables.
|
426
|
+
template_variables: A dictionary of template variable schemas to
|
427
|
+
use with the config.
|
387
428
|
|
388
429
|
Returns:
|
389
|
-
The newly created `RunQueue
|
430
|
+
The newly created `RunQueue`.
|
390
431
|
|
391
432
|
Raises:
|
392
|
-
ValueError if any of the parameters are invalid
|
393
|
-
wandb.Error on wandb API errors
|
433
|
+
`ValueError` if any of the parameters are invalid
|
434
|
+
`wandb.Error` on wandb API errors
|
394
435
|
"""
|
395
436
|
# TODO(np): Need to check server capabilities for this feature
|
396
437
|
# 0. assert params are valid/normalized
|
@@ -556,30 +597,24 @@ class Api:
|
|
556
597
|
external_links: Optional[dict] = None,
|
557
598
|
prioritization_mode: Optional["public.RunQueuePrioritizationMode"] = None,
|
558
599
|
):
|
559
|
-
"""Upsert a run queue
|
600
|
+
"""Upsert a run queue in W&B Launch.
|
560
601
|
|
561
602
|
Args:
|
562
|
-
name:
|
563
|
-
entity:
|
564
|
-
|
565
|
-
|
566
|
-
|
567
|
-
|
568
|
-
|
569
|
-
|
570
|
-
|
571
|
-
|
572
|
-
|
573
|
-
|
574
|
-
|
575
|
-
|
576
|
-
|
577
|
-
}`
|
578
|
-
external_links: (dict) Optional dictionary of external links to be used with the queue. Expected format of:
|
579
|
-
`{
|
580
|
-
"name": "url"
|
581
|
-
}`
|
582
|
-
prioritization_mode: (str) Optional version of prioritization to use. Either "V0" or None
|
603
|
+
name: Name of the queue to create
|
604
|
+
entity: Optional name of the entity to create the queue. If `None`,
|
605
|
+
use the configured or default entity.
|
606
|
+
resource_config: Optional default resource configuration to be used
|
607
|
+
for the queue. Use handlebars (eg. `{{var}}`) to specify
|
608
|
+
template variables.
|
609
|
+
resource_type: Type of resource to be used for the queue. One of
|
610
|
+
"local-container", "local-process", "kubernetes", "sagemaker",
|
611
|
+
or "gcp-vertex".
|
612
|
+
template_variables: A dictionary of template variable schemas to
|
613
|
+
be used with the config.
|
614
|
+
external_links: Optional dictionary of external links to be used
|
615
|
+
with the queue.
|
616
|
+
prioritization_mode: Optional version of prioritization to use.
|
617
|
+
Either "V0" or None
|
583
618
|
|
584
619
|
Returns:
|
585
620
|
The upserted `RunQueue`.
|
@@ -661,15 +696,15 @@ class Api:
|
|
661
696
|
entity=entity,
|
662
697
|
)
|
663
698
|
|
664
|
-
def create_user(self, email, admin=False):
|
699
|
+
def create_user(self, email: str, admin: Optional[bool] = False):
|
665
700
|
"""Create a new user.
|
666
701
|
|
667
702
|
Args:
|
668
|
-
email:
|
669
|
-
admin:
|
703
|
+
email: The email address of the user.
|
704
|
+
admin: Set user as a global instance administrator.
|
670
705
|
|
671
706
|
Returns:
|
672
|
-
A `User` object
|
707
|
+
A `User` object.
|
673
708
|
"""
|
674
709
|
return public.User.create(self, email, admin)
|
675
710
|
|
@@ -699,14 +734,17 @@ class Api:
|
|
699
734
|
|
700
735
|
@property
|
701
736
|
def client(self) -> RetryingClient:
|
737
|
+
"""Returns the client object."""
|
702
738
|
return self._client
|
703
739
|
|
704
740
|
@property
|
705
741
|
def user_agent(self) -> str:
|
742
|
+
"""Returns W&B public user agent."""
|
706
743
|
return "W&B Public Client {}".format(wandb.__version__)
|
707
744
|
|
708
745
|
@property
|
709
746
|
def api_key(self) -> Optional[str]:
|
747
|
+
"""Returns W&B API key."""
|
710
748
|
# just use thread local api key if it's set
|
711
749
|
if _thread_local_api_settings.api_key:
|
712
750
|
return _thread_local_api_settings.api_key
|
@@ -724,6 +762,7 @@ class Api:
|
|
724
762
|
|
725
763
|
@property
|
726
764
|
def default_entity(self) -> Optional[str]:
|
765
|
+
"""Returns the default W&B entity."""
|
727
766
|
if self._default_entity is None:
|
728
767
|
res = self._client.execute(self.DEFAULT_ENTITY_QUERY)
|
729
768
|
self._default_entity = (res.get("viewer") or {}).get("entity")
|
@@ -731,42 +770,62 @@ class Api:
|
|
731
770
|
|
732
771
|
@property
|
733
772
|
def viewer(self) -> "public.User":
|
773
|
+
"""Returns the viewer object.
|
774
|
+
|
775
|
+
Raises:
|
776
|
+
ValueError: If viewer data is not able to be fetched from W&B.
|
777
|
+
requests.RequestException: If an error occurs while making the graphql request.
|
778
|
+
"""
|
734
779
|
if self._viewer is None:
|
735
|
-
|
736
|
-
|
737
|
-
|
780
|
+
viewer = self._client.execute(self.VIEWER_QUERY).get("viewer")
|
781
|
+
|
782
|
+
if viewer is None:
|
783
|
+
raise ValueError(
|
784
|
+
"Unable to fetch user data from W&B,"
|
785
|
+
" please verify your API key is valid."
|
786
|
+
)
|
787
|
+
|
788
|
+
self._viewer = public.User(self._client, viewer)
|
738
789
|
self._default_entity = self._viewer.entity
|
739
790
|
return self._viewer
|
740
791
|
|
741
792
|
def flush(self):
|
742
793
|
"""Flush the local cache.
|
743
794
|
|
744
|
-
The api object keeps a local cache of runs, so if the state of the run
|
745
|
-
change while executing your script you must clear the local cache
|
746
|
-
`api.flush()` to get the latest values associated with the run.
|
795
|
+
The api object keeps a local cache of runs, so if the state of the run
|
796
|
+
may change while executing your script you must clear the local cache
|
797
|
+
with `api.flush()` to get the latest values associated with the run.
|
747
798
|
"""
|
748
799
|
self._runs = {}
|
749
800
|
|
750
|
-
def from_path(self, path):
|
801
|
+
def from_path(self, path: str):
|
751
802
|
"""Return a run, sweep, project or report from a path.
|
752
803
|
|
753
|
-
Examples:
|
754
|
-
```
|
755
|
-
project = api.from_path("my_project")
|
756
|
-
team_project = api.from_path("my_team/my_project")
|
757
|
-
run = api.from_path("my_team/my_project/runs/id")
|
758
|
-
sweep = api.from_path("my_team/my_project/sweeps/id")
|
759
|
-
report = api.from_path("my_team/my_project/reports/My-Report-Vm11dsdf")
|
760
|
-
```
|
761
|
-
|
762
804
|
Args:
|
763
|
-
path:
|
805
|
+
path: The path to the project, run, sweep or report
|
764
806
|
|
765
807
|
Returns:
|
766
808
|
A `Project`, `Run`, `Sweep`, or `BetaReport` instance.
|
767
809
|
|
768
810
|
Raises:
|
769
|
-
wandb.Error if path is invalid or the object doesn't exist
|
811
|
+
`wandb.Error` if path is invalid or the object doesn't exist.
|
812
|
+
|
813
|
+
Examples:
|
814
|
+
In the proceeding code snippets "project", "team", "run_id", "sweep_id",
|
815
|
+
and "report_name" are placeholders for the project, team, run ID,
|
816
|
+
sweep ID, and the name of a specific report, respectively.
|
817
|
+
|
818
|
+
```python
|
819
|
+
import wandb
|
820
|
+
|
821
|
+
api = wandb.Api()
|
822
|
+
|
823
|
+
project = api.from_path("project")
|
824
|
+
team_project = api.from_path("team/project")
|
825
|
+
run = api.from_path("team/project/runs/run_id")
|
826
|
+
sweep = api.from_path("team/project/sweeps/sweep_id")
|
827
|
+
report = api.from_path("team/project/reports/report_name")
|
828
|
+
```
|
770
829
|
"""
|
771
830
|
parts = path.strip("/ ").split("/")
|
772
831
|
if len(parts) == 1:
|
@@ -874,12 +933,14 @@ class Api:
|
|
874
933
|
"""Get projects for a given entity.
|
875
934
|
|
876
935
|
Args:
|
877
|
-
entity:
|
878
|
-
default entity passed to `Api`. If no default entity,
|
879
|
-
|
936
|
+
entity: Name of the entity requested. If None, will fall back to
|
937
|
+
the default entity passed to `Api`. If no default entity,
|
938
|
+
will raise a `ValueError`.
|
939
|
+
per_page: Sets the page size for query pagination. If set to `None`,
|
940
|
+
use the default size. Usually there is no reason to change this.
|
880
941
|
|
881
942
|
Returns:
|
882
|
-
A `Projects` object which is an iterable collection of `Project`
|
943
|
+
A `Projects` object which is an iterable collection of `Project`objects.
|
883
944
|
"""
|
884
945
|
if entity is None:
|
885
946
|
entity = self.settings["entity"] or self.default_entity
|
@@ -897,9 +958,10 @@ class Api:
|
|
897
958
|
"""Return the `Project` with the given name (and entity, if given).
|
898
959
|
|
899
960
|
Args:
|
900
|
-
name:
|
901
|
-
entity:
|
902
|
-
default entity passed to `Api`. If no default entity, will
|
961
|
+
name: The project name.
|
962
|
+
entity: Name of the entity requested. If None, will fall back to the
|
963
|
+
default entity passed to `Api`. If no default entity, will
|
964
|
+
raise a `ValueError`.
|
903
965
|
|
904
966
|
Returns:
|
905
967
|
A `Project` object.
|
@@ -923,15 +985,29 @@ class Api:
|
|
923
985
|
) -> "public.Reports":
|
924
986
|
"""Get reports for a given project path.
|
925
987
|
|
926
|
-
|
988
|
+
Note: `wandb.Api.reports()` API is in beta and will likely change in
|
989
|
+
future releases.
|
927
990
|
|
928
991
|
Args:
|
929
|
-
path:
|
930
|
-
|
931
|
-
|
992
|
+
path: The path to project the report resides in. Specify the
|
993
|
+
entity that created the project as a prefix followed by a
|
994
|
+
forward slash.
|
995
|
+
name: Name of the report requested.
|
996
|
+
per_page: Sets the page size for query pagination. If set to
|
997
|
+
`None`, use the default size. Usually there is no reason to
|
998
|
+
change this.
|
932
999
|
|
933
1000
|
Returns:
|
934
|
-
A `Reports` object which is an iterable collection of
|
1001
|
+
A `Reports` object which is an iterable collection of
|
1002
|
+
`BetaReport` objects.
|
1003
|
+
|
1004
|
+
Examples:
|
1005
|
+
```python
|
1006
|
+
import wandb
|
1007
|
+
|
1008
|
+
wandb.Api.reports("entity/project")
|
1009
|
+
```
|
1010
|
+
|
935
1011
|
"""
|
936
1012
|
entity, project, _ = self._parse_path(path + "/fake_run")
|
937
1013
|
|
@@ -950,15 +1026,18 @@ class Api:
|
|
950
1026
|
)
|
951
1027
|
return self._reports[key]
|
952
1028
|
|
953
|
-
def create_team(
|
1029
|
+
def create_team(
|
1030
|
+
self, team: str, admin_username: Optional[str] = None
|
1031
|
+
) -> "public.Team":
|
954
1032
|
"""Create a new team.
|
955
1033
|
|
956
1034
|
Args:
|
957
|
-
team:
|
958
|
-
admin_username:
|
1035
|
+
team: The name of the team
|
1036
|
+
admin_username: Username of the admin user of the team.
|
1037
|
+
Defaults to the current user.
|
959
1038
|
|
960
1039
|
Returns:
|
961
|
-
A `Team` object
|
1040
|
+
A `Team` object.
|
962
1041
|
"""
|
963
1042
|
return public.Team.create(self, team, admin_username)
|
964
1043
|
|
@@ -966,7 +1045,7 @@ class Api:
|
|
966
1045
|
"""Return the matching `Team` with the given name.
|
967
1046
|
|
968
1047
|
Args:
|
969
|
-
team:
|
1048
|
+
team: The name of the team.
|
970
1049
|
|
971
1050
|
Returns:
|
972
1051
|
A `Team` object.
|
@@ -976,13 +1055,14 @@ class Api:
|
|
976
1055
|
def user(self, username_or_email: str) -> Optional["public.User"]:
|
977
1056
|
"""Return a user from a username or email address.
|
978
1057
|
|
979
|
-
|
1058
|
+
This function only works for local administrators. Use `api.viewer`
|
1059
|
+
to get your own user object.
|
980
1060
|
|
981
1061
|
Args:
|
982
|
-
username_or_email:
|
1062
|
+
username_or_email: The username or email address of the user.
|
983
1063
|
|
984
1064
|
Returns:
|
985
|
-
A `User` object or None if a user
|
1065
|
+
A `User` object or None if a user is not found.
|
986
1066
|
"""
|
987
1067
|
res = self._client.execute(self.USERS_QUERY, {"query": username_or_email})
|
988
1068
|
if len(res["users"]["edges"]) == 0:
|
@@ -998,13 +1078,14 @@ class Api:
|
|
998
1078
|
def users(self, username_or_email: str) -> List["public.User"]:
|
999
1079
|
"""Return all users from a partial username or email address query.
|
1000
1080
|
|
1001
|
-
|
1081
|
+
This function only works for local administrators. Use `api.viewer`
|
1082
|
+
to get your own user object.
|
1002
1083
|
|
1003
1084
|
Args:
|
1004
|
-
username_or_email:
|
1085
|
+
username_or_email: The prefix or suffix of the user you want to find.
|
1005
1086
|
|
1006
1087
|
Returns:
|
1007
|
-
An array of `User` objects
|
1088
|
+
An array of `User` objects.
|
1008
1089
|
"""
|
1009
1090
|
res = self._client.execute(self.USERS_QUERY, {"query": username_or_email})
|
1010
1091
|
return [
|
@@ -1019,7 +1100,7 @@ class Api:
|
|
1019
1100
|
per_page: int = 50,
|
1020
1101
|
include_sweeps: bool = True,
|
1021
1102
|
):
|
1022
|
-
"""
|
1103
|
+
"""Returns a `Runs` object, which lazily iterates over `Run` objects.
|
1023
1104
|
|
1024
1105
|
Fields you can filter by include:
|
1025
1106
|
- `createdAt`: The timestamp when the run was created. (in ISO 8601 format, e.g. "2023-01-01T12:00:00Z")
|
@@ -1054,64 +1135,6 @@ class Api:
|
|
1054
1135
|
- `$regex`
|
1055
1136
|
|
1056
1137
|
|
1057
|
-
Examples:
|
1058
|
-
Find runs in my_project where config.experiment_name has been set to "foo"
|
1059
|
-
```
|
1060
|
-
api.runs(
|
1061
|
-
path="my_entity/my_project",
|
1062
|
-
filters={"config.experiment_name": "foo"},
|
1063
|
-
)
|
1064
|
-
```
|
1065
|
-
|
1066
|
-
Find runs in my_project where config.experiment_name has been set to "foo" or "bar"
|
1067
|
-
```
|
1068
|
-
api.runs(
|
1069
|
-
path="my_entity/my_project",
|
1070
|
-
filters={
|
1071
|
-
"$or": [
|
1072
|
-
{"config.experiment_name": "foo"},
|
1073
|
-
{"config.experiment_name": "bar"},
|
1074
|
-
]
|
1075
|
-
},
|
1076
|
-
)
|
1077
|
-
```
|
1078
|
-
|
1079
|
-
Find runs in my_project where config.experiment_name matches a regex (anchors are not supported)
|
1080
|
-
```
|
1081
|
-
api.runs(
|
1082
|
-
path="my_entity/my_project",
|
1083
|
-
filters={"config.experiment_name": {"$regex": "b.*"}},
|
1084
|
-
)
|
1085
|
-
```
|
1086
|
-
|
1087
|
-
Find runs in my_project where the run name matches a regex (anchors are not supported)
|
1088
|
-
```
|
1089
|
-
api.runs(
|
1090
|
-
path="my_entity/my_project",
|
1091
|
-
filters={"display_name": {"$regex": "^foo.*"}},
|
1092
|
-
)
|
1093
|
-
```
|
1094
|
-
|
1095
|
-
Find runs in my_project where config.experiment contains a nested field "category" with value "testing"
|
1096
|
-
```
|
1097
|
-
api.runs(
|
1098
|
-
path="my_entity/my_project",
|
1099
|
-
filters={"config.experiment.category": "testing"},
|
1100
|
-
)
|
1101
|
-
```
|
1102
|
-
|
1103
|
-
Find runs in my_project with a loss value of 0.5 nested in a dictionary under model1 in the summary metrics
|
1104
|
-
```
|
1105
|
-
api.runs(
|
1106
|
-
path="my_entity/my_project",
|
1107
|
-
filters={"summary_metrics.model1.loss": 0.5},
|
1108
|
-
)
|
1109
|
-
```
|
1110
|
-
|
1111
|
-
Find runs in my_project sorted by ascending loss
|
1112
|
-
```
|
1113
|
-
api.runs(path="my_entity/my_project", order="+summary_metrics.loss")
|
1114
|
-
```
|
1115
1138
|
|
1116
1139
|
Args:
|
1117
1140
|
path: (str) path to project, should be in the form: "entity/project"
|
@@ -1120,14 +1143,55 @@ class Api:
|
|
1120
1143
|
For example: `{"config.experiment_name": "foo"}` would find runs with a config entry
|
1121
1144
|
of experiment name set to "foo"
|
1122
1145
|
order: (str) Order can be `created_at`, `heartbeat_at`, `config.*.value`, or `summary_metrics.*`.
|
1123
|
-
If you prepend order with a + order is ascending.
|
1124
|
-
If you prepend order with a - order is descending
|
1146
|
+
If you prepend order with a + order is ascending (default).
|
1147
|
+
If you prepend order with a - order is descending.
|
1125
1148
|
The default order is run.created_at from oldest to newest.
|
1126
1149
|
per_page: (int) Sets the page size for query pagination.
|
1127
1150
|
include_sweeps: (bool) Whether to include the sweep runs in the results.
|
1128
1151
|
|
1129
1152
|
Returns:
|
1130
1153
|
A `Runs` object, which is an iterable collection of `Run` objects.
|
1154
|
+
|
1155
|
+
Examples:
|
1156
|
+
```python
|
1157
|
+
# Find runs in project where config.experiment_name has been set to "foo"
|
1158
|
+
api.runs(path="my_entity/project", filters={"config.experiment_name": "foo"})
|
1159
|
+
```
|
1160
|
+
|
1161
|
+
```python
|
1162
|
+
# Find runs in project where config.experiment_name has been set to "foo" or "bar"
|
1163
|
+
api.runs(
|
1164
|
+
path="my_entity/project",
|
1165
|
+
filters={
|
1166
|
+
"$or": [
|
1167
|
+
{"config.experiment_name": "foo"},
|
1168
|
+
{"config.experiment_name": "bar"},
|
1169
|
+
]
|
1170
|
+
},
|
1171
|
+
)
|
1172
|
+
```
|
1173
|
+
|
1174
|
+
```python
|
1175
|
+
# Find runs in project where config.experiment_name matches a regex
|
1176
|
+
# (anchors are not supported)
|
1177
|
+
api.runs(
|
1178
|
+
path="my_entity/project",
|
1179
|
+
filters={"config.experiment_name": {"$regex": "b.*"}},
|
1180
|
+
)
|
1181
|
+
```
|
1182
|
+
|
1183
|
+
```python
|
1184
|
+
# Find runs in project where the run name matches a regex
|
1185
|
+
# (anchors are not supported)
|
1186
|
+
api.runs(
|
1187
|
+
path="my_entity/project", filters={"display_name": {"$regex": "^foo.*"}}
|
1188
|
+
)
|
1189
|
+
```
|
1190
|
+
|
1191
|
+
```python
|
1192
|
+
# Find runs in project sorted by ascending loss
|
1193
|
+
api.runs(path="my_entity/project", order="+summary_metrics.loss")
|
1194
|
+
```
|
1131
1195
|
"""
|
1132
1196
|
entity, project = self._parse_project_path(path)
|
1133
1197
|
filters = filters or {}
|
@@ -1146,10 +1210,10 @@ class Api:
|
|
1146
1210
|
|
1147
1211
|
@normalize_exceptions
|
1148
1212
|
def run(self, path=""):
|
1149
|
-
"""Return a single run by parsing path in the form entity/project/run_id
|
1213
|
+
"""Return a single run by parsing path in the form `entity/project/run_id`.
|
1150
1214
|
|
1151
1215
|
Args:
|
1152
|
-
path:
|
1216
|
+
path: Path to run in the form `entity/project/run_id`.
|
1153
1217
|
If `api.entity` is set, this can be in the form `project/run_id`
|
1154
1218
|
and if `api.project` is set this can just be the run_id.
|
1155
1219
|
|
@@ -1163,16 +1227,16 @@ class Api:
|
|
1163
1227
|
|
1164
1228
|
def queued_run(
|
1165
1229
|
self,
|
1166
|
-
entity,
|
1167
|
-
project,
|
1168
|
-
queue_name,
|
1169
|
-
run_queue_item_id,
|
1230
|
+
entity: str,
|
1231
|
+
project: str,
|
1232
|
+
queue_name: str,
|
1233
|
+
run_queue_item_id: str,
|
1170
1234
|
project_queue=None,
|
1171
1235
|
priority=None,
|
1172
1236
|
):
|
1173
1237
|
"""Return a single queued run based on the path.
|
1174
1238
|
|
1175
|
-
Parses paths of the form entity/project/queue_id/run_queue_item_id
|
1239
|
+
Parses paths of the form `entity/project/queue_id/run_queue_item_id`.
|
1176
1240
|
"""
|
1177
1241
|
return public.QueuedRun(
|
1178
1242
|
self.client,
|
@@ -1186,12 +1250,12 @@ class Api:
|
|
1186
1250
|
|
1187
1251
|
def run_queue(
|
1188
1252
|
self,
|
1189
|
-
entity,
|
1190
|
-
name,
|
1253
|
+
entity: str,
|
1254
|
+
name: str,
|
1191
1255
|
):
|
1192
1256
|
"""Return the named `RunQueue` for entity.
|
1193
1257
|
|
1194
|
-
|
1258
|
+
See `Api.create_run_queue` for more information on how to create a run queue.
|
1195
1259
|
"""
|
1196
1260
|
return public.RunQueue(
|
1197
1261
|
self.client,
|
@@ -1204,8 +1268,9 @@ class Api:
|
|
1204
1268
|
"""Return a sweep by parsing path in the form `entity/project/sweep_id`.
|
1205
1269
|
|
1206
1270
|
Args:
|
1207
|
-
path:
|
1208
|
-
is set, this can be in the form
|
1271
|
+
path: Path to sweep in the form entity/project/sweep_id.
|
1272
|
+
If `api.entity` is set, this can be in the form
|
1273
|
+
project/sweep_id and if `api.project` is set
|
1209
1274
|
this can just be the sweep_id.
|
1210
1275
|
|
1211
1276
|
Returns:
|
@@ -1218,10 +1283,10 @@ class Api:
|
|
1218
1283
|
|
1219
1284
|
@normalize_exceptions
|
1220
1285
|
def artifact_types(self, project: Optional[str] = None) -> "public.ArtifactTypes":
|
1221
|
-
"""
|
1286
|
+
"""Returns a collection of matching artifact types.
|
1222
1287
|
|
1223
1288
|
Args:
|
1224
|
-
project:
|
1289
|
+
project: The project name or path to filter on.
|
1225
1290
|
|
1226
1291
|
Returns:
|
1227
1292
|
An iterable `ArtifactTypes` object.
|
@@ -1241,11 +1306,11 @@ class Api:
|
|
1241
1306
|
def artifact_type(
|
1242
1307
|
self, type_name: str, project: Optional[str] = None
|
1243
1308
|
) -> "public.ArtifactType":
|
1244
|
-
"""
|
1309
|
+
"""Returns the matching `ArtifactType`.
|
1245
1310
|
|
1246
1311
|
Args:
|
1247
|
-
type_name:
|
1248
|
-
project:
|
1312
|
+
type_name: The name of the artifact type to retrieve.
|
1313
|
+
project: If given, a project name or path to filter on.
|
1249
1314
|
|
1250
1315
|
Returns:
|
1251
1316
|
An `ArtifactType` object.
|
@@ -1265,12 +1330,13 @@ class Api:
|
|
1265
1330
|
def artifact_collections(
|
1266
1331
|
self, project_name: str, type_name: str, per_page: int = 50
|
1267
1332
|
) -> "public.ArtifactCollections":
|
1268
|
-
"""
|
1333
|
+
"""Returns a collection of matching artifact collections.
|
1269
1334
|
|
1270
1335
|
Args:
|
1271
|
-
project_name:
|
1272
|
-
type_name:
|
1273
|
-
per_page:
|
1336
|
+
project_name: The name of the project to filter on.
|
1337
|
+
type_name: The name of the artifact type to filter on.
|
1338
|
+
per_page: Sets the page size for query pagination. None will use the default size.
|
1339
|
+
Usually there is no reason to change this.
|
1274
1340
|
|
1275
1341
|
Returns:
|
1276
1342
|
An iterable `ArtifactCollections` object.
|
@@ -1291,14 +1357,39 @@ class Api:
|
|
1291
1357
|
def artifact_collection(
|
1292
1358
|
self, type_name: str, name: str
|
1293
1359
|
) -> "public.ArtifactCollection":
|
1294
|
-
"""
|
1360
|
+
"""Returns a single artifact collection by type.
|
1361
|
+
|
1362
|
+
You can use the returned `ArtifactCollection` object to retrieve
|
1363
|
+
information about specific artifacts in that collection, and more.
|
1295
1364
|
|
1296
1365
|
Args:
|
1297
|
-
type_name:
|
1298
|
-
name:
|
1366
|
+
type_name: The type of artifact collection to fetch.
|
1367
|
+
name: An artifact collection name. Optionally append the entity
|
1368
|
+
that logged the artifact as a prefix followed by a forward
|
1369
|
+
slash.
|
1299
1370
|
|
1300
1371
|
Returns:
|
1301
1372
|
An `ArtifactCollection` object.
|
1373
|
+
|
1374
|
+
Examples:
|
1375
|
+
In the proceeding code snippet "type", "entity", "project", and
|
1376
|
+
"artifact_name" are placeholders for the collection type, your W&B
|
1377
|
+
entity, name of the project the artifact is in, and the name of
|
1378
|
+
the artifact, respectively.
|
1379
|
+
|
1380
|
+
```python
|
1381
|
+
import wandb
|
1382
|
+
|
1383
|
+
collections = wandb.Api().artifact_collection(
|
1384
|
+
type_name="type", name="entity/project/artifact_name"
|
1385
|
+
)
|
1386
|
+
|
1387
|
+
# Get the first artifact in the collection
|
1388
|
+
artifact_example = collections.artifacts()[0]
|
1389
|
+
|
1390
|
+
# Download the contents of the artifact to the specified root directory.
|
1391
|
+
artifact_example.download()
|
1392
|
+
```
|
1302
1393
|
"""
|
1303
1394
|
entity, project, collection_name = self._parse_artifact_path(name)
|
1304
1395
|
# If its an Registry artifact, the entity is considered to be an org instead
|
@@ -1320,7 +1411,7 @@ class Api:
|
|
1320
1411
|
|
1321
1412
|
@normalize_exceptions
|
1322
1413
|
def artifact_versions(self, type_name, name, per_page=50):
|
1323
|
-
"""Deprecated
|
1414
|
+
"""Deprecated. Use `Api.artifacts(type_name, name)` method instead."""
|
1324
1415
|
deprecate(
|
1325
1416
|
field_name=Deprecated.api__artifact_versions,
|
1326
1417
|
warning_message=(
|
@@ -1338,16 +1429,32 @@ class Api:
|
|
1338
1429
|
per_page: int = 50,
|
1339
1430
|
tags: Optional[List[str]] = None,
|
1340
1431
|
) -> "public.Artifacts":
|
1341
|
-
"""Return an `Artifacts` collection
|
1432
|
+
"""Return an `Artifacts` collection.
|
1342
1433
|
|
1343
1434
|
Args:
|
1344
|
-
|
1345
|
-
|
1346
|
-
|
1347
|
-
|
1435
|
+
type_name: The type of artifacts to fetch.
|
1436
|
+
name: The artifact's collection name. Optionally append the
|
1437
|
+
entity that logged the artifact as a prefix followed by
|
1438
|
+
a forward slash.
|
1439
|
+
per_page: Sets the page size for query pagination. If set to
|
1440
|
+
`None`, use the default size. Usually there is no reason
|
1441
|
+
to change this.
|
1442
|
+
tags: Only return artifacts with all of these tags.
|
1348
1443
|
|
1349
1444
|
Returns:
|
1350
1445
|
An iterable `Artifacts` object.
|
1446
|
+
|
1447
|
+
Examples:
|
1448
|
+
In the proceeding code snippet, "type", "entity", "project", and
|
1449
|
+
"artifact_name" are placeholders for the artifact type, W&B entity,
|
1450
|
+
name of the project the artifact was logged to,
|
1451
|
+
and the name of the artifact, respectively.
|
1452
|
+
|
1453
|
+
```python
|
1454
|
+
import wandb
|
1455
|
+
|
1456
|
+
wandb.Api().artifacts(type_name="type", name="entity/project/artifact_name")
|
1457
|
+
```
|
1351
1458
|
"""
|
1352
1459
|
entity, project, collection_name = self._parse_artifact_path(name)
|
1353
1460
|
# If its an Registry project, the entity is considered to be an org instead
|
@@ -1410,22 +1517,47 @@ class Api:
|
|
1410
1517
|
|
1411
1518
|
@normalize_exceptions
|
1412
1519
|
def artifact(self, name: str, type: Optional[str] = None):
|
1413
|
-
"""
|
1520
|
+
"""Returns a single artifact.
|
1414
1521
|
|
1415
1522
|
Args:
|
1416
|
-
name:
|
1417
|
-
|
1418
|
-
|
1419
|
-
|
1420
|
-
|
1421
|
-
|
1523
|
+
name: The artifact's name. The name of an artifact resembles a
|
1524
|
+
filepath that consists, at a minimum, the name of the project
|
1525
|
+
the artifact was logged to, the name of the artifact, and the
|
1526
|
+
artifact's version or alias. Optionally append the entity that
|
1527
|
+
logged the artifact as a prefix followed by a forward slash.
|
1528
|
+
If no entity is specified in the name, the Run or API
|
1529
|
+
setting's entity is used.
|
1530
|
+
type: The type of artifact to fetch.
|
1422
1531
|
|
1423
1532
|
Returns:
|
1424
1533
|
An `Artifact` object.
|
1425
1534
|
|
1426
1535
|
Raises:
|
1427
1536
|
ValueError: If the artifact name is not specified.
|
1428
|
-
ValueError: If the artifact type is specified but does not
|
1537
|
+
ValueError: If the artifact type is specified but does not
|
1538
|
+
match the type of the fetched artifact.
|
1539
|
+
|
1540
|
+
Examples:
|
1541
|
+
In the proceeding code snippets "entity", "project", "artifact",
|
1542
|
+
"version", and "alias" are placeholders for your W&B entity, name
|
1543
|
+
of the project the artifact is in, the name of the artifact,
|
1544
|
+
and artifact's version, respectively.
|
1545
|
+
|
1546
|
+
```python
|
1547
|
+
import wandb
|
1548
|
+
|
1549
|
+
# Specify the project, artifact's name, and the artifact's alias
|
1550
|
+
wandb.Api().artifact(name="project/artifact:alias")
|
1551
|
+
|
1552
|
+
# Specify the project, artifact's name, and a specific artifact version
|
1553
|
+
wandb.Api().artifact(name="project/artifact:version")
|
1554
|
+
|
1555
|
+
# Specify the entity, project, artifact's name, and the artifact's alias
|
1556
|
+
wandb.Api().artifact(name="entity/project/artifact:alias")
|
1557
|
+
|
1558
|
+
# Specify the entity, project, artifact's name, and a specific artifact version
|
1559
|
+
wandb.Api().artifact(name="entity/project/artifact:version")
|
1560
|
+
```
|
1429
1561
|
|
1430
1562
|
Note:
|
1431
1563
|
This method is intended for external use only. Do not call `api.artifact()` within the wandb repository code.
|
@@ -1434,11 +1566,11 @@ class Api:
|
|
1434
1566
|
|
1435
1567
|
@normalize_exceptions
|
1436
1568
|
def job(self, name: Optional[str], path: Optional[str] = None) -> "public.Job":
|
1437
|
-
"""Return a `Job`
|
1569
|
+
"""Return a `Job` object.
|
1438
1570
|
|
1439
1571
|
Args:
|
1440
|
-
name:
|
1441
|
-
path:
|
1572
|
+
name: The name of the job.
|
1573
|
+
path: The root path to download the job artifact.
|
1442
1574
|
|
1443
1575
|
Returns:
|
1444
1576
|
A `Job` object.
|
@@ -1456,8 +1588,8 @@ class Api:
|
|
1456
1588
|
"""Return a list of jobs, if any, for the given entity and project.
|
1457
1589
|
|
1458
1590
|
Args:
|
1459
|
-
entity:
|
1460
|
-
project:
|
1591
|
+
entity: The entity for the listed jobs.
|
1592
|
+
project: The project for the listed jobs.
|
1461
1593
|
|
1462
1594
|
Returns:
|
1463
1595
|
A list of matching jobs.
|
@@ -1531,19 +1663,33 @@ class Api:
|
|
1531
1663
|
|
1532
1664
|
@normalize_exceptions
|
1533
1665
|
def artifact_exists(self, name: str, type: Optional[str] = None) -> bool:
|
1534
|
-
"""
|
1666
|
+
"""Whether an artifact version exists within the specified project and entity.
|
1535
1667
|
|
1536
1668
|
Args:
|
1537
|
-
name:
|
1538
|
-
|
1539
|
-
|
1540
|
-
|
1541
|
-
|
1542
|
-
|
1543
|
-
type:
|
1669
|
+
name: The name of artifact. Add the artifact's entity and project
|
1670
|
+
as a prefix. Append the version or the alias of the artifact
|
1671
|
+
with a colon. If the entity or project is not specified,
|
1672
|
+
W&B uses override parameters if populated. Otherwise, the
|
1673
|
+
entity is pulled from the user settings and the project is
|
1674
|
+
set to "Uncategorized".
|
1675
|
+
type: The type of artifact.
|
1544
1676
|
|
1545
1677
|
Returns:
|
1546
1678
|
True if the artifact version exists, False otherwise.
|
1679
|
+
|
1680
|
+
Examples:
|
1681
|
+
In the proceeding code snippets "entity", "project", "artifact",
|
1682
|
+
"version", and "alias" are placeholders for your W&B entity, name of
|
1683
|
+
the project the artifact is in, the name of the artifact, and
|
1684
|
+
artifact's version, respectively.
|
1685
|
+
|
1686
|
+
```python
|
1687
|
+
import wandb
|
1688
|
+
|
1689
|
+
wandb.Api().artifact_exists("entity/project/artifact:version")
|
1690
|
+
wandb.Api().artifact_exists("entity/project/artifact:alias")
|
1691
|
+
```
|
1692
|
+
|
1547
1693
|
"""
|
1548
1694
|
try:
|
1549
1695
|
self._artifact(name, type)
|
@@ -1554,16 +1700,29 @@ class Api:
|
|
1554
1700
|
|
1555
1701
|
@normalize_exceptions
|
1556
1702
|
def artifact_collection_exists(self, name: str, type: str) -> bool:
|
1557
|
-
"""
|
1703
|
+
"""Whether an artifact collection exists within a specified project and entity.
|
1558
1704
|
|
1559
1705
|
Args:
|
1560
|
-
name:
|
1561
|
-
|
1562
|
-
|
1563
|
-
|
1706
|
+
name: An artifact collection name. Optionally append the
|
1707
|
+
entity that logged the artifact as a prefix followed by
|
1708
|
+
a forward slash. If entity or project is not specified,
|
1709
|
+
infer the collection from the override params if they exist.
|
1710
|
+
Otherwise, entity is pulled from the user settings and project
|
1711
|
+
will default to "uncategorized".
|
1712
|
+
type: The type of artifact collection.
|
1564
1713
|
|
1565
1714
|
Returns:
|
1566
1715
|
True if the artifact collection exists, False otherwise.
|
1716
|
+
|
1717
|
+
Examples:
|
1718
|
+
In the proceeding code snippet "type", and "collection_name" refer to the type
|
1719
|
+
of the artifact collection and the name of the collection, respectively.
|
1720
|
+
|
1721
|
+
```python
|
1722
|
+
import wandb
|
1723
|
+
|
1724
|
+
wandb.Api.artifact_collection_exists(type="type", name="collection_name")
|
1725
|
+
```
|
1567
1726
|
"""
|
1568
1727
|
try:
|
1569
1728
|
self.artifact_collection(type, name)
|
@@ -1577,46 +1736,16 @@ class Api:
|
|
1577
1736
|
organization: Optional[str] = None,
|
1578
1737
|
filter: Optional[Dict[str, Any]] = None,
|
1579
1738
|
) -> Registries:
|
1580
|
-
"""Returns a Registry
|
1739
|
+
"""Returns a lazy iterator of `Registry` objects.
|
1581
1740
|
|
1582
1741
|
Use the iterator to search and filter registries, collections,
|
1583
1742
|
or artifact versions across your organization's registry.
|
1584
1743
|
|
1585
|
-
Examples:
|
1586
|
-
Find all registries with the names that contain "model"
|
1587
|
-
```python
|
1588
|
-
import wandb
|
1589
|
-
|
1590
|
-
api = wandb.Api() # specify an org if your entity belongs to multiple orgs
|
1591
|
-
api.registries(filter={"name": {"$regex": "model"}})
|
1592
|
-
```
|
1593
|
-
|
1594
|
-
Find all collections in the registries with the name "my_collection" and the tag "my_tag"
|
1595
|
-
```python
|
1596
|
-
api.registries().collections(
|
1597
|
-
filter={"name": "my_collection", "tag": "my_tag"}
|
1598
|
-
)
|
1599
|
-
```
|
1600
|
-
|
1601
|
-
Find all artifact versions in the registries with a collection name that contains "my_collection" and a version that has the alias "best"
|
1602
|
-
```python
|
1603
|
-
api.registries().collections(
|
1604
|
-
filter={"name": {"$regex": "my_collection"}}
|
1605
|
-
).versions(filter={"alias": "best"})
|
1606
|
-
```
|
1607
|
-
|
1608
|
-
Find all artifact versions in the registries that contain "model" and have the tag "prod" or alias "best"
|
1609
|
-
```python
|
1610
|
-
api.registries(filter={"name": {"$regex": "model"}}).versions(
|
1611
|
-
filter={"$or": [{"tag": "prod"}, {"alias": "best"}]}
|
1612
|
-
)
|
1613
|
-
```
|
1614
|
-
|
1615
1744
|
Args:
|
1616
1745
|
organization: (str, optional) The organization of the registry to fetch.
|
1617
1746
|
If not specified, use the organization specified in the user's settings.
|
1618
|
-
filter: (dict, optional) MongoDB-style filter to apply to each object in the registry iterator.
|
1619
|
-
Fields available to filter for
|
1747
|
+
filter: (dict, optional) MongoDB-style filter to apply to each object in the lazy registry iterator.
|
1748
|
+
Fields available to filter for registries are
|
1620
1749
|
`name`, `description`, `created_at`, `updated_at`.
|
1621
1750
|
Fields available to filter for collections are
|
1622
1751
|
`name`, `tag`, `description`, `created_at`, `updated_at`
|
@@ -1624,7 +1753,39 @@ class Api:
|
|
1624
1753
|
`tag`, `alias`, `created_at`, `updated_at`, `metadata`
|
1625
1754
|
|
1626
1755
|
Returns:
|
1627
|
-
A
|
1756
|
+
A lazy iterator of `Registry` objects.
|
1757
|
+
|
1758
|
+
Examples:
|
1759
|
+
Find all registries with the names that contain "model"
|
1760
|
+
|
1761
|
+
```python
|
1762
|
+
import wandb
|
1763
|
+
|
1764
|
+
api = wandb.Api() # specify an org if your entity belongs to multiple orgs
|
1765
|
+
api.registries(filter={"name": {"$regex": "model"}})
|
1766
|
+
```
|
1767
|
+
|
1768
|
+
Find all collections in the registries with the name "my_collection" and the tag "my_tag"
|
1769
|
+
|
1770
|
+
```python
|
1771
|
+
api.registries().collections(filter={"name": "my_collection", "tag": "my_tag"})
|
1772
|
+
```
|
1773
|
+
|
1774
|
+
Find all artifact versions in the registries with a collection name that contains "my_collection" and a version that has the alias "best"
|
1775
|
+
|
1776
|
+
```python
|
1777
|
+
api.registries().collections(
|
1778
|
+
filter={"name": {"$regex": "my_collection"}}
|
1779
|
+
).versions(filter={"alias": "best"})
|
1780
|
+
```
|
1781
|
+
|
1782
|
+
Find all artifact versions in the registries that contain "model" and have the tag "prod" or alias "best"
|
1783
|
+
|
1784
|
+
```python
|
1785
|
+
api.registries(filter={"name": {"$regex": "model"}}).versions(
|
1786
|
+
filter={"$or": [{"tag": "prod"}, {"alias": "best"}]}
|
1787
|
+
)
|
1788
|
+
```
|
1628
1789
|
"""
|
1629
1790
|
if not InternalApi()._server_supports(ServerFeature.ARTIFACT_REGISTRY_SEARCH):
|
1630
1791
|
raise RuntimeError(
|
@@ -1652,15 +1813,16 @@ class Api:
|
|
1652
1813
|
A registry object.
|
1653
1814
|
|
1654
1815
|
Examples:
|
1655
|
-
|
1656
|
-
```python
|
1657
|
-
import wandb
|
1816
|
+
Fetch and update a registry
|
1658
1817
|
|
1659
|
-
|
1660
|
-
|
1661
|
-
|
1662
|
-
|
1663
|
-
|
1818
|
+
```python
|
1819
|
+
import wandb
|
1820
|
+
|
1821
|
+
api = wandb.Api()
|
1822
|
+
registry = api.registry(name="my-registry", organization="my-org")
|
1823
|
+
registry.description = "This is an updated description"
|
1824
|
+
registry.save()
|
1825
|
+
```
|
1664
1826
|
"""
|
1665
1827
|
if not InternalApi()._server_supports(ServerFeature.ARTIFACT_REGISTRY_SEARCH):
|
1666
1828
|
raise RuntimeError(
|
@@ -1705,18 +1867,18 @@ class Api:
|
|
1705
1867
|
A registry object.
|
1706
1868
|
|
1707
1869
|
Examples:
|
1708
|
-
|
1709
|
-
|
1710
|
-
|
1711
|
-
|
1712
|
-
|
1713
|
-
|
1714
|
-
|
1715
|
-
|
1716
|
-
|
1717
|
-
|
1718
|
-
|
1719
|
-
|
1870
|
+
```python
|
1871
|
+
import wandb
|
1872
|
+
|
1873
|
+
api = wandb.Api()
|
1874
|
+
registry = api.create_registry(
|
1875
|
+
name="my-registry",
|
1876
|
+
visibility="restricted",
|
1877
|
+
organization="my-org",
|
1878
|
+
description="This is a test registry",
|
1879
|
+
artifact_types=["model"],
|
1880
|
+
)
|
1881
|
+
```
|
1720
1882
|
"""
|
1721
1883
|
if not InternalApi()._server_supports(
|
1722
1884
|
ServerFeature.INCLUDE_ARTIFACT_TYPES_IN_REGISTRY_CREATION
|
@@ -1788,23 +1950,25 @@ class Api:
|
|
1788
1950
|
Iterator[WebhookIntegration]: An iterator of webhook integrations.
|
1789
1951
|
|
1790
1952
|
Examples:
|
1791
|
-
|
1792
|
-
```python
|
1793
|
-
import wandb
|
1953
|
+
Get all registered webhook integrations for the team "my-team":
|
1794
1954
|
|
1795
|
-
|
1796
|
-
|
1797
|
-
```
|
1955
|
+
```python
|
1956
|
+
import wandb
|
1798
1957
|
|
1799
|
-
|
1800
|
-
|
1801
|
-
|
1802
|
-
|
1803
|
-
|
1804
|
-
|
1805
|
-
|
1806
|
-
|
1807
|
-
|
1958
|
+
api = wandb.Api()
|
1959
|
+
webhook_integrations = api.webhook_integrations(entity="my-team")
|
1960
|
+
```
|
1961
|
+
|
1962
|
+
Find only webhook integrations that post requests to "https://my-fake-url.com":
|
1963
|
+
|
1964
|
+
```python
|
1965
|
+
webhook_integrations = api.webhook_integrations(entity="my-team")
|
1966
|
+
my_webhooks = [
|
1967
|
+
ig
|
1968
|
+
for ig in webhook_integrations
|
1969
|
+
if ig.url_endpoint.startswith("https://my-fake-url.com")
|
1970
|
+
]
|
1971
|
+
```
|
1808
1972
|
"""
|
1809
1973
|
from wandb.apis.public.integrations import WebhookIntegrations
|
1810
1974
|
|
@@ -1829,23 +1993,25 @@ class Api:
|
|
1829
1993
|
Iterator[SlackIntegration]: An iterator of Slack integrations.
|
1830
1994
|
|
1831
1995
|
Examples:
|
1832
|
-
|
1833
|
-
```python
|
1834
|
-
import wandb
|
1996
|
+
Get all registered Slack integrations for the team "my-team":
|
1835
1997
|
|
1836
|
-
|
1837
|
-
|
1838
|
-
```
|
1998
|
+
```python
|
1999
|
+
import wandb
|
1839
2000
|
|
1840
|
-
|
1841
|
-
|
1842
|
-
|
1843
|
-
|
1844
|
-
|
1845
|
-
|
1846
|
-
|
1847
|
-
|
1848
|
-
|
2001
|
+
api = wandb.Api()
|
2002
|
+
slack_integrations = api.slack_integrations(entity="my-team")
|
2003
|
+
```
|
2004
|
+
|
2005
|
+
Find only Slack integrations that post to channel names starting with "team-alerts-":
|
2006
|
+
|
2007
|
+
```python
|
2008
|
+
slack_integrations = api.slack_integrations(entity="my-team")
|
2009
|
+
team_alert_integrations = [
|
2010
|
+
ig
|
2011
|
+
for ig in slack_integrations
|
2012
|
+
if ig.channel_name.startswith("team-alerts-")
|
2013
|
+
]
|
2014
|
+
```
|
1849
2015
|
"""
|
1850
2016
|
from wandb.apis.public.integrations import SlackIntegrations
|
1851
2017
|
|
@@ -1943,20 +2109,20 @@ class Api:
|
|
1943
2109
|
ValueError: If zero or multiple Automations match the search criteria.
|
1944
2110
|
|
1945
2111
|
Examples:
|
1946
|
-
|
2112
|
+
Get an existing automation named "my-automation":
|
1947
2113
|
|
1948
|
-
|
1949
|
-
|
2114
|
+
```python
|
2115
|
+
import wandb
|
1950
2116
|
|
1951
|
-
|
1952
|
-
|
1953
|
-
|
2117
|
+
api = wandb.Api()
|
2118
|
+
automation = api.automation(name="my-automation")
|
2119
|
+
```
|
1954
2120
|
|
1955
|
-
|
2121
|
+
Get an existing automation named "other-automation", from the entity "my-team":
|
1956
2122
|
|
1957
|
-
|
1958
|
-
|
1959
|
-
|
2123
|
+
```python
|
2124
|
+
automation = api.automation(name="other-automation", entity="my-team")
|
2125
|
+
```
|
1960
2126
|
"""
|
1961
2127
|
return one(
|
1962
2128
|
self.automations(entity=entity, name=name),
|
@@ -1986,14 +2152,14 @@ class Api:
|
|
1986
2152
|
A list of automations.
|
1987
2153
|
|
1988
2154
|
Examples:
|
1989
|
-
|
2155
|
+
Fetch all existing automations for the entity "my-team":
|
1990
2156
|
|
1991
|
-
|
1992
|
-
|
2157
|
+
```python
|
2158
|
+
import wandb
|
1993
2159
|
|
1994
|
-
|
1995
|
-
|
1996
|
-
|
2160
|
+
api = wandb.Api()
|
2161
|
+
automations = api.automations(entity="my-team")
|
2162
|
+
```
|
1997
2163
|
"""
|
1998
2164
|
from wandb.apis.public.automations import Automations
|
1999
2165
|
from wandb.automations._generated import (
|
@@ -2051,32 +2217,32 @@ class Api:
|
|
2051
2217
|
The saved Automation.
|
2052
2218
|
|
2053
2219
|
Examples:
|
2054
|
-
|
2055
|
-
|
2220
|
+
Create a new automation named "my-automation" that sends a Slack notification
|
2221
|
+
when a run within a specific project logs a metric exceeding a custom threshold:
|
2056
2222
|
|
2057
|
-
|
2058
|
-
|
2059
|
-
|
2223
|
+
```python
|
2224
|
+
import wandb
|
2225
|
+
from wandb.automations import OnRunMetric, RunEvent, SendNotification
|
2060
2226
|
|
2061
|
-
|
2227
|
+
api = wandb.Api()
|
2062
2228
|
|
2063
|
-
|
2229
|
+
project = api.project("my-project", entity="my-team")
|
2064
2230
|
|
2065
|
-
|
2066
|
-
|
2231
|
+
# Use the first Slack integration for the team
|
2232
|
+
slack_hook = next(api.slack_integrations(entity="my-team"))
|
2067
2233
|
|
2068
|
-
|
2069
|
-
|
2070
|
-
|
2071
|
-
|
2072
|
-
|
2234
|
+
event = OnRunMetric(
|
2235
|
+
scope=project,
|
2236
|
+
filter=RunEvent.metric("custom-metric") > 10,
|
2237
|
+
)
|
2238
|
+
action = SendNotification.from_integration(slack_hook)
|
2073
2239
|
|
2074
|
-
|
2075
|
-
|
2076
|
-
|
2077
|
-
|
2078
|
-
|
2079
|
-
|
2240
|
+
automation = api.create_automation(
|
2241
|
+
event >> action,
|
2242
|
+
name="my-automation",
|
2243
|
+
description="Send a Slack message whenever 'custom-metric' exceeds 10.",
|
2244
|
+
)
|
2245
|
+
```
|
2080
2246
|
"""
|
2081
2247
|
from wandb.automations import Automation
|
2082
2248
|
from wandb.automations._generated import CREATE_AUTOMATION_GQL, CreateAutomation
|
@@ -2156,35 +2322,35 @@ class Api:
|
|
2156
2322
|
The updated automation.
|
2157
2323
|
|
2158
2324
|
Examples:
|
2159
|
-
|
2325
|
+
Disable and edit the description of an existing automation ("my-automation"):
|
2160
2326
|
|
2161
|
-
|
2162
|
-
|
2327
|
+
```python
|
2328
|
+
import wandb
|
2163
2329
|
|
2164
|
-
|
2330
|
+
api = wandb.Api()
|
2165
2331
|
|
2166
|
-
|
2167
|
-
|
2168
|
-
|
2332
|
+
automation = api.automation(name="my-automation")
|
2333
|
+
automation.enabled = False
|
2334
|
+
automation.description = "Kept for reference, but no longer used."
|
2169
2335
|
|
2170
|
-
|
2171
|
-
|
2336
|
+
updated_automation = api.update_automation(automation)
|
2337
|
+
```
|
2172
2338
|
|
2173
|
-
|
2339
|
+
OR
|
2174
2340
|
|
2175
|
-
|
2176
|
-
|
2341
|
+
```python
|
2342
|
+
import wandb
|
2177
2343
|
|
2178
|
-
|
2344
|
+
api = wandb.Api()
|
2179
2345
|
|
2180
|
-
|
2346
|
+
automation = api.automation(name="my-automation")
|
2181
2347
|
|
2182
|
-
|
2183
|
-
|
2184
|
-
|
2185
|
-
|
2186
|
-
|
2187
|
-
|
2348
|
+
updated_automation = api.update_automation(
|
2349
|
+
automation,
|
2350
|
+
enabled=False,
|
2351
|
+
description="Kept for reference, but no longer used.",
|
2352
|
+
)
|
2353
|
+
```
|
2188
2354
|
"""
|
2189
2355
|
from wandb.automations import ActionType, Automation
|
2190
2356
|
from wandb.automations._generated import UPDATE_AUTOMATION_GQL, UpdateAutomation
|