wandb 0.18.4__py3-none-any.whl → 0.18.6__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- wandb/__init__.py +2 -2
- wandb/__init__.pyi +21 -19
- wandb/agents/pyagent.py +1 -1
- wandb/apis/importers/wandb.py +1 -1
- wandb/apis/normalize.py +2 -18
- wandb/apis/public/api.py +122 -62
- wandb/apis/public/artifacts.py +8 -3
- wandb/apis/public/files.py +17 -2
- wandb/apis/public/jobs.py +2 -2
- wandb/apis/public/query_generator.py +1 -1
- wandb/apis/public/runs.py +8 -8
- wandb/apis/public/teams.py +3 -3
- wandb/apis/public/users.py +1 -1
- wandb/apis/public/utils.py +68 -0
- wandb/bin/gpu_stats +0 -0
- wandb/cli/cli.py +12 -3
- wandb/data_types.py +1 -1
- wandb/docker/__init__.py +2 -1
- wandb/docker/auth.py +2 -3
- wandb/errors/links.py +73 -0
- wandb/errors/term.py +7 -6
- wandb/filesync/step_prepare.py +1 -1
- wandb/filesync/upload_job.py +1 -1
- wandb/integration/catboost/catboost.py +2 -2
- wandb/integration/diffusers/pipeline_resolver.py +1 -1
- wandb/integration/diffusers/resolvers/multimodal.py +6 -6
- wandb/integration/diffusers/resolvers/utils.py +1 -1
- wandb/integration/fastai/__init__.py +3 -2
- wandb/integration/keras/callbacks/metrics_logger.py +1 -1
- wandb/integration/keras/callbacks/model_checkpoint.py +1 -1
- wandb/integration/keras/keras.py +1 -1
- wandb/integration/kfp/kfp_patch.py +1 -1
- wandb/integration/lightgbm/__init__.py +2 -2
- wandb/integration/magic.py +2 -2
- wandb/integration/metaflow/metaflow.py +1 -1
- wandb/integration/sacred/__init__.py +1 -1
- wandb/integration/sagemaker/auth.py +1 -1
- wandb/integration/sklearn/plot/classifier.py +7 -7
- wandb/integration/sklearn/plot/clusterer.py +3 -3
- wandb/integration/sklearn/plot/regressor.py +3 -3
- wandb/integration/sklearn/plot/shared.py +2 -2
- wandb/integration/tensorboard/log.py +2 -2
- wandb/integration/ultralytics/callback.py +2 -2
- wandb/integration/xgboost/xgboost.py +1 -1
- wandb/jupyter.py +0 -1
- wandb/plot/__init__.py +17 -8
- wandb/plot/bar.py +53 -27
- wandb/plot/confusion_matrix.py +151 -70
- wandb/plot/custom_chart.py +124 -0
- wandb/plot/histogram.py +46 -20
- wandb/plot/line.py +57 -26
- wandb/plot/line_series.py +148 -60
- wandb/plot/pr_curve.py +89 -44
- wandb/plot/roc_curve.py +82 -37
- wandb/plot/scatter.py +53 -20
- wandb/plot/viz.py +20 -102
- wandb/sdk/artifacts/artifact.py +280 -328
- wandb/sdk/artifacts/artifact_manifest.py +10 -9
- wandb/sdk/artifacts/artifact_manifest_entry.py +1 -1
- wandb/sdk/artifacts/storage_handlers/azure_handler.py +9 -4
- wandb/sdk/artifacts/storage_handlers/gcs_handler.py +1 -3
- wandb/sdk/artifacts/storage_handlers/s3_handler.py +1 -1
- wandb/sdk/artifacts/storage_handlers/wb_artifact_handler.py +2 -2
- wandb/sdk/artifacts/storage_handlers/wb_local_artifact_handler.py +1 -1
- wandb/sdk/backend/backend.py +0 -1
- wandb/sdk/data_types/audio.py +1 -1
- wandb/sdk/data_types/base_types/media.py +66 -5
- wandb/sdk/data_types/bokeh.py +1 -1
- wandb/sdk/data_types/helper_types/bounding_boxes_2d.py +1 -1
- wandb/sdk/data_types/helper_types/image_mask.py +2 -2
- wandb/sdk/data_types/histogram.py +1 -1
- wandb/sdk/data_types/html.py +1 -1
- wandb/sdk/data_types/image.py +1 -1
- wandb/sdk/data_types/molecule.py +3 -3
- wandb/sdk/data_types/object_3d.py +4 -4
- wandb/sdk/data_types/plotly.py +1 -1
- wandb/sdk/data_types/saved_model.py +0 -1
- wandb/sdk/data_types/table.py +7 -7
- wandb/sdk/data_types/trace_tree.py +1 -1
- wandb/sdk/data_types/video.py +4 -3
- wandb/sdk/interface/router.py +0 -2
- wandb/sdk/internal/datastore.py +1 -1
- wandb/sdk/internal/file_pusher.py +1 -1
- wandb/sdk/internal/file_stream.py +4 -4
- wandb/sdk/internal/handler.py +3 -2
- wandb/sdk/internal/internal.py +1 -1
- wandb/sdk/internal/internal_api.py +183 -64
- wandb/sdk/internal/job_builder.py +4 -3
- wandb/sdk/internal/system/assets/__init__.py +0 -2
- wandb/sdk/internal/tb_watcher.py +11 -10
- wandb/sdk/launch/_launch.py +4 -3
- wandb/sdk/launch/_launch_add.py +2 -2
- wandb/sdk/launch/builder/kaniko_builder.py +0 -1
- wandb/sdk/launch/create_job.py +1 -0
- wandb/sdk/launch/environment/local_environment.py +0 -1
- wandb/sdk/launch/errors.py +0 -6
- wandb/sdk/launch/registry/local_registry.py +0 -2
- wandb/sdk/launch/runner/abstract.py +0 -5
- wandb/sdk/launch/sweeps/__init__.py +0 -2
- wandb/sdk/launch/sweeps/scheduler.py +0 -2
- wandb/sdk/launch/sweeps/scheduler_sweep.py +0 -1
- wandb/sdk/lib/apikey.py +3 -3
- wandb/sdk/lib/file_stream_utils.py +1 -1
- wandb/sdk/lib/filesystem.py +1 -1
- wandb/sdk/lib/ipython.py +16 -9
- wandb/sdk/lib/mailbox.py +0 -4
- wandb/sdk/lib/printer.py +44 -8
- wandb/sdk/lib/retry.py +1 -1
- wandb/sdk/service/service.py +3 -3
- wandb/sdk/service/streams.py +2 -4
- wandb/sdk/wandb_init.py +20 -20
- wandb/sdk/wandb_login.py +1 -1
- wandb/sdk/wandb_require.py +1 -4
- wandb/sdk/wandb_run.py +57 -69
- wandb/sdk/wandb_settings.py +3 -4
- wandb/sdk/wandb_sync.py +2 -1
- wandb/util.py +46 -18
- wandb/wandb_agent.py +3 -3
- wandb/wandb_controller.py +2 -2
- {wandb-0.18.4.dist-info → wandb-0.18.6.dist-info}/METADATA +1 -1
- {wandb-0.18.4.dist-info → wandb-0.18.6.dist-info}/RECORD +124 -125
- wandb/sdk/internal/system/assets/gpu_apple.py +0 -177
- wandb/sdk/lib/_wburls_generate.py +0 -25
- wandb/sdk/lib/_wburls_generated.py +0 -22
- wandb/sdk/lib/wburls.py +0 -46
- {wandb-0.18.4.dist-info → wandb-0.18.6.dist-info}/WHEEL +0 -0
- {wandb-0.18.4.dist-info → wandb-0.18.6.dist-info}/entry_points.txt +0 -0
- {wandb-0.18.4.dist-info → wandb-0.18.6.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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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.
|
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
|
-
|
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.
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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,25 @@ class Api:
|
|
1142
1190
|
)
|
1143
1191
|
|
1144
1192
|
@normalize_exceptions
|
1145
|
-
def
|
1146
|
-
|
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
|
-
|
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
|
-
|
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,
|
1211
|
+
entity, project, artifact_name, self.client, enable_tracking
|
1176
1212
|
)
|
1177
1213
|
if type is not None and artifact.type != type:
|
1178
1214
|
raise ValueError(
|
@@ -1180,11 +1216,35 @@ class Api:
|
|
1180
1216
|
)
|
1181
1217
|
return artifact
|
1182
1218
|
|
1219
|
+
@normalize_exceptions
|
1220
|
+
def artifact(self, name: str, type: Optional[str] = None):
|
1221
|
+
"""Return a single artifact by parsing path in the form `project/name` or `entity/project/name`.
|
1222
|
+
|
1223
|
+
Args:
|
1224
|
+
name: (str) An artifact name. May be prefixed with project/ or entity/project/.
|
1225
|
+
If no entity is specified in the name, the Run or API setting's entity is used.
|
1226
|
+
Valid names can be in the following forms:
|
1227
|
+
name:version
|
1228
|
+
name:alias
|
1229
|
+
type: (str, optional) The type of artifact to fetch.
|
1230
|
+
|
1231
|
+
Returns:
|
1232
|
+
An `Artifact` object.
|
1233
|
+
|
1234
|
+
Raises:
|
1235
|
+
ValueError: If the artifact name is not specified.
|
1236
|
+
ValueError: If the artifact type is specified but does not match the type of the fetched artifact.
|
1237
|
+
|
1238
|
+
Note:
|
1239
|
+
This method is intended for external use only. Do not call `api.artifact()` within the wandb repository code.
|
1240
|
+
"""
|
1241
|
+
return self._artifact(name=name, type=type, enable_tracking=True)
|
1242
|
+
|
1183
1243
|
@normalize_exceptions
|
1184
1244
|
def job(self, name: Optional[str], path: Optional[str] = None) -> "public.Job":
|
1185
1245
|
"""Return a `Job` from the given parameters.
|
1186
1246
|
|
1187
|
-
|
1247
|
+
Args:
|
1188
1248
|
name: (str) The job name.
|
1189
1249
|
path: (str, optional) If given, the root path in which to download the job artifact.
|
1190
1250
|
|
@@ -1203,7 +1263,7 @@ class Api:
|
|
1203
1263
|
def list_jobs(self, entity: str, project: str) -> List[Dict[str, Any]]:
|
1204
1264
|
"""Return a list of jobs, if any, for the given entity and project.
|
1205
1265
|
|
1206
|
-
|
1266
|
+
Args:
|
1207
1267
|
entity: (str) The entity for the listed job(s).
|
1208
1268
|
project: (str) The project for the listed job(s).
|
1209
1269
|
|
@@ -1281,7 +1341,7 @@ class Api:
|
|
1281
1341
|
def artifact_exists(self, name: str, type: Optional[str] = None) -> bool:
|
1282
1342
|
"""Return whether an artifact version exists within a specified project and entity.
|
1283
1343
|
|
1284
|
-
|
1344
|
+
Args:
|
1285
1345
|
name: (str) An artifact name. May be prefixed with entity/project.
|
1286
1346
|
If entity or project is not specified, it will be inferred from the override params if populated.
|
1287
1347
|
Otherwise, entity will be pulled from the user settings and project will default to "uncategorized".
|
@@ -1294,7 +1354,7 @@ class Api:
|
|
1294
1354
|
True if the artifact version exists, False otherwise.
|
1295
1355
|
"""
|
1296
1356
|
try:
|
1297
|
-
self.
|
1357
|
+
self._artifact(name, type)
|
1298
1358
|
return True
|
1299
1359
|
except wandb.errors.CommError:
|
1300
1360
|
return False
|
@@ -1303,7 +1363,7 @@ class Api:
|
|
1303
1363
|
def artifact_collection_exists(self, name: str, type: str) -> bool:
|
1304
1364
|
"""Return whether an artifact collection exists within a specified project and entity.
|
1305
1365
|
|
1306
|
-
|
1366
|
+
Args:
|
1307
1367
|
name: (str) An artifact collection name. May be prefixed with entity/project.
|
1308
1368
|
If entity or project is not specified, it will be inferred from the override params if populated.
|
1309
1369
|
Otherwise, entity will be pulled from the user settings and project will default to "uncategorized".
|
wandb/apis/public/artifacts.py
CHANGED
@@ -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
|
-
|
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
|
-
+
|
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
|
-
+
|
918
|
+
+ _gql_artifact_fragment()
|
914
919
|
)
|
915
920
|
|
916
921
|
self.run = run
|
wandb/apis/public/files.py
CHANGED
@@ -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
|
-
|
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.
|
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.
|
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:
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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.
|