wandb 0.18.5__py3-none-macosx_11_0_arm64.whl → 0.18.7__py3-none-macosx_11_0_arm64.whl

Sign up to get free protection for your applications and to get access to all the features.
Files changed (150) hide show
  1. wandb/__init__.py +2 -2
  2. wandb/__init__.pyi +22 -20
  3. wandb/agents/pyagent.py +1 -1
  4. wandb/apis/importers/wandb.py +1 -1
  5. wandb/apis/normalize.py +2 -18
  6. wandb/apis/public/api.py +126 -62
  7. wandb/apis/public/artifacts.py +8 -3
  8. wandb/apis/public/files.py +17 -2
  9. wandb/apis/public/jobs.py +2 -2
  10. wandb/apis/public/query_generator.py +1 -1
  11. wandb/apis/public/runs.py +8 -8
  12. wandb/apis/public/teams.py +3 -3
  13. wandb/apis/public/users.py +1 -1
  14. wandb/apis/public/utils.py +68 -0
  15. wandb/bin/gpu_stats +0 -0
  16. wandb/bin/wandb-core +0 -0
  17. wandb/cli/cli.py +12 -3
  18. wandb/data_types.py +1 -1
  19. wandb/docker/__init__.py +2 -1
  20. wandb/docker/auth.py +2 -3
  21. wandb/errors/links.py +73 -0
  22. wandb/errors/term.py +7 -6
  23. wandb/filesync/step_prepare.py +1 -1
  24. wandb/filesync/upload_job.py +1 -1
  25. wandb/integration/catboost/catboost.py +2 -2
  26. wandb/integration/diffusers/pipeline_resolver.py +1 -1
  27. wandb/integration/diffusers/resolvers/multimodal.py +6 -6
  28. wandb/integration/diffusers/resolvers/utils.py +1 -1
  29. wandb/integration/fastai/__init__.py +3 -2
  30. wandb/integration/keras/callbacks/metrics_logger.py +1 -1
  31. wandb/integration/keras/callbacks/model_checkpoint.py +1 -1
  32. wandb/integration/keras/keras.py +1 -1
  33. wandb/integration/kfp/kfp_patch.py +1 -1
  34. wandb/integration/lightgbm/__init__.py +2 -2
  35. wandb/integration/magic.py +2 -2
  36. wandb/integration/metaflow/metaflow.py +1 -1
  37. wandb/integration/sacred/__init__.py +1 -1
  38. wandb/integration/sagemaker/auth.py +1 -1
  39. wandb/integration/sklearn/plot/classifier.py +7 -7
  40. wandb/integration/sklearn/plot/clusterer.py +3 -3
  41. wandb/integration/sklearn/plot/regressor.py +3 -3
  42. wandb/integration/sklearn/plot/shared.py +2 -2
  43. wandb/integration/tensorboard/log.py +2 -2
  44. wandb/integration/ultralytics/callback.py +2 -2
  45. wandb/integration/xgboost/xgboost.py +1 -1
  46. wandb/jupyter.py +0 -1
  47. wandb/plot/__init__.py +17 -8
  48. wandb/plot/bar.py +53 -27
  49. wandb/plot/confusion_matrix.py +151 -70
  50. wandb/plot/custom_chart.py +124 -0
  51. wandb/plot/histogram.py +46 -20
  52. wandb/plot/line.py +57 -26
  53. wandb/plot/line_series.py +148 -60
  54. wandb/plot/pr_curve.py +89 -44
  55. wandb/plot/roc_curve.py +82 -37
  56. wandb/plot/scatter.py +53 -20
  57. wandb/plot/viz.py +20 -102
  58. wandb/proto/v3/wandb_settings_pb2.py +2 -2
  59. wandb/proto/v3/wandb_telemetry_pb2.py +4 -4
  60. wandb/proto/v4/wandb_settings_pb2.py +2 -2
  61. wandb/proto/v4/wandb_telemetry_pb2.py +4 -4
  62. wandb/proto/v5/wandb_settings_pb2.py +2 -2
  63. wandb/proto/v5/wandb_telemetry_pb2.py +4 -4
  64. wandb/proto/wandb_deprecated.py +2 -0
  65. wandb/sdk/artifacts/artifact.py +281 -329
  66. wandb/sdk/artifacts/artifact_manifest.py +10 -9
  67. wandb/sdk/artifacts/artifact_manifest_entry.py +1 -1
  68. wandb/sdk/artifacts/storage_handlers/azure_handler.py +9 -4
  69. wandb/sdk/artifacts/storage_handlers/gcs_handler.py +1 -3
  70. wandb/sdk/artifacts/storage_handlers/s3_handler.py +1 -1
  71. wandb/sdk/artifacts/storage_handlers/wb_artifact_handler.py +2 -2
  72. wandb/sdk/artifacts/storage_handlers/wb_local_artifact_handler.py +1 -1
  73. wandb/sdk/backend/backend.py +0 -1
  74. wandb/sdk/data_types/audio.py +1 -1
  75. wandb/sdk/data_types/base_types/media.py +66 -5
  76. wandb/sdk/data_types/base_types/wb_value.py +20 -10
  77. wandb/sdk/data_types/bokeh.py +1 -1
  78. wandb/sdk/data_types/helper_types/bounding_boxes_2d.py +1 -1
  79. wandb/sdk/data_types/helper_types/image_mask.py +2 -2
  80. wandb/sdk/data_types/histogram.py +1 -1
  81. wandb/sdk/data_types/html.py +1 -1
  82. wandb/sdk/data_types/image.py +1 -1
  83. wandb/sdk/data_types/molecule.py +3 -3
  84. wandb/sdk/data_types/object_3d.py +4 -4
  85. wandb/sdk/data_types/plotly.py +1 -1
  86. wandb/sdk/data_types/saved_model.py +0 -1
  87. wandb/sdk/data_types/table.py +7 -7
  88. wandb/sdk/data_types/trace_tree.py +1 -1
  89. wandb/sdk/data_types/video.py +4 -3
  90. wandb/sdk/interface/interface_queue.py +0 -6
  91. wandb/sdk/interface/router.py +1 -4
  92. wandb/sdk/interface/router_queue.py +0 -3
  93. wandb/sdk/interface/router_relay.py +0 -2
  94. wandb/sdk/internal/datastore.py +1 -1
  95. wandb/sdk/internal/file_pusher.py +1 -1
  96. wandb/sdk/internal/file_stream.py +4 -4
  97. wandb/sdk/internal/handler.py +3 -4
  98. wandb/sdk/internal/internal.py +1 -15
  99. wandb/sdk/internal/internal_api.py +178 -63
  100. wandb/sdk/internal/internal_util.py +0 -3
  101. wandb/sdk/internal/job_builder.py +4 -3
  102. wandb/sdk/internal/sender.py +0 -2
  103. wandb/sdk/internal/system/assets/__init__.py +0 -2
  104. wandb/sdk/internal/tb_watcher.py +11 -10
  105. wandb/sdk/internal/writer.py +1 -3
  106. wandb/sdk/launch/__init__.py +2 -1
  107. wandb/sdk/launch/_launch.py +4 -3
  108. wandb/sdk/launch/_launch_add.py +2 -2
  109. wandb/sdk/launch/builder/kaniko_builder.py +0 -1
  110. wandb/sdk/launch/create_job.py +1 -0
  111. wandb/sdk/launch/environment/local_environment.py +0 -1
  112. wandb/sdk/launch/errors.py +0 -6
  113. wandb/sdk/launch/registry/local_registry.py +0 -2
  114. wandb/sdk/launch/runner/abstract.py +0 -5
  115. wandb/sdk/launch/sweeps/__init__.py +0 -2
  116. wandb/sdk/launch/sweeps/scheduler.py +0 -2
  117. wandb/sdk/launch/sweeps/scheduler_sweep.py +0 -1
  118. wandb/sdk/lib/_settings_toposort_generated.py +1 -0
  119. wandb/sdk/lib/apikey.py +3 -3
  120. wandb/sdk/lib/file_stream_utils.py +1 -1
  121. wandb/sdk/lib/filesystem.py +1 -1
  122. wandb/sdk/lib/ipython.py +16 -9
  123. wandb/sdk/lib/mailbox.py +0 -4
  124. wandb/sdk/lib/printer.py +44 -8
  125. wandb/sdk/lib/retry.py +1 -1
  126. wandb/sdk/lib/sock_client.py +0 -5
  127. wandb/sdk/service/server.py +2 -11
  128. wandb/sdk/service/server_sock.py +0 -2
  129. wandb/sdk/service/service.py +3 -3
  130. wandb/sdk/service/streams.py +2 -4
  131. wandb/sdk/wandb_init.py +20 -20
  132. wandb/sdk/wandb_login.py +1 -1
  133. wandb/sdk/wandb_require.py +1 -4
  134. wandb/sdk/wandb_run.py +97 -115
  135. wandb/sdk/wandb_settings.py +23 -6
  136. wandb/sdk/wandb_setup.py +1 -5
  137. wandb/sdk/wandb_sync.py +2 -1
  138. wandb/util.py +49 -21
  139. wandb/wandb_agent.py +3 -3
  140. wandb/wandb_controller.py +2 -2
  141. {wandb-0.18.5.dist-info → wandb-0.18.7.dist-info}/METADATA +1 -1
  142. {wandb-0.18.5.dist-info → wandb-0.18.7.dist-info}/RECORD +145 -147
  143. wandb/sdk/internal/system/assets/gpu_apple.py +0 -177
  144. wandb/sdk/lib/_wburls_generate.py +0 -25
  145. wandb/sdk/lib/_wburls_generated.py +0 -22
  146. wandb/sdk/lib/tracelog.py +0 -255
  147. wandb/sdk/lib/wburls.py +0 -46
  148. {wandb-0.18.5.dist-info → wandb-0.18.7.dist-info}/WHEEL +0 -0
  149. {wandb-0.18.5.dist-info → wandb-0.18.7.dist-info}/entry_points.txt +0 -0
  150. {wandb-0.18.5.dist-info → wandb-0.18.7.dist-info}/licenses/LICENSE +0 -0
wandb/apis/public/api.py CHANGED
@@ -24,10 +24,11 @@ from wandb_gql.client import RetryError
24
24
  import wandb
25
25
  from wandb import env, util
26
26
  from wandb.apis import public
27
- from wandb.apis.internal import Api as InternalApi
28
27
  from wandb.apis.normalize import normalize_exceptions
29
28
  from wandb.apis.public.const import RETRY_TIMEDELTA
29
+ from wandb.apis.public.utils import PathType, parse_org_from_registry_path
30
30
  from wandb.sdk.artifacts._validators import is_artifact_registry_project
31
+ from wandb.sdk.internal.internal_api import Api as InternalApi
31
32
  from wandb.sdk.internal.thread_local_settings import _thread_local_api_settings
32
33
  from wandb.sdk.launch.utils import LAUNCH_DEFAULT_PROJECT
33
34
  from wandb.sdk.lib import retry, runid
@@ -100,7 +101,7 @@ class Api:
100
101
  Most common way to initialize
101
102
  >>> wandb.Api()
102
103
 
103
- Arguments:
104
+ Args:
104
105
  overrides: (dict) You can set `base_url` if you are using a wandb server
105
106
  other than https://api.wandb.ai.
106
107
  You can also set defaults for `entity`, `project`, and `run`.
@@ -282,7 +283,7 @@ class Api:
282
283
  def create_project(self, name: str, entity: str) -> None:
283
284
  """Create a new project.
284
285
 
285
- Arguments:
286
+ Args:
286
287
  name: (str) The name of the new project.
287
288
  entity: (str) The entity of the new project.
288
289
  """
@@ -297,7 +298,7 @@ class Api:
297
298
  ) -> "public.Run":
298
299
  """Create a new run.
299
300
 
300
- Arguments:
301
+ Args:
301
302
  run_id: (str, optional) The ID to assign to the run, if given. The run ID is automatically generated by
302
303
  default, so in general, you do not need to specify this and should only do so at your own risk.
303
304
  project: (str, optional) If given, the project of the new run.
@@ -321,14 +322,14 @@ class Api:
321
322
  ) -> "public.RunQueue":
322
323
  """Create a new run queue (launch).
323
324
 
324
- Arguments:
325
+ Args:
325
326
  name: (str) Name of the queue to create
326
327
  type: (str) Type of resource to be used for the queue. One of "local-container", "local-process", "kubernetes", "sagemaker", or "gcp-vertex".
327
328
  entity: (str) Optional name of the entity to create the queue. If None, will use the configured or default entity.
328
329
  prioritization_mode: (str) Optional version of prioritization to use. Either "V0" or None
329
- config: (dict) Optional default resource configuration to be used for the queue. Use handlebars (eg. "{{var}}") to specify template variables.
330
+ config: (dict) Optional default resource configuration to be used for the queue. Use handlebars (eg. `{{var}}`) to specify template variables.
330
331
  template_variables: (dict) A dictionary of template variable schemas to be used with the config. Expected format of:
331
- {
332
+ `{
332
333
  "var-name": {
333
334
  "schema": {
334
335
  "type": ("string", "number", or "integer"),
@@ -338,7 +339,7 @@ class Api:
338
339
  "enum": [..."(options)"]
339
340
  }
340
341
  }
341
- }
342
+ }`
342
343
 
343
344
  Returns:
344
345
  The newly created `RunQueue`
@@ -434,13 +435,13 @@ class Api:
434
435
  ):
435
436
  """Upsert a run queue (launch).
436
437
 
437
- Arguments:
438
+ Args:
438
439
  name: (str) Name of the queue to create
439
440
  entity: (str) Optional name of the entity to create the queue. If None, will use the configured or default entity.
440
- resource_config: (dict) Optional default resource configuration to be used for the queue. Use handlebars (eg. "{{var}}") to specify template variables.
441
+ resource_config: (dict) Optional default resource configuration to be used for the queue. Use handlebars (eg. `{{var}}`) to specify template variables.
441
442
  resource_type: (str) Type of resource to be used for the queue. One of "local-container", "local-process", "kubernetes", "sagemaker", or "gcp-vertex".
442
443
  template_variables: (dict) A dictionary of template variable schemas to be used with the config. Expected format of:
443
- {
444
+ `{
444
445
  "var-name": {
445
446
  "schema": {
446
447
  "type": ("string", "number", or "integer"),
@@ -450,11 +451,11 @@ class Api:
450
451
  "enum": [..."(options)"]
451
452
  }
452
453
  }
453
- }
454
+ }`
454
455
  external_links: (dict) Optional dictionary of external links to be used with the queue. Expected format of:
455
- {
456
+ `{
456
457
  "name": "url"
457
- }
458
+ }`
458
459
  prioritization_mode: (str) Optional version of prioritization to use. Either "V0" or None
459
460
 
460
461
  Returns:
@@ -540,7 +541,7 @@ class Api:
540
541
  def create_user(self, email, admin=False):
541
542
  """Create a new user.
542
543
 
543
- Arguments:
544
+ Args:
544
545
  email: (str) The email address of the user
545
546
  admin: (bool) Whether this user should be a global instance admin
546
547
 
@@ -635,7 +636,7 @@ class Api:
635
636
  report = api.from_path("my_team/my_project/reports/My-Report-Vm11dsdf")
636
637
  ```
637
638
 
638
- Arguments:
639
+ Args:
639
640
  path: (str) The path to the project, run, sweep or report
640
641
 
641
642
  Returns:
@@ -749,7 +750,7 @@ class Api:
749
750
  ) -> "public.Projects":
750
751
  """Get projects for a given entity.
751
752
 
752
- Arguments:
753
+ Args:
753
754
  entity: (str) Name of the entity requested. If None, will fall back to the
754
755
  default entity passed to `Api`. If no default entity, will raise a `ValueError`.
755
756
  per_page: (int) Sets the page size for query pagination. None will use the default size.
@@ -773,7 +774,7 @@ class Api:
773
774
  def project(self, name: str, entity: Optional[str] = None) -> "public.Project":
774
775
  """Return the `Project` with the given name (and entity, if given).
775
776
 
776
- Arguments:
777
+ Args:
777
778
  name: (str) The project name.
778
779
  entity: (str) Name of the entity requested. If None, will fall back to the
779
780
  default entity passed to `Api`. If no default entity, will raise a `ValueError`.
@@ -781,8 +782,18 @@ class Api:
781
782
  Returns:
782
783
  A `Project` object.
783
784
  """
785
+ # For registry artifacts, capture potential org user inputted before resolving entity
786
+ org = entity if is_artifact_registry_project(name) else ""
787
+
784
788
  if entity is None:
785
789
  entity = self.settings["entity"] or self.default_entity
790
+
791
+ # For registry artifacts, resolve org-based entity
792
+ if is_artifact_registry_project(name):
793
+ settings_entity = self.settings["entity"] or self.default_entity
794
+ entity = InternalApi()._resolve_org_entity_name(
795
+ entity=settings_entity, organization=org
796
+ )
786
797
  return public.Project(self.client, entity, name, {})
787
798
 
788
799
  def reports(
@@ -792,7 +803,7 @@ class Api:
792
803
 
793
804
  WARNING: This api is in beta and will likely change in a future release
794
805
 
795
- Arguments:
806
+ Args:
796
807
  path: (str) path to project the report resides in, should be in the form: "entity/project"
797
808
  name: (str, optional) optional name of the report requested.
798
809
  per_page: (int) Sets the page size for query pagination. None will use the default size.
@@ -821,7 +832,7 @@ class Api:
821
832
  def create_team(self, team, admin_username=None):
822
833
  """Create a new team.
823
834
 
824
- Arguments:
835
+ Args:
825
836
  team: (str) The name of the team
826
837
  admin_username: (str) optional username of the admin user of the team, defaults to the current user.
827
838
 
@@ -833,7 +844,7 @@ class Api:
833
844
  def team(self, team: str) -> "public.Team":
834
845
  """Return the matching `Team` with the given name.
835
846
 
836
- Arguments:
847
+ Args:
837
848
  team: (str) The name of the team.
838
849
 
839
850
  Returns:
@@ -846,7 +857,7 @@ class Api:
846
857
 
847
858
  Note: This function only works for Local Admins, if you are trying to get your own user object, please use `api.viewer`.
848
859
 
849
- Arguments:
860
+ Args:
850
861
  username_or_email: (str) The username or email address of the user
851
862
 
852
863
  Returns:
@@ -868,7 +879,7 @@ class Api:
868
879
 
869
880
  Note: This function only works for Local Admins, if you are trying to get your own user object, please use `api.viewer`.
870
881
 
871
- Arguments:
882
+ Args:
872
883
  username_or_email: (str) The prefix or suffix of the user you want to find
873
884
 
874
885
  Returns:
@@ -926,11 +937,11 @@ class Api:
926
937
  api.runs(path="my_entity/my_project", order="+summary_metrics.loss")
927
938
  ```
928
939
 
929
- Arguments:
940
+ Args:
930
941
  path: (str) path to project, should be in the form: "entity/project"
931
942
  filters: (dict) queries for specific runs using the MongoDB query language.
932
943
  You can filter by run properties such as config.key, summary_metrics.key, state, entity, createdAt, etc.
933
- For example: {"config.experiment_name": "foo"} would find runs with a config entry
944
+ For example: `{"config.experiment_name": "foo"}` would find runs with a config entry
934
945
  of experiment name set to "foo"
935
946
  You can compose operations to make more complicated queries,
936
947
  see Reference for the language is at https://docs.mongodb.com/manual/reference/operator/query
@@ -963,7 +974,7 @@ class Api:
963
974
  def run(self, path=""):
964
975
  """Return a single run by parsing path in the form entity/project/run_id.
965
976
 
966
- Arguments:
977
+ Args:
967
978
  path: (str) path to run in the form `entity/project/run_id`.
968
979
  If `api.entity` is set, this can be in the form `project/run_id`
969
980
  and if `api.project` is set this can just be the run_id.
@@ -1018,7 +1029,7 @@ class Api:
1018
1029
  def sweep(self, path=""):
1019
1030
  """Return a sweep by parsing path in the form `entity/project/sweep_id`.
1020
1031
 
1021
- Arguments:
1032
+ Args:
1022
1033
  path: (str, optional) path to sweep in the form entity/project/sweep_id. If `api.entity`
1023
1034
  is set, this can be in the form project/sweep_id and if `api.project` is set
1024
1035
  this can just be the sweep_id.
@@ -1035,13 +1046,21 @@ class Api:
1035
1046
  def artifact_types(self, project: Optional[str] = None) -> "public.ArtifactTypes":
1036
1047
  """Return a collection of matching artifact types.
1037
1048
 
1038
- Arguments:
1049
+ Args:
1039
1050
  project: (str, optional) If given, a project name or path to filter on.
1040
1051
 
1041
1052
  Returns:
1042
1053
  An iterable `ArtifactTypes` object.
1043
1054
  """
1044
- entity, project = self._parse_project_path(project)
1055
+ project_path = project
1056
+ entity, project = self._parse_project_path(project_path)
1057
+ # If its a Registry project, the entity is considered to be an org instead
1058
+ if is_artifact_registry_project(project):
1059
+ settings_entity = self.settings["entity"] or self.default_entity
1060
+ org = parse_org_from_registry_path(project_path, PathType.PROJECT)
1061
+ entity = InternalApi()._resolve_org_entity_name(
1062
+ entity=settings_entity, organization=org
1063
+ )
1045
1064
  return public.ArtifactTypes(self.client, entity, project)
1046
1065
 
1047
1066
  @normalize_exceptions
@@ -1050,14 +1069,22 @@ class Api:
1050
1069
  ) -> "public.ArtifactType":
1051
1070
  """Return the matching `ArtifactType`.
1052
1071
 
1053
- Arguments:
1072
+ Args:
1054
1073
  type_name: (str) The name of the artifact type to retrieve.
1055
1074
  project: (str, optional) If given, a project name or path to filter on.
1056
1075
 
1057
1076
  Returns:
1058
1077
  An `ArtifactType` object.
1059
1078
  """
1060
- entity, project = self._parse_project_path(project)
1079
+ project_path = project
1080
+ entity, project = self._parse_project_path(project_path)
1081
+ # If its an Registry artifact, the entity is an org instead
1082
+ if is_artifact_registry_project(project):
1083
+ org = parse_org_from_registry_path(project_path, PathType.PROJECT)
1084
+ settings_entity = self.settings["entity"] or self.default_entity
1085
+ entity = InternalApi()._resolve_org_entity_name(
1086
+ entity=settings_entity, organization=org
1087
+ )
1061
1088
  return public.ArtifactType(self.client, entity, project, type_name)
1062
1089
 
1063
1090
  @normalize_exceptions
@@ -1066,7 +1093,7 @@ class Api:
1066
1093
  ) -> "public.ArtifactCollections":
1067
1094
  """Return a collection of matching artifact collections.
1068
1095
 
1069
- Arguments:
1096
+ Args:
1070
1097
  project_name: (str) The name of the project to filter on.
1071
1098
  type_name: (str) The name of the artifact type to filter on.
1072
1099
  per_page: (int, optional) Sets the page size for query pagination. None will use the default size.
@@ -1076,6 +1103,13 @@ class Api:
1076
1103
  An iterable `ArtifactCollections` object.
1077
1104
  """
1078
1105
  entity, project = self._parse_project_path(project_name)
1106
+ # If iterating through Registry project, the entity is considered to be an org instead
1107
+ if is_artifact_registry_project(project):
1108
+ org = parse_org_from_registry_path(project_name, PathType.PROJECT)
1109
+ settings_entity = self.settings["entity"] or self.default_entity
1110
+ entity = InternalApi()._resolve_org_entity_name(
1111
+ entity=settings_entity, organization=org
1112
+ )
1079
1113
  return public.ArtifactCollections(
1080
1114
  self.client, entity, project, type_name, per_page=per_page
1081
1115
  )
@@ -1086,7 +1120,7 @@ class Api:
1086
1120
  ) -> "public.ArtifactCollection":
1087
1121
  """Return a single artifact collection by type and parsing path in the form `entity/project/name`.
1088
1122
 
1089
- Arguments:
1123
+ Args:
1090
1124
  type_name: (str) The type of artifact collection to fetch.
1091
1125
  name: (str) An artifact collection name. May be prefixed with entity/project.
1092
1126
 
@@ -1094,6 +1128,13 @@ class Api:
1094
1128
  An `ArtifactCollection` object.
1095
1129
  """
1096
1130
  entity, project, collection_name = self._parse_artifact_path(name)
1131
+ # If its an Registry artifact, the entity is considered to be an org instead
1132
+ if is_artifact_registry_project(project):
1133
+ org = parse_org_from_registry_path(name, PathType.ARTIFACT)
1134
+ settings_entity = self.settings["entity"] or self.default_entity
1135
+ entity = InternalApi()._resolve_org_entity_name(
1136
+ entity=settings_entity, organization=org
1137
+ )
1097
1138
  return public.ArtifactCollection(
1098
1139
  self.client, entity, project, collection_name, type_name
1099
1140
  )
@@ -1120,7 +1161,7 @@ class Api:
1120
1161
  ) -> "public.Artifacts":
1121
1162
  """Return an `Artifacts` collection from the given parameters.
1122
1163
 
1123
- Arguments:
1164
+ Args:
1124
1165
  type_name: (str) The type of artifacts to fetch.
1125
1166
  name: (str) An artifact collection name. May be prefixed with entity/project.
1126
1167
  per_page: (int, optional) Sets the page size for query pagination. None will use the default size.
@@ -1131,6 +1172,13 @@ class Api:
1131
1172
  An iterable `Artifacts` object.
1132
1173
  """
1133
1174
  entity, project, collection_name = self._parse_artifact_path(name)
1175
+ # If its an Registry project, the entity is considered to be an org instead
1176
+ if is_artifact_registry_project(project):
1177
+ org = parse_org_from_registry_path(name, PathType.ARTIFACT)
1178
+ settings_entity = self.settings["entity"] or self.default_entity
1179
+ entity = InternalApi()._resolve_org_entity_name(
1180
+ entity=settings_entity, organization=org
1181
+ )
1134
1182
  return public.Artifacts(
1135
1183
  self.client,
1136
1184
  entity,
@@ -1142,37 +1190,29 @@ class Api:
1142
1190
  )
1143
1191
 
1144
1192
  @normalize_exceptions
1145
- def artifact(self, name, type=None):
1146
- """Return a single artifact by parsing path in the form `project/name` or `entity/project/name`.
1147
-
1148
- Arguments:
1149
- name: (str) An artifact name. May be prefixed with project/ or entity/project/.
1150
- If no entity is specified in the name, the Run or API setting's entity is used.
1151
- Valid names can be in the following forms:
1152
- name:version
1153
- name:alias
1154
- type: (str, optional) The type of artifact to fetch.
1155
-
1156
- Returns:
1157
- A `Artifact` object.
1158
- """
1193
+ def _artifact(
1194
+ self, name: str, type: Optional[str] = None, enable_tracking: bool = False
1195
+ ):
1159
1196
  if name is None:
1160
1197
  raise ValueError("You must specify name= to fetch an artifact.")
1161
1198
  entity, project, artifact_name = self._parse_artifact_path(name)
1162
1199
 
1163
- organization = ""
1164
1200
  # If its an Registry artifact, the entity is an org instead
1165
1201
  if is_artifact_registry_project(project):
1166
- # Update `organization` only if an organization name was provided,
1167
- # otherwise use the default that you already set above.
1168
- try:
1169
- organization, _, _ = name.split("/")
1170
- except ValueError:
1171
- organization = ""
1202
+ organization = name.split("/")[0] if name.count("/") == 2 else ""
1172
1203
  # set entity to match the settings since in above code it was potentially set to an org
1173
- entity = self.settings["entity"] or self.default_entity
1204
+ settings_entity = self.settings["entity"] or self.default_entity
1205
+ # Registry artifacts are under the org entity. Because we offer a shorthand and alias for this path,
1206
+ # we need to fetch the org entity to for the user behind the scenes.
1207
+ entity = InternalApi()._resolve_org_entity_name(
1208
+ entity=settings_entity, organization=organization
1209
+ )
1174
1210
  artifact = wandb.Artifact._from_name(
1175
- entity, project, artifact_name, self.client, organization
1211
+ entity=entity,
1212
+ project=project,
1213
+ name=artifact_name,
1214
+ client=self.client,
1215
+ enable_tracking=enable_tracking,
1176
1216
  )
1177
1217
  if type is not None and artifact.type != type:
1178
1218
  raise ValueError(
@@ -1180,11 +1220,35 @@ class Api:
1180
1220
  )
1181
1221
  return artifact
1182
1222
 
1223
+ @normalize_exceptions
1224
+ def artifact(self, name: str, type: Optional[str] = None):
1225
+ """Return a single artifact by parsing path in the form `project/name` or `entity/project/name`.
1226
+
1227
+ Args:
1228
+ name: (str) An artifact name. May be prefixed with project/ or entity/project/.
1229
+ If no entity is specified in the name, the Run or API setting's entity is used.
1230
+ Valid names can be in the following forms:
1231
+ name:version
1232
+ name:alias
1233
+ type: (str, optional) The type of artifact to fetch.
1234
+
1235
+ Returns:
1236
+ An `Artifact` object.
1237
+
1238
+ Raises:
1239
+ ValueError: If the artifact name is not specified.
1240
+ ValueError: If the artifact type is specified but does not match the type of the fetched artifact.
1241
+
1242
+ Note:
1243
+ This method is intended for external use only. Do not call `api.artifact()` within the wandb repository code.
1244
+ """
1245
+ return self._artifact(name=name, type=type, enable_tracking=True)
1246
+
1183
1247
  @normalize_exceptions
1184
1248
  def job(self, name: Optional[str], path: Optional[str] = None) -> "public.Job":
1185
1249
  """Return a `Job` from the given parameters.
1186
1250
 
1187
- Arguments:
1251
+ Args:
1188
1252
  name: (str) The job name.
1189
1253
  path: (str, optional) If given, the root path in which to download the job artifact.
1190
1254
 
@@ -1203,7 +1267,7 @@ class Api:
1203
1267
  def list_jobs(self, entity: str, project: str) -> List[Dict[str, Any]]:
1204
1268
  """Return a list of jobs, if any, for the given entity and project.
1205
1269
 
1206
- Arguments:
1270
+ Args:
1207
1271
  entity: (str) The entity for the listed job(s).
1208
1272
  project: (str) The project for the listed job(s).
1209
1273
 
@@ -1281,7 +1345,7 @@ class Api:
1281
1345
  def artifact_exists(self, name: str, type: Optional[str] = None) -> bool:
1282
1346
  """Return whether an artifact version exists within a specified project and entity.
1283
1347
 
1284
- Arguments:
1348
+ Args:
1285
1349
  name: (str) An artifact name. May be prefixed with entity/project.
1286
1350
  If entity or project is not specified, it will be inferred from the override params if populated.
1287
1351
  Otherwise, entity will be pulled from the user settings and project will default to "uncategorized".
@@ -1294,7 +1358,7 @@ class Api:
1294
1358
  True if the artifact version exists, False otherwise.
1295
1359
  """
1296
1360
  try:
1297
- self.artifact(name, type)
1361
+ self._artifact(name, type)
1298
1362
  return True
1299
1363
  except wandb.errors.CommError:
1300
1364
  return False
@@ -1303,7 +1367,7 @@ class Api:
1303
1367
  def artifact_collection_exists(self, name: str, type: str) -> bool:
1304
1368
  """Return whether an artifact collection exists within a specified project and entity.
1305
1369
 
1306
- Arguments:
1370
+ Args:
1307
1371
  name: (str) An artifact collection name. May be prefixed with entity/project.
1308
1372
  If entity or project is not specified, it will be inferred from the override params if populated.
1309
1373
  Otherwise, entity will be pulled from the user settings and project will default to "uncategorized".
@@ -50,6 +50,7 @@ ARTIFACT_FILES_FRAGMENT = """fragment ArtifactFilesFragment on Artifact {
50
50
  updatedAt
51
51
  digest
52
52
  md5
53
+ directUrl
53
54
  }
54
55
  cursor
55
56
  }
@@ -759,6 +760,8 @@ class Artifacts(Paginator):
759
760
  per_page: int = 50,
760
761
  tags: Optional[Union[str, List[str]]] = None,
761
762
  ):
763
+ from wandb.sdk.artifacts.artifact import _gql_artifact_fragment
764
+
762
765
  self.entity = entity
763
766
  self.collection_name = collection_name
764
767
  self.type = type
@@ -804,7 +807,7 @@ class Artifacts(Paginator):
804
807
  artifact_collection_edge_name(
805
808
  server_supports_artifact_collections_gql_edges(client)
806
809
  ),
807
- wandb.Artifact._get_gql_artifact_fragment(),
810
+ _gql_artifact_fragment(),
808
811
  )
809
812
  )
810
813
  super().__init__(client, variables, per_page)
@@ -859,6 +862,8 @@ class RunArtifacts(Paginator):
859
862
  def __init__(
860
863
  self, client: Client, run: "Run", mode="logged", per_page: Optional[int] = 50
861
864
  ):
865
+ from wandb.sdk.artifacts.artifact import _gql_artifact_fragment
866
+
862
867
  output_query = gql(
863
868
  """
864
869
  query RunOutputArtifacts(
@@ -883,7 +888,7 @@ class RunArtifacts(Paginator):
883
888
  }
884
889
  }
885
890
  """
886
- + wandb.Artifact._get_gql_artifact_fragment()
891
+ + _gql_artifact_fragment()
887
892
  )
888
893
 
889
894
  input_query = gql(
@@ -910,7 +915,7 @@ class RunArtifacts(Paginator):
910
915
  }
911
916
  }
912
917
  """
913
- + wandb.Artifact._get_gql_artifact_fragment()
918
+ + _gql_artifact_fragment()
914
919
  )
915
920
 
916
921
  self.run = run
@@ -13,6 +13,7 @@ from wandb import util
13
13
  from wandb.apis.attrs import Attrs
14
14
  from wandb.apis.normalize import normalize_exceptions
15
15
  from wandb.apis.paginator import Paginator
16
+ from wandb.apis.public import utils
16
17
  from wandb.apis.public.api import Api
17
18
  from wandb.apis.public.const import RETRY_TIMEDELTA
18
19
  from wandb.sdk.lib import retry
@@ -116,7 +117,7 @@ class File(Attrs):
116
117
  mimetype (string): mimetype of file
117
118
  updated_at (string): timestamp of last update
118
119
  size (int): size of file in bytes
119
-
120
+ path_uri (str): path to file in the bucket, currently only available for files stored in S3
120
121
  """
121
122
 
122
123
  def __init__(self, client, attrs):
@@ -131,6 +132,20 @@ class File(Attrs):
131
132
  return int(size_bytes)
132
133
  return 0
133
134
 
135
+ @property
136
+ def path_uri(self) -> str:
137
+ """
138
+ Returns the uri path to the file in the storage bucket.
139
+ """
140
+ path_uri = ""
141
+ try:
142
+ path_uri = utils.parse_s3_url_to_s3_uri(self._attrs["directUrl"])
143
+ except ValueError:
144
+ wandb.termwarn("path_uri is only available for files stored in S3")
145
+ except LookupError:
146
+ wandb.termwarn("Unable to find direct_url of file")
147
+ return path_uri
148
+
134
149
  @normalize_exceptions
135
150
  @retry.retriable(
136
151
  retry_timedelta=RETRY_TIMEDELTA,
@@ -146,7 +161,7 @@ class File(Attrs):
146
161
  ) -> io.TextIOWrapper:
147
162
  """Downloads a file previously saved by a run from the wandb server.
148
163
 
149
- Arguments:
164
+ Args:
150
165
  replace (boolean): If `True`, download will overwrite a local file
151
166
  if it exists. Defaults to `False`.
152
167
  root (str): Local directory to save the file. Defaults to ".".
wandb/apis/public/jobs.py CHANGED
@@ -45,7 +45,7 @@ class Job:
45
45
 
46
46
  def __init__(self, api: "Api", name, path: Optional[str] = None) -> None:
47
47
  try:
48
- self._job_artifact = api.artifact(name, type="job")
48
+ self._job_artifact = api._artifact(name, type="job")
49
49
  except CommError:
50
50
  raise CommError(f"Job artifact {name} not found")
51
51
  if path:
@@ -94,7 +94,7 @@ class Job:
94
94
  if is_id:
95
95
  code_artifact = wandb.Artifact._from_id(artifact_string, self._api._client)
96
96
  else:
97
- code_artifact = self._api.artifact(name=artifact_string, type="code")
97
+ code_artifact = self._api._artifact(name=artifact_string, type="code")
98
98
  if code_artifact is None:
99
99
  raise LaunchError("No code artifact found")
100
100
  if code_artifact.state == ArtifactState.DELETED:
@@ -21,7 +21,7 @@ class QueryGenerator:
21
21
 
22
22
  @classmethod
23
23
  def format_order_key(cls, key: str):
24
- if key.startswith("+") or key.startswith("-"):
24
+ if key.startswith(("+", "-")):
25
25
  direction = key[0]
26
26
  key = key[1:]
27
27
  else:
wandb/apis/public/runs.py CHANGED
@@ -178,7 +178,7 @@ class Runs(Paginator):
178
178
  ):
179
179
  """Return sampled history metrics for all runs that fit the filters conditions.
180
180
 
181
- Arguments:
181
+ Args:
182
182
  samples : (int, optional) The number of samples to return per run
183
183
  keys : (list[str], optional) Only return metrics for specific keys
184
184
  x_axis : (str, optional) Use this metric as the xAxis defaults to _step
@@ -609,7 +609,7 @@ class Run(Attrs):
609
609
  def files(self, names=None, per_page=50):
610
610
  """Return a file path for each file named.
611
611
 
612
- Arguments:
612
+ Args:
613
613
  names (list): names of the requested files, if empty returns all files
614
614
  per_page (int): number of results per page.
615
615
 
@@ -622,7 +622,7 @@ class Run(Attrs):
622
622
  def file(self, name):
623
623
  """Return the path of a file with a given name in the artifact.
624
624
 
625
- Arguments:
625
+ Args:
626
626
  name (str): name of requested file.
627
627
 
628
628
  Returns:
@@ -634,7 +634,7 @@ class Run(Attrs):
634
634
  def upload_file(self, path, root="."):
635
635
  """Upload a file.
636
636
 
637
- Arguments:
637
+ Args:
638
638
  path (str): name of file to upload.
639
639
  root (str): the root path to save the file relative to. i.e.
640
640
  If you want to have the file saved in the run as "my_dir/file.txt"
@@ -662,7 +662,7 @@ class Run(Attrs):
662
662
 
663
663
  This is simpler and faster if you are ok with the history records being sampled.
664
664
 
665
- Arguments:
665
+ Args:
666
666
  samples : (int, optional) The number of samples to return
667
667
  pandas : (bool, optional) Return a pandas dataframe
668
668
  keys : (list, optional) Only return metrics for specific keys
@@ -709,7 +709,7 @@ class Run(Attrs):
709
709
  losses = [row["Loss"] for row in history]
710
710
  ```
711
711
 
712
- Arguments:
712
+ Args:
713
713
  keys ([str], optional): only fetch these keys, and only fetch rows that have all of keys defined.
714
714
  page_size (int, optional): size of pages to fetch from the api.
715
715
  min_step (int, optional): the minimum number of pages to scan at a time.
@@ -815,7 +815,7 @@ class Run(Attrs):
815
815
  def use_artifact(self, artifact, use_as=None):
816
816
  """Declare an artifact as an input to a run.
817
817
 
818
- Arguments:
818
+ Args:
819
819
  artifact (`Artifact`): An artifact returned from
820
820
  `wandb.Api().artifact(name)`
821
821
  use_as (string, optional): A string identifying
@@ -853,7 +853,7 @@ class Run(Attrs):
853
853
  ):
854
854
  """Declare an artifact as output of a run.
855
855
 
856
- Arguments:
856
+ Args:
857
857
  artifact (`Artifact`): An artifact returned from
858
858
  `wandb.Api().artifact(name)`.
859
859
  aliases (list, optional): Aliases to apply to this artifact.