wandb 0.21.0__py3-none-win32.whl → 0.21.2__py3-none-win32.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.
Files changed (153) hide show
  1. wandb/__init__.py +16 -14
  2. wandb/__init__.pyi +427 -450
  3. wandb/agents/pyagent.py +41 -12
  4. wandb/analytics/sentry.py +7 -2
  5. wandb/apis/importers/mlflow.py +1 -1
  6. wandb/apis/public/__init__.py +1 -1
  7. wandb/apis/public/api.py +525 -360
  8. wandb/apis/public/artifacts.py +207 -13
  9. wandb/apis/public/automations.py +19 -3
  10. wandb/apis/public/files.py +172 -33
  11. wandb/apis/public/history.py +67 -15
  12. wandb/apis/public/integrations.py +25 -2
  13. wandb/apis/public/jobs.py +90 -2
  14. wandb/apis/public/projects.py +130 -79
  15. wandb/apis/public/query_generator.py +11 -1
  16. wandb/apis/public/registries/_utils.py +14 -16
  17. wandb/apis/public/registries/registries_search.py +183 -304
  18. wandb/apis/public/reports.py +96 -15
  19. wandb/apis/public/runs.py +299 -105
  20. wandb/apis/public/sweeps.py +222 -22
  21. wandb/apis/public/teams.py +41 -4
  22. wandb/apis/public/users.py +45 -4
  23. wandb/automations/_generated/delete_automation.py +1 -3
  24. wandb/automations/_generated/enums.py +13 -11
  25. wandb/beta/workflows.py +66 -30
  26. wandb/bin/gpu_stats.exe +0 -0
  27. wandb/bin/wandb-core +0 -0
  28. wandb/cli/cli.py +127 -3
  29. wandb/env.py +8 -0
  30. wandb/errors/errors.py +4 -1
  31. wandb/integration/lightning/fabric/logger.py +3 -4
  32. wandb/integration/metaflow/__init__.py +6 -0
  33. wandb/integration/metaflow/data_pandas.py +74 -0
  34. wandb/integration/metaflow/data_pytorch.py +75 -0
  35. wandb/integration/metaflow/data_sklearn.py +76 -0
  36. wandb/integration/metaflow/errors.py +13 -0
  37. wandb/integration/metaflow/metaflow.py +167 -223
  38. wandb/integration/openai/fine_tuning.py +1 -2
  39. wandb/integration/weave/__init__.py +6 -0
  40. wandb/integration/weave/interface.py +49 -0
  41. wandb/integration/weave/weave.py +63 -0
  42. wandb/jupyter.py +5 -5
  43. wandb/plot/custom_chart.py +30 -7
  44. wandb/proto/v3/wandb_internal_pb2.py +281 -280
  45. wandb/proto/v3/wandb_telemetry_pb2.py +4 -4
  46. wandb/proto/v4/wandb_internal_pb2.py +280 -280
  47. wandb/proto/v4/wandb_telemetry_pb2.py +4 -4
  48. wandb/proto/v5/wandb_internal_pb2.py +280 -280
  49. wandb/proto/v5/wandb_telemetry_pb2.py +4 -4
  50. wandb/proto/v6/wandb_internal_pb2.py +280 -280
  51. wandb/proto/v6/wandb_telemetry_pb2.py +4 -4
  52. wandb/proto/wandb_deprecated.py +6 -0
  53. wandb/sdk/artifacts/_factories.py +17 -0
  54. wandb/sdk/artifacts/_generated/__init__.py +221 -13
  55. wandb/sdk/artifacts/_generated/artifact_by_id.py +17 -0
  56. wandb/sdk/artifacts/_generated/artifact_by_name.py +22 -0
  57. wandb/sdk/artifacts/_generated/artifact_collection_membership_file_urls.py +43 -0
  58. wandb/sdk/artifacts/_generated/artifact_created_by.py +47 -0
  59. wandb/sdk/artifacts/_generated/artifact_file_urls.py +22 -0
  60. wandb/sdk/artifacts/_generated/artifact_type.py +31 -0
  61. wandb/sdk/artifacts/_generated/artifact_used_by.py +43 -0
  62. wandb/sdk/artifacts/_generated/artifact_via_membership_by_name.py +26 -0
  63. wandb/sdk/artifacts/_generated/delete_artifact.py +28 -0
  64. wandb/sdk/artifacts/_generated/enums.py +5 -0
  65. wandb/sdk/artifacts/_generated/fetch_artifact_manifest.py +38 -0
  66. wandb/sdk/artifacts/_generated/fetch_registries.py +32 -0
  67. wandb/sdk/artifacts/_generated/fragments.py +279 -41
  68. wandb/sdk/artifacts/_generated/link_artifact.py +6 -0
  69. wandb/sdk/artifacts/_generated/operations.py +654 -51
  70. wandb/sdk/artifacts/_generated/registry_collections.py +34 -0
  71. wandb/sdk/artifacts/_generated/registry_versions.py +34 -0
  72. wandb/sdk/artifacts/_generated/unlink_artifact.py +25 -0
  73. wandb/sdk/artifacts/_graphql_fragments.py +3 -86
  74. wandb/sdk/artifacts/_internal_artifact.py +19 -8
  75. wandb/sdk/artifacts/_validators.py +14 -4
  76. wandb/sdk/artifacts/artifact.py +512 -618
  77. wandb/sdk/artifacts/artifact_file_cache.py +10 -6
  78. wandb/sdk/artifacts/artifact_manifest.py +10 -9
  79. wandb/sdk/artifacts/artifact_manifest_entry.py +9 -10
  80. wandb/sdk/artifacts/artifact_manifests/artifact_manifest_v1.py +5 -3
  81. wandb/sdk/artifacts/storage_handlers/http_handler.py +1 -1
  82. wandb/sdk/artifacts/storage_handlers/s3_handler.py +1 -1
  83. wandb/sdk/artifacts/storage_policies/wandb_storage_policy.py +1 -1
  84. wandb/sdk/data_types/audio.py +38 -10
  85. wandb/sdk/data_types/base_types/media.py +6 -56
  86. wandb/sdk/data_types/graph.py +48 -14
  87. wandb/sdk/data_types/helper_types/bounding_boxes_2d.py +1 -3
  88. wandb/sdk/data_types/helper_types/image_mask.py +1 -3
  89. wandb/sdk/data_types/histogram.py +34 -21
  90. wandb/sdk/data_types/html.py +35 -12
  91. wandb/sdk/data_types/image.py +104 -68
  92. wandb/sdk/data_types/molecule.py +32 -19
  93. wandb/sdk/data_types/object_3d.py +36 -17
  94. wandb/sdk/data_types/plotly.py +18 -5
  95. wandb/sdk/data_types/saved_model.py +4 -6
  96. wandb/sdk/data_types/table.py +59 -30
  97. wandb/sdk/data_types/video.py +53 -26
  98. wandb/sdk/integration_utils/auto_logging.py +2 -2
  99. wandb/sdk/interface/interface_queue.py +1 -4
  100. wandb/sdk/interface/interface_shared.py +26 -37
  101. wandb/sdk/interface/interface_sock.py +24 -14
  102. wandb/sdk/internal/internal_api.py +6 -0
  103. wandb/sdk/internal/job_builder.py +6 -0
  104. wandb/sdk/internal/settings_static.py +2 -3
  105. wandb/sdk/launch/agent/agent.py +8 -1
  106. wandb/sdk/launch/agent/run_queue_item_file_saver.py +2 -2
  107. wandb/sdk/launch/create_job.py +15 -2
  108. wandb/sdk/launch/inputs/internal.py +3 -4
  109. wandb/sdk/launch/inputs/schema.py +1 -0
  110. wandb/sdk/launch/runner/kubernetes_monitor.py +1 -0
  111. wandb/sdk/launch/runner/kubernetes_runner.py +323 -1
  112. wandb/sdk/launch/sweeps/scheduler.py +2 -3
  113. wandb/sdk/lib/asyncio_compat.py +19 -16
  114. wandb/sdk/lib/asyncio_manager.py +252 -0
  115. wandb/sdk/lib/deprecate.py +1 -7
  116. wandb/sdk/lib/disabled.py +1 -1
  117. wandb/sdk/lib/hashutil.py +27 -5
  118. wandb/sdk/lib/module.py +7 -13
  119. wandb/sdk/lib/printer.py +2 -2
  120. wandb/sdk/lib/printer_asyncio.py +3 -1
  121. wandb/sdk/lib/progress.py +0 -19
  122. wandb/sdk/lib/retry.py +185 -78
  123. wandb/sdk/lib/service/service_client.py +106 -0
  124. wandb/sdk/lib/service/service_connection.py +20 -26
  125. wandb/sdk/lib/service/service_token.py +30 -13
  126. wandb/sdk/mailbox/mailbox.py +13 -5
  127. wandb/sdk/mailbox/mailbox_handle.py +22 -13
  128. wandb/sdk/mailbox/response_handle.py +42 -106
  129. wandb/sdk/mailbox/wait_with_progress.py +7 -42
  130. wandb/sdk/wandb_init.py +77 -116
  131. wandb/sdk/wandb_login.py +19 -15
  132. wandb/sdk/wandb_metric.py +2 -0
  133. wandb/sdk/wandb_run.py +497 -469
  134. wandb/sdk/wandb_settings.py +145 -4
  135. wandb/sdk/wandb_setup.py +204 -124
  136. wandb/sdk/wandb_sweep.py +14 -13
  137. wandb/sdk/wandb_watch.py +4 -6
  138. wandb/sync/sync.py +10 -0
  139. wandb/util.py +58 -1
  140. wandb/wandb_run.py +1 -2
  141. {wandb-0.21.0.dist-info → wandb-0.21.2.dist-info}/METADATA +1 -1
  142. {wandb-0.21.0.dist-info → wandb-0.21.2.dist-info}/RECORD +145 -129
  143. wandb/sdk/interface/interface_relay.py +0 -38
  144. wandb/sdk/interface/router.py +0 -89
  145. wandb/sdk/interface/router_queue.py +0 -43
  146. wandb/sdk/interface/router_relay.py +0 -50
  147. wandb/sdk/interface/router_sock.py +0 -32
  148. wandb/sdk/lib/sock_client.py +0 -236
  149. wandb/vendor/pynvml/__init__.py +0 -0
  150. wandb/vendor/pynvml/pynvml.py +0 -4779
  151. {wandb-0.21.0.dist-info → wandb-0.21.2.dist-info}/WHEEL +0 -0
  152. {wandb-0.21.0.dist-info → wandb-0.21.2.dist-info}/entry_points.txt +0 -0
  153. {wandb-0.21.0.dist-info → wandb-0.21.2.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 wandb server.
144
+ """Used for querying the W&B server.
139
145
 
140
146
  Examples:
141
- Most common way to initialize
142
- >>> wandb.Api()
147
+ ```python
148
+ import wandb
143
149
 
144
- Args:
145
- overrides: (dict) You can set `base_url` if you are using a wandb server
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 self.api_key is None and _thread_local_api_settings.cookies is None:
293
- wandb.login(host=_overrides.get("base_url"))
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: (str) The name of the new project.
332
- entity: (str) The entity of the new project.
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: (str, optional) The ID to assign to the run, if given. The run ID is automatically generated by
347
- default, so in general, you do not need to specify this and should only do so at your own risk.
348
- project: (str, optional) If given, the project of the new run.
349
- entity: (str, optional) If given, the entity of the new run.
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 (launch).
413
+ """Create a new run queue in W&B Launch.
368
414
 
369
415
  Args:
370
- name: (str) Name of the queue to create
371
- type: (str) Type of resource to be used for the queue. One of "local-container", "local-process", "kubernetes", "sagemaker", or "gcp-vertex".
372
- entity: (str) Optional name of the entity to create the queue. If None, will use the configured or default entity.
373
- prioritization_mode: (str) Optional version of prioritization to use. Either "V0" or None
374
- config: (dict) Optional default resource configuration to be used for the queue. Use handlebars (eg. `{{var}}`) to specify template variables.
375
- template_variables: (dict) A dictionary of template variable schemas to be used with the config. Expected format of:
376
- `{
377
- "var-name": {
378
- "schema": {
379
- "type": ("string", "number", or "integer"),
380
- "default": (optional value),
381
- "minimum": (optional minimum),
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 (launch).
600
+ """Upsert a run queue in W&B Launch.
560
601
 
561
602
  Args:
562
- name: (str) Name of the queue to create
563
- entity: (str) Optional name of the entity to create the queue. If None, will use the configured or default entity.
564
- resource_config: (dict) Optional default resource configuration to be used for the queue. Use handlebars (eg. `{{var}}`) to specify template variables.
565
- resource_type: (str) Type of resource to be used for the queue. One of "local-container", "local-process", "kubernetes", "sagemaker", or "gcp-vertex".
566
- template_variables: (dict) A dictionary of template variable schemas to be used with the config. Expected format of:
567
- `{
568
- "var-name": {
569
- "schema": {
570
- "type": ("string", "number", or "integer"),
571
- "default": (optional value),
572
- "minimum": (optional minimum),
573
- "maximum": (optional maximum),
574
- "enum": [..."(options)"]
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: (str) The email address of the user
669
- admin: (bool) Whether this user should be a global instance 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
- self._viewer = public.User(
736
- self._client, self._client.execute(self.VIEWER_QUERY).get("viewer")
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 may
745
- change while executing your script you must clear the local cache with
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: (str) The path to the project, run, sweep or report
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: (str) Name of the entity requested. If None, will fall back to the
878
- default entity passed to `Api`. If no default entity, will raise a `ValueError`.
879
- per_page: (int) Sets the page size for query pagination. Usually there is no reason to change this.
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` objects.
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: (str) The project name.
901
- entity: (str) Name of the entity requested. If None, will fall back to the
902
- default entity passed to `Api`. If no default entity, will raise a `ValueError`.
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,28 @@ class Api:
923
985
  ) -> "public.Reports":
924
986
  """Get reports for a given project path.
925
987
 
926
- WARNING: This api is in beta and will likely change in a future release
988
+ Note: `wandb.Api.reports()` API is in beta and will likely change in
989
+ future releases.
927
990
 
928
991
  Args:
929
- path: (str) path to project the report resides in, should be in the form: "entity/project"
930
- name: (str, optional) optional name of the report requested.
931
- per_page: (int) Sets the page size for query pagination. Usually there is no reason to change this.
992
+ path: The path to the 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 `BetaReport` objects.
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
+ ```
935
1010
  """
936
1011
  entity, project, _ = self._parse_path(path + "/fake_run")
937
1012
 
@@ -950,15 +1025,18 @@ class Api:
950
1025
  )
951
1026
  return self._reports[key]
952
1027
 
953
- def create_team(self, team, admin_username=None):
1028
+ def create_team(
1029
+ self, team: str, admin_username: Optional[str] = None
1030
+ ) -> "public.Team":
954
1031
  """Create a new team.
955
1032
 
956
1033
  Args:
957
- team: (str) The name of the team
958
- admin_username: (str) optional username of the admin user of the team, defaults to the current user.
1034
+ team: The name of the team
1035
+ admin_username: Username of the admin user of the team.
1036
+ Defaults to the current user.
959
1037
 
960
1038
  Returns:
961
- A `Team` object
1039
+ A `Team` object.
962
1040
  """
963
1041
  return public.Team.create(self, team, admin_username)
964
1042
 
@@ -966,7 +1044,7 @@ class Api:
966
1044
  """Return the matching `Team` with the given name.
967
1045
 
968
1046
  Args:
969
- team: (str) The name of the team.
1047
+ team: The name of the team.
970
1048
 
971
1049
  Returns:
972
1050
  A `Team` object.
@@ -976,13 +1054,14 @@ class Api:
976
1054
  def user(self, username_or_email: str) -> Optional["public.User"]:
977
1055
  """Return a user from a username or email address.
978
1056
 
979
- Note: This function only works for Local Admins, if you are trying to get your own user object, please use `api.viewer`.
1057
+ This function only works for local administrators. Use `api.viewer`
1058
+ to get your own user object.
980
1059
 
981
1060
  Args:
982
- username_or_email: (str) The username or email address of the user
1061
+ username_or_email: The username or email address of the user.
983
1062
 
984
1063
  Returns:
985
- A `User` object or None if a user couldn't be found
1064
+ A `User` object or None if a user is not found.
986
1065
  """
987
1066
  res = self._client.execute(self.USERS_QUERY, {"query": username_or_email})
988
1067
  if len(res["users"]["edges"]) == 0:
@@ -998,13 +1077,14 @@ class Api:
998
1077
  def users(self, username_or_email: str) -> List["public.User"]:
999
1078
  """Return all users from a partial username or email address query.
1000
1079
 
1001
- Note: This function only works for Local Admins, if you are trying to get your own user object, please use `api.viewer`.
1080
+ This function only works for local administrators. Use `api.viewer`
1081
+ to get your own user object.
1002
1082
 
1003
1083
  Args:
1004
- username_or_email: (str) The prefix or suffix of the user you want to find
1084
+ username_or_email: The prefix or suffix of the user you want to find.
1005
1085
 
1006
1086
  Returns:
1007
- An array of `User` objects
1087
+ An array of `User` objects.
1008
1088
  """
1009
1089
  res = self._client.execute(self.USERS_QUERY, {"query": username_or_email})
1010
1090
  return [
@@ -1019,7 +1099,7 @@ class Api:
1019
1099
  per_page: int = 50,
1020
1100
  include_sweeps: bool = True,
1021
1101
  ):
1022
- """Return a set of runs from a project that match the filters provided.
1102
+ """Returns a `Runs` object, which lazily iterates over `Run` objects.
1023
1103
 
1024
1104
  Fields you can filter by include:
1025
1105
  - `createdAt`: The timestamp when the run was created. (in ISO 8601 format, e.g. "2023-01-01T12:00:00Z")
@@ -1054,64 +1134,6 @@ class Api:
1054
1134
  - `$regex`
1055
1135
 
1056
1136
 
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
1137
 
1116
1138
  Args:
1117
1139
  path: (str) path to project, should be in the form: "entity/project"
@@ -1120,14 +1142,55 @@ class Api:
1120
1142
  For example: `{"config.experiment_name": "foo"}` would find runs with a config entry
1121
1143
  of experiment name set to "foo"
1122
1144
  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 (default).
1145
+ If you prepend order with a + order is ascending (default).
1146
+ If you prepend order with a - order is descending.
1125
1147
  The default order is run.created_at from oldest to newest.
1126
1148
  per_page: (int) Sets the page size for query pagination.
1127
1149
  include_sweeps: (bool) Whether to include the sweep runs in the results.
1128
1150
 
1129
1151
  Returns:
1130
1152
  A `Runs` object, which is an iterable collection of `Run` objects.
1153
+
1154
+ Examples:
1155
+ ```python
1156
+ # Find runs in project where config.experiment_name has been set to "foo"
1157
+ api.runs(path="my_entity/project", filters={"config.experiment_name": "foo"})
1158
+ ```
1159
+
1160
+ ```python
1161
+ # Find runs in project where config.experiment_name has been set to "foo" or "bar"
1162
+ api.runs(
1163
+ path="my_entity/project",
1164
+ filters={
1165
+ "$or": [
1166
+ {"config.experiment_name": "foo"},
1167
+ {"config.experiment_name": "bar"},
1168
+ ]
1169
+ },
1170
+ )
1171
+ ```
1172
+
1173
+ ```python
1174
+ # Find runs in project where config.experiment_name matches a regex
1175
+ # (anchors are not supported)
1176
+ api.runs(
1177
+ path="my_entity/project",
1178
+ filters={"config.experiment_name": {"$regex": "b.*"}},
1179
+ )
1180
+ ```
1181
+
1182
+ ```python
1183
+ # Find runs in project where the run name matches a regex
1184
+ # (anchors are not supported)
1185
+ api.runs(
1186
+ path="my_entity/project", filters={"display_name": {"$regex": "^foo.*"}}
1187
+ )
1188
+ ```
1189
+
1190
+ ```python
1191
+ # Find runs in project sorted by ascending loss
1192
+ api.runs(path="my_entity/project", order="+summary_metrics.loss")
1193
+ ```
1131
1194
  """
1132
1195
  entity, project = self._parse_project_path(path)
1133
1196
  filters = filters or {}
@@ -1146,10 +1209,10 @@ class Api:
1146
1209
 
1147
1210
  @normalize_exceptions
1148
1211
  def run(self, path=""):
1149
- """Return a single run by parsing path in the form entity/project/run_id.
1212
+ """Return a single run by parsing path in the form `entity/project/run_id`.
1150
1213
 
1151
1214
  Args:
1152
- path: (str) path to run in the form `entity/project/run_id`.
1215
+ path: Path to run in the form `entity/project/run_id`.
1153
1216
  If `api.entity` is set, this can be in the form `project/run_id`
1154
1217
  and if `api.project` is set this can just be the run_id.
1155
1218
 
@@ -1163,16 +1226,16 @@ class Api:
1163
1226
 
1164
1227
  def queued_run(
1165
1228
  self,
1166
- entity,
1167
- project,
1168
- queue_name,
1169
- run_queue_item_id,
1229
+ entity: str,
1230
+ project: str,
1231
+ queue_name: str,
1232
+ run_queue_item_id: str,
1170
1233
  project_queue=None,
1171
1234
  priority=None,
1172
1235
  ):
1173
1236
  """Return a single queued run based on the path.
1174
1237
 
1175
- Parses paths of the form entity/project/queue_id/run_queue_item_id.
1238
+ Parses paths of the form `entity/project/queue_id/run_queue_item_id`.
1176
1239
  """
1177
1240
  return public.QueuedRun(
1178
1241
  self.client,
@@ -1186,12 +1249,12 @@ class Api:
1186
1249
 
1187
1250
  def run_queue(
1188
1251
  self,
1189
- entity,
1190
- name,
1252
+ entity: str,
1253
+ name: str,
1191
1254
  ):
1192
1255
  """Return the named `RunQueue` for entity.
1193
1256
 
1194
- To create a new `RunQueue`, use `wandb.Api().create_run_queue(...)`.
1257
+ See `Api.create_run_queue` for more information on how to create a run queue.
1195
1258
  """
1196
1259
  return public.RunQueue(
1197
1260
  self.client,
@@ -1204,8 +1267,9 @@ class Api:
1204
1267
  """Return a sweep by parsing path in the form `entity/project/sweep_id`.
1205
1268
 
1206
1269
  Args:
1207
- path: (str, optional) path to sweep in the form entity/project/sweep_id. If `api.entity`
1208
- is set, this can be in the form project/sweep_id and if `api.project` is set
1270
+ path: Path to sweep in the form entity/project/sweep_id.
1271
+ If `api.entity` is set, this can be in the form
1272
+ project/sweep_id and if `api.project` is set
1209
1273
  this can just be the sweep_id.
1210
1274
 
1211
1275
  Returns:
@@ -1218,10 +1282,10 @@ class Api:
1218
1282
 
1219
1283
  @normalize_exceptions
1220
1284
  def artifact_types(self, project: Optional[str] = None) -> "public.ArtifactTypes":
1221
- """Return a collection of matching artifact types.
1285
+ """Returns a collection of matching artifact types.
1222
1286
 
1223
1287
  Args:
1224
- project: (str, optional) If given, a project name or path to filter on.
1288
+ project: The project name or path to filter on.
1225
1289
 
1226
1290
  Returns:
1227
1291
  An iterable `ArtifactTypes` object.
@@ -1241,11 +1305,11 @@ class Api:
1241
1305
  def artifact_type(
1242
1306
  self, type_name: str, project: Optional[str] = None
1243
1307
  ) -> "public.ArtifactType":
1244
- """Return the matching `ArtifactType`.
1308
+ """Returns the matching `ArtifactType`.
1245
1309
 
1246
1310
  Args:
1247
- type_name: (str) The name of the artifact type to retrieve.
1248
- project: (str, optional) If given, a project name or path to filter on.
1311
+ type_name: The name of the artifact type to retrieve.
1312
+ project: If given, a project name or path to filter on.
1249
1313
 
1250
1314
  Returns:
1251
1315
  An `ArtifactType` object.
@@ -1265,12 +1329,13 @@ class Api:
1265
1329
  def artifact_collections(
1266
1330
  self, project_name: str, type_name: str, per_page: int = 50
1267
1331
  ) -> "public.ArtifactCollections":
1268
- """Return a collection of matching artifact collections.
1332
+ """Returns a collection of matching artifact collections.
1269
1333
 
1270
1334
  Args:
1271
- project_name: (str) The name of the project to filter on.
1272
- type_name: (str) The name of the artifact type to filter on.
1273
- per_page: (int) Sets the page size for query pagination. Usually there is no reason to change this.
1335
+ project_name: The name of the project to filter on.
1336
+ type_name: The name of the artifact type to filter on.
1337
+ per_page: Sets the page size for query pagination. None will use the default size.
1338
+ Usually there is no reason to change this.
1274
1339
 
1275
1340
  Returns:
1276
1341
  An iterable `ArtifactCollections` object.
@@ -1291,14 +1356,39 @@ class Api:
1291
1356
  def artifact_collection(
1292
1357
  self, type_name: str, name: str
1293
1358
  ) -> "public.ArtifactCollection":
1294
- """Return a single artifact collection by type and parsing path in the form `entity/project/name`.
1359
+ """Returns a single artifact collection by type.
1360
+
1361
+ You can use the returned `ArtifactCollection` object to retrieve
1362
+ information about specific artifacts in that collection, and more.
1295
1363
 
1296
1364
  Args:
1297
- type_name: (str) The type of artifact collection to fetch.
1298
- name: (str) An artifact collection name. May be prefixed with entity/project.
1365
+ type_name: The type of artifact collection to fetch.
1366
+ name: An artifact collection name. Optionally append the entity
1367
+ that logged the artifact as a prefix followed by a forward
1368
+ slash.
1299
1369
 
1300
1370
  Returns:
1301
1371
  An `ArtifactCollection` object.
1372
+
1373
+ Examples:
1374
+ In the proceeding code snippet "type", "entity", "project", and
1375
+ "artifact_name" are placeholders for the collection type, your W&B
1376
+ entity, name of the project the artifact is in, and the name of
1377
+ the artifact, respectively.
1378
+
1379
+ ```python
1380
+ import wandb
1381
+
1382
+ collections = wandb.Api().artifact_collection(
1383
+ type_name="type", name="entity/project/artifact_name"
1384
+ )
1385
+
1386
+ # Get the first artifact in the collection
1387
+ artifact_example = collections.artifacts()[0]
1388
+
1389
+ # Download the contents of the artifact to the specified root directory.
1390
+ artifact_example.download()
1391
+ ```
1302
1392
  """
1303
1393
  entity, project, collection_name = self._parse_artifact_path(name)
1304
1394
  # If its an Registry artifact, the entity is considered to be an org instead
@@ -1320,7 +1410,7 @@ class Api:
1320
1410
 
1321
1411
  @normalize_exceptions
1322
1412
  def artifact_versions(self, type_name, name, per_page=50):
1323
- """Deprecated, use `artifacts(type_name, name)` instead."""
1413
+ """Deprecated. Use `Api.artifacts(type_name, name)` method instead."""
1324
1414
  deprecate(
1325
1415
  field_name=Deprecated.api__artifact_versions,
1326
1416
  warning_message=(
@@ -1338,16 +1428,32 @@ class Api:
1338
1428
  per_page: int = 50,
1339
1429
  tags: Optional[List[str]] = None,
1340
1430
  ) -> "public.Artifacts":
1341
- """Return an `Artifacts` collection from the given parameters.
1431
+ """Return an `Artifacts` collection.
1342
1432
 
1343
1433
  Args:
1344
- type_name: (str) The type of artifacts to fetch.
1345
- name: (str) An artifact collection name. May be prefixed with entity/project.
1346
- per_page: (int) Sets the page size for query pagination. Usually there is no reason to change this.
1347
- tags: (list[str], optional) Only return artifacts with all of these tags.
1434
+ type_name: The type of artifacts to fetch.
1435
+ name: The artifact's collection name. Optionally append the
1436
+ entity that logged the artifact as a prefix followed by
1437
+ a forward slash.
1438
+ per_page: Sets the page size for query pagination. If set to
1439
+ `None`, use the default size. Usually there is no reason
1440
+ to change this.
1441
+ tags: Only return artifacts with all of these tags.
1348
1442
 
1349
1443
  Returns:
1350
1444
  An iterable `Artifacts` object.
1445
+
1446
+ Examples:
1447
+ In the proceeding code snippet, "type", "entity", "project", and
1448
+ "artifact_name" are placeholders for the artifact type, W&B entity,
1449
+ name of the project the artifact was logged to,
1450
+ and the name of the artifact, respectively.
1451
+
1452
+ ```python
1453
+ import wandb
1454
+
1455
+ wandb.Api().artifacts(type_name="type", name="entity/project/artifact_name")
1456
+ ```
1351
1457
  """
1352
1458
  entity, project, collection_name = self._parse_artifact_path(name)
1353
1459
  # If its an Registry project, the entity is considered to be an org instead
@@ -1410,22 +1516,47 @@ class Api:
1410
1516
 
1411
1517
  @normalize_exceptions
1412
1518
  def artifact(self, name: str, type: Optional[str] = None):
1413
- """Return a single artifact by parsing path in the form `project/name` or `entity/project/name`.
1519
+ """Returns a single artifact.
1414
1520
 
1415
1521
  Args:
1416
- name: (str) An artifact name. May be prefixed with project/ or entity/project/.
1417
- If no entity is specified in the name, the Run or API setting's entity is used.
1418
- Valid names can be in the following forms:
1419
- name:version
1420
- name:alias
1421
- type: (str, optional) The type of artifact to fetch.
1522
+ name: The artifact's name. The name of an artifact resembles a
1523
+ filepath that consists, at a minimum, the name of the project
1524
+ the artifact was logged to, the name of the artifact, and the
1525
+ artifact's version or alias. Optionally append the entity that
1526
+ logged the artifact as a prefix followed by a forward slash.
1527
+ If no entity is specified in the name, the Run or API
1528
+ setting's entity is used.
1529
+ type: The type of artifact to fetch.
1422
1530
 
1423
1531
  Returns:
1424
1532
  An `Artifact` object.
1425
1533
 
1426
1534
  Raises:
1427
1535
  ValueError: If the artifact name is not specified.
1428
- ValueError: If the artifact type is specified but does not match the type of the fetched artifact.
1536
+ ValueError: If the artifact type is specified but does not
1537
+ match the type of the fetched artifact.
1538
+
1539
+ Examples:
1540
+ In the proceeding code snippets "entity", "project", "artifact",
1541
+ "version", and "alias" are placeholders for your W&B entity, name
1542
+ of the project the artifact is in, the name of the artifact,
1543
+ and artifact's version, respectively.
1544
+
1545
+ ```python
1546
+ import wandb
1547
+
1548
+ # Specify the project, artifact's name, and the artifact's alias
1549
+ wandb.Api().artifact(name="project/artifact:alias")
1550
+
1551
+ # Specify the project, artifact's name, and a specific artifact version
1552
+ wandb.Api().artifact(name="project/artifact:version")
1553
+
1554
+ # Specify the entity, project, artifact's name, and the artifact's alias
1555
+ wandb.Api().artifact(name="entity/project/artifact:alias")
1556
+
1557
+ # Specify the entity, project, artifact's name, and a specific artifact version
1558
+ wandb.Api().artifact(name="entity/project/artifact:version")
1559
+ ```
1429
1560
 
1430
1561
  Note:
1431
1562
  This method is intended for external use only. Do not call `api.artifact()` within the wandb repository code.
@@ -1434,11 +1565,11 @@ class Api:
1434
1565
 
1435
1566
  @normalize_exceptions
1436
1567
  def job(self, name: Optional[str], path: Optional[str] = None) -> "public.Job":
1437
- """Return a `Job` from the given parameters.
1568
+ """Return a `Job` object.
1438
1569
 
1439
1570
  Args:
1440
- name: (str) The job name.
1441
- path: (str, optional) If given, the root path in which to download the job artifact.
1571
+ name: The name of the job.
1572
+ path: The root path to download the job artifact.
1442
1573
 
1443
1574
  Returns:
1444
1575
  A `Job` object.
@@ -1456,8 +1587,8 @@ class Api:
1456
1587
  """Return a list of jobs, if any, for the given entity and project.
1457
1588
 
1458
1589
  Args:
1459
- entity: (str) The entity for the listed job(s).
1460
- project: (str) The project for the listed job(s).
1590
+ entity: The entity for the listed jobs.
1591
+ project: The project for the listed jobs.
1461
1592
 
1462
1593
  Returns:
1463
1594
  A list of matching jobs.
@@ -1531,19 +1662,33 @@ class Api:
1531
1662
 
1532
1663
  @normalize_exceptions
1533
1664
  def artifact_exists(self, name: str, type: Optional[str] = None) -> bool:
1534
- """Return whether an artifact version exists within a specified project and entity.
1665
+ """Whether an artifact version exists within the specified project and entity.
1535
1666
 
1536
1667
  Args:
1537
- name: (str) An artifact name. May be prefixed with entity/project.
1538
- If entity or project is not specified, it will be inferred from the override params if populated.
1539
- Otherwise, entity will be pulled from the user settings and project will default to "uncategorized".
1540
- Valid names can be in the following forms:
1541
- name:version
1542
- name:alias
1543
- type: (str, optional) The type of artifact
1668
+ name: The name of artifact. Add the artifact's entity and project
1669
+ as a prefix. Append the version or the alias of the artifact
1670
+ with a colon. If the entity or project is not specified,
1671
+ W&B uses override parameters if populated. Otherwise, the
1672
+ entity is pulled from the user settings and the project is
1673
+ set to "Uncategorized".
1674
+ type: The type of artifact.
1544
1675
 
1545
1676
  Returns:
1546
1677
  True if the artifact version exists, False otherwise.
1678
+
1679
+ Examples:
1680
+ In the proceeding code snippets "entity", "project", "artifact",
1681
+ "version", and "alias" are placeholders for your W&B entity, name of
1682
+ the project the artifact is in, the name of the artifact, and
1683
+ artifact's version, respectively.
1684
+
1685
+ ```python
1686
+ import wandb
1687
+
1688
+ wandb.Api().artifact_exists("entity/project/artifact:version")
1689
+ wandb.Api().artifact_exists("entity/project/artifact:alias")
1690
+ ```
1691
+
1547
1692
  """
1548
1693
  try:
1549
1694
  self._artifact(name, type)
@@ -1554,16 +1699,29 @@ class Api:
1554
1699
 
1555
1700
  @normalize_exceptions
1556
1701
  def artifact_collection_exists(self, name: str, type: str) -> bool:
1557
- """Return whether an artifact collection exists within a specified project and entity.
1702
+ """Whether an artifact collection exists within a specified project and entity.
1558
1703
 
1559
1704
  Args:
1560
- name: (str) An artifact collection name. May be prefixed with entity/project.
1561
- If entity or project is not specified, it will be inferred from the override params if populated.
1562
- Otherwise, entity will be pulled from the user settings and project will default to "uncategorized".
1563
- type: (str) The type of artifact collection
1705
+ name: An artifact collection name. Optionally append the
1706
+ entity that logged the artifact as a prefix followed by
1707
+ a forward slash. If entity or project is not specified,
1708
+ infer the collection from the override params if they exist.
1709
+ Otherwise, entity is pulled from the user settings and project
1710
+ will default to "uncategorized".
1711
+ type: The type of artifact collection.
1564
1712
 
1565
1713
  Returns:
1566
1714
  True if the artifact collection exists, False otherwise.
1715
+
1716
+ Examples:
1717
+ In the proceeding code snippet "type", and "collection_name" refer to the type
1718
+ of the artifact collection and the name of the collection, respectively.
1719
+
1720
+ ```python
1721
+ import wandb
1722
+
1723
+ wandb.Api.artifact_collection_exists(type="type", name="collection_name")
1724
+ ```
1567
1725
  """
1568
1726
  try:
1569
1727
  self.artifact_collection(type, name)
@@ -1577,46 +1735,16 @@ class Api:
1577
1735
  organization: Optional[str] = None,
1578
1736
  filter: Optional[Dict[str, Any]] = None,
1579
1737
  ) -> Registries:
1580
- """Returns a Registry iterator.
1738
+ """Returns a lazy iterator of `Registry` objects.
1581
1739
 
1582
1740
  Use the iterator to search and filter registries, collections,
1583
1741
  or artifact versions across your organization's registry.
1584
1742
 
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
1743
  Args:
1616
1744
  organization: (str, optional) The organization of the registry to fetch.
1617
1745
  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 collections are
1746
+ filter: (dict, optional) MongoDB-style filter to apply to each object in the lazy registry iterator.
1747
+ Fields available to filter for registries are
1620
1748
  `name`, `description`, `created_at`, `updated_at`.
1621
1749
  Fields available to filter for collections are
1622
1750
  `name`, `tag`, `description`, `created_at`, `updated_at`
@@ -1624,7 +1752,39 @@ class Api:
1624
1752
  `tag`, `alias`, `created_at`, `updated_at`, `metadata`
1625
1753
 
1626
1754
  Returns:
1627
- A registry iterator.
1755
+ A lazy iterator of `Registry` objects.
1756
+
1757
+ Examples:
1758
+ Find all registries with the names that contain "model"
1759
+
1760
+ ```python
1761
+ import wandb
1762
+
1763
+ api = wandb.Api() # specify an org if your entity belongs to multiple orgs
1764
+ api.registries(filter={"name": {"$regex": "model"}})
1765
+ ```
1766
+
1767
+ Find all collections in the registries with the name "my_collection" and the tag "my_tag"
1768
+
1769
+ ```python
1770
+ api.registries().collections(filter={"name": "my_collection", "tag": "my_tag"})
1771
+ ```
1772
+
1773
+ Find all artifact versions in the registries with a collection name that contains "my_collection" and a version that has the alias "best"
1774
+
1775
+ ```python
1776
+ api.registries().collections(
1777
+ filter={"name": {"$regex": "my_collection"}}
1778
+ ).versions(filter={"alias": "best"})
1779
+ ```
1780
+
1781
+ Find all artifact versions in the registries that contain "model" and have the tag "prod" or alias "best"
1782
+
1783
+ ```python
1784
+ api.registries(filter={"name": {"$regex": "model"}}).versions(
1785
+ filter={"$or": [{"tag": "prod"}, {"alias": "best"}]}
1786
+ )
1787
+ ```
1628
1788
  """
1629
1789
  if not InternalApi()._server_supports(ServerFeature.ARTIFACT_REGISTRY_SEARCH):
1630
1790
  raise RuntimeError(
@@ -1652,15 +1812,16 @@ class Api:
1652
1812
  A registry object.
1653
1813
 
1654
1814
  Examples:
1655
- Fetch and update a registry
1656
- ```python
1657
- import wandb
1815
+ Fetch and update a registry
1658
1816
 
1659
- api = wandb.Api()
1660
- registry = api.registry(name="my-registry", organization="my-org")
1661
- registry.description = "This is an updated description"
1662
- registry.save()
1663
- ```
1817
+ ```python
1818
+ import wandb
1819
+
1820
+ api = wandb.Api()
1821
+ registry = api.registry(name="my-registry", organization="my-org")
1822
+ registry.description = "This is an updated description"
1823
+ registry.save()
1824
+ ```
1664
1825
  """
1665
1826
  if not InternalApi()._server_supports(ServerFeature.ARTIFACT_REGISTRY_SEARCH):
1666
1827
  raise RuntimeError(
@@ -1705,18 +1866,18 @@ class Api:
1705
1866
  A registry object.
1706
1867
 
1707
1868
  Examples:
1708
- ```python
1709
- import wandb
1710
-
1711
- api = wandb.Api()
1712
- registry = api.create_registry(
1713
- name="my-registry",
1714
- visibility="restricted",
1715
- organization="my-org",
1716
- description="This is a test registry",
1717
- artifact_types=["model"],
1718
- )
1719
- ```
1869
+ ```python
1870
+ import wandb
1871
+
1872
+ api = wandb.Api()
1873
+ registry = api.create_registry(
1874
+ name="my-registry",
1875
+ visibility="restricted",
1876
+ organization="my-org",
1877
+ description="This is a test registry",
1878
+ artifact_types=["model"],
1879
+ )
1880
+ ```
1720
1881
  """
1721
1882
  if not InternalApi()._server_supports(
1722
1883
  ServerFeature.INCLUDE_ARTIFACT_TYPES_IN_REGISTRY_CREATION
@@ -1788,23 +1949,25 @@ class Api:
1788
1949
  Iterator[WebhookIntegration]: An iterator of webhook integrations.
1789
1950
 
1790
1951
  Examples:
1791
- Get all registered webhook integrations for the team "my-team":
1792
- ```python
1793
- import wandb
1952
+ Get all registered webhook integrations for the team "my-team":
1794
1953
 
1795
- api = wandb.Api()
1796
- webhook_integrations = api.webhook_integrations(entity="my-team")
1797
- ```
1954
+ ```python
1955
+ import wandb
1798
1956
 
1799
- Find only webhook integrations that post requests to "https://my-fake-url.com":
1800
- ```python
1801
- webhook_integrations = api.webhook_integrations(entity="my-team")
1802
- my_webhooks = [
1803
- ig
1804
- for ig in webhook_integrations
1805
- if ig.url_endpoint.startswith("https://my-fake-url.com")
1806
- ]
1807
- ```
1957
+ api = wandb.Api()
1958
+ webhook_integrations = api.webhook_integrations(entity="my-team")
1959
+ ```
1960
+
1961
+ Find only webhook integrations that post requests to "https://my-fake-url.com":
1962
+
1963
+ ```python
1964
+ webhook_integrations = api.webhook_integrations(entity="my-team")
1965
+ my_webhooks = [
1966
+ ig
1967
+ for ig in webhook_integrations
1968
+ if ig.url_endpoint.startswith("https://my-fake-url.com")
1969
+ ]
1970
+ ```
1808
1971
  """
1809
1972
  from wandb.apis.public.integrations import WebhookIntegrations
1810
1973
 
@@ -1829,23 +1992,25 @@ class Api:
1829
1992
  Iterator[SlackIntegration]: An iterator of Slack integrations.
1830
1993
 
1831
1994
  Examples:
1832
- Get all registered Slack integrations for the team "my-team":
1833
- ```python
1834
- import wandb
1995
+ Get all registered Slack integrations for the team "my-team":
1835
1996
 
1836
- api = wandb.Api()
1837
- slack_integrations = api.slack_integrations(entity="my-team")
1838
- ```
1997
+ ```python
1998
+ import wandb
1839
1999
 
1840
- Find only Slack integrations that post to channel names starting with "team-alerts-":
1841
- ```python
1842
- slack_integrations = api.slack_integrations(entity="my-team")
1843
- team_alert_integrations = [
1844
- ig
1845
- for ig in slack_integrations
1846
- if ig.channel_name.startswith("team-alerts-")
1847
- ]
1848
- ```
2000
+ api = wandb.Api()
2001
+ slack_integrations = api.slack_integrations(entity="my-team")
2002
+ ```
2003
+
2004
+ Find only Slack integrations that post to channel names starting with "team-alerts-":
2005
+
2006
+ ```python
2007
+ slack_integrations = api.slack_integrations(entity="my-team")
2008
+ team_alert_integrations = [
2009
+ ig
2010
+ for ig in slack_integrations
2011
+ if ig.channel_name.startswith("team-alerts-")
2012
+ ]
2013
+ ```
1849
2014
  """
1850
2015
  from wandb.apis.public.integrations import SlackIntegrations
1851
2016
 
@@ -1943,20 +2108,20 @@ class Api:
1943
2108
  ValueError: If zero or multiple Automations match the search criteria.
1944
2109
 
1945
2110
  Examples:
1946
- Get an existing automation named "my-automation":
2111
+ Get an existing automation named "my-automation":
1947
2112
 
1948
- ```python
1949
- import wandb
2113
+ ```python
2114
+ import wandb
1950
2115
 
1951
- api = wandb.Api()
1952
- automation = api.automation(name="my-automation")
1953
- ```
2116
+ api = wandb.Api()
2117
+ automation = api.automation(name="my-automation")
2118
+ ```
1954
2119
 
1955
- Get an existing automation named "other-automation", from the entity "my-team":
2120
+ Get an existing automation named "other-automation", from the entity "my-team":
1956
2121
 
1957
- ```python
1958
- automation = api.automation(name="other-automation", entity="my-team")
1959
- ```
2122
+ ```python
2123
+ automation = api.automation(name="other-automation", entity="my-team")
2124
+ ```
1960
2125
  """
1961
2126
  return one(
1962
2127
  self.automations(entity=entity, name=name),
@@ -1986,14 +2151,14 @@ class Api:
1986
2151
  A list of automations.
1987
2152
 
1988
2153
  Examples:
1989
- Fetch all existing automations for the entity "my-team":
2154
+ Fetch all existing automations for the entity "my-team":
1990
2155
 
1991
- ```python
1992
- import wandb
2156
+ ```python
2157
+ import wandb
1993
2158
 
1994
- api = wandb.Api()
1995
- automations = api.automations(entity="my-team")
1996
- ```
2159
+ api = wandb.Api()
2160
+ automations = api.automations(entity="my-team")
2161
+ ```
1997
2162
  """
1998
2163
  from wandb.apis.public.automations import Automations
1999
2164
  from wandb.automations._generated import (
@@ -2051,32 +2216,32 @@ class Api:
2051
2216
  The saved Automation.
2052
2217
 
2053
2218
  Examples:
2054
- Create a new automation named "my-automation" that sends a Slack notification
2055
- when a run within a specific project logs a metric exceeding a custom threshold:
2219
+ Create a new automation named "my-automation" that sends a Slack notification
2220
+ when a run within a specific project logs a metric exceeding a custom threshold:
2056
2221
 
2057
- ```python
2058
- import wandb
2059
- from wandb.automations import OnRunMetric, RunEvent, SendNotification
2222
+ ```python
2223
+ import wandb
2224
+ from wandb.automations import OnRunMetric, RunEvent, SendNotification
2060
2225
 
2061
- api = wandb.Api()
2226
+ api = wandb.Api()
2062
2227
 
2063
- project = api.project("my-project", entity="my-team")
2228
+ project = api.project("my-project", entity="my-team")
2064
2229
 
2065
- # Use the first Slack integration for the team
2066
- slack_hook = next(api.slack_integrations(entity="my-team"))
2230
+ # Use the first Slack integration for the team
2231
+ slack_hook = next(api.slack_integrations(entity="my-team"))
2067
2232
 
2068
- event = OnRunMetric(
2069
- scope=project,
2070
- filter=RunEvent.metric("custom-metric") > 10,
2071
- )
2072
- action = SendNotification.from_integration(slack_hook)
2233
+ event = OnRunMetric(
2234
+ scope=project,
2235
+ filter=RunEvent.metric("custom-metric") > 10,
2236
+ )
2237
+ action = SendNotification.from_integration(slack_hook)
2073
2238
 
2074
- automation = api.create_automation(
2075
- event >> action,
2076
- name="my-automation",
2077
- description="Send a Slack message whenever 'custom-metric' exceeds 10.",
2078
- )
2079
- ```
2239
+ automation = api.create_automation(
2240
+ event >> action,
2241
+ name="my-automation",
2242
+ description="Send a Slack message whenever 'custom-metric' exceeds 10.",
2243
+ )
2244
+ ```
2080
2245
  """
2081
2246
  from wandb.automations import Automation
2082
2247
  from wandb.automations._generated import CREATE_AUTOMATION_GQL, CreateAutomation
@@ -2156,35 +2321,35 @@ class Api:
2156
2321
  The updated automation.
2157
2322
 
2158
2323
  Examples:
2159
- Disable and edit the description of an existing automation ("my-automation"):
2324
+ Disable and edit the description of an existing automation ("my-automation"):
2160
2325
 
2161
- ```python
2162
- import wandb
2326
+ ```python
2327
+ import wandb
2163
2328
 
2164
- api = wandb.Api()
2329
+ api = wandb.Api()
2165
2330
 
2166
- automation = api.automation(name="my-automation")
2167
- automation.enabled = False
2168
- automation.description = "Kept for reference, but no longer used."
2331
+ automation = api.automation(name="my-automation")
2332
+ automation.enabled = False
2333
+ automation.description = "Kept for reference, but no longer used."
2169
2334
 
2170
- updated_automation = api.update_automation(automation)
2171
- ```
2335
+ updated_automation = api.update_automation(automation)
2336
+ ```
2172
2337
 
2173
- OR:
2338
+ OR
2174
2339
 
2175
- ```python
2176
- import wandb
2340
+ ```python
2341
+ import wandb
2177
2342
 
2178
- api = wandb.Api()
2343
+ api = wandb.Api()
2179
2344
 
2180
- automation = api.automation(name="my-automation")
2345
+ automation = api.automation(name="my-automation")
2181
2346
 
2182
- updated_automation = api.update_automation(
2183
- automation,
2184
- enabled=False,
2185
- description="Kept for reference, but no longer used.",
2186
- )
2187
- ```
2347
+ updated_automation = api.update_automation(
2348
+ automation,
2349
+ enabled=False,
2350
+ description="Kept for reference, but no longer used.",
2351
+ )
2352
+ ```
2188
2353
  """
2189
2354
  from wandb.automations import ActionType, Automation
2190
2355
  from wandb.automations._generated import UPDATE_AUTOMATION_GQL, UpdateAutomation