wandb 0.21.2__py3-none-macosx_12_0_arm64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package_readme.md +97 -0
- wandb/__init__.py +248 -0
- wandb/__init__.pyi +1230 -0
- wandb/__main__.py +3 -0
- wandb/_iterutils.py +65 -0
- wandb/_pydantic/__init__.py +30 -0
- wandb/_pydantic/base.py +128 -0
- wandb/_pydantic/utils.py +80 -0
- wandb/_pydantic/v1_compat.py +284 -0
- wandb/agents/__init__.py +0 -0
- wandb/agents/pyagent.py +386 -0
- wandb/analytics/__init__.py +3 -0
- wandb/analytics/sentry.py +267 -0
- wandb/apis/__init__.py +48 -0
- wandb/apis/attrs.py +50 -0
- wandb/apis/importers/__init__.py +1 -0
- wandb/apis/importers/internals/internal.py +382 -0
- wandb/apis/importers/internals/protocols.py +103 -0
- wandb/apis/importers/internals/util.py +78 -0
- wandb/apis/importers/mlflow.py +254 -0
- wandb/apis/importers/validation.py +108 -0
- wandb/apis/importers/wandb.py +1608 -0
- wandb/apis/internal.py +239 -0
- wandb/apis/normalize.py +81 -0
- wandb/apis/paginator.py +138 -0
- wandb/apis/public/__init__.py +35 -0
- wandb/apis/public/api.py +2449 -0
- wandb/apis/public/artifacts.py +1046 -0
- wandb/apis/public/automations.py +85 -0
- wandb/apis/public/const.py +4 -0
- wandb/apis/public/files.py +402 -0
- wandb/apis/public/history.py +201 -0
- wandb/apis/public/integrations.py +203 -0
- wandb/apis/public/jobs.py +742 -0
- wandb/apis/public/projects.py +276 -0
- wandb/apis/public/query_generator.py +176 -0
- wandb/apis/public/registries/__init__.py +0 -0
- wandb/apis/public/registries/_freezable_list.py +179 -0
- wandb/apis/public/registries/_utils.py +138 -0
- wandb/apis/public/registries/registries_search.py +347 -0
- wandb/apis/public/registries/registry.py +358 -0
- wandb/apis/public/reports.py +595 -0
- wandb/apis/public/runs.py +1216 -0
- wandb/apis/public/sweeps.py +440 -0
- wandb/apis/public/teams.py +235 -0
- wandb/apis/public/users.py +177 -0
- wandb/apis/public/utils.py +210 -0
- wandb/apis/reports/__init__.py +1 -0
- wandb/apis/reports/v1/__init__.py +8 -0
- wandb/apis/reports/v2/__init__.py +8 -0
- wandb/apis/workspaces/__init__.py +8 -0
- wandb/automations/__init__.py +73 -0
- wandb/automations/_filters/__init__.py +40 -0
- wandb/automations/_filters/expressions.py +181 -0
- wandb/automations/_filters/operators.py +258 -0
- wandb/automations/_filters/run_metrics.py +330 -0
- wandb/automations/_generated/__init__.py +177 -0
- wandb/automations/_generated/create_automation.py +17 -0
- wandb/automations/_generated/create_generic_webhook_integration.py +43 -0
- wandb/automations/_generated/delete_automation.py +15 -0
- wandb/automations/_generated/enums.py +35 -0
- wandb/automations/_generated/fragments.py +358 -0
- wandb/automations/_generated/generic_webhook_integrations_by_entity.py +22 -0
- wandb/automations/_generated/get_automations.py +24 -0
- wandb/automations/_generated/get_automations_by_entity.py +26 -0
- wandb/automations/_generated/input_types.py +104 -0
- wandb/automations/_generated/integrations_by_entity.py +22 -0
- wandb/automations/_generated/operations.py +647 -0
- wandb/automations/_generated/slack_integrations_by_entity.py +22 -0
- wandb/automations/_generated/update_automation.py +17 -0
- wandb/automations/_utils.py +235 -0
- wandb/automations/_validators.py +165 -0
- wandb/automations/actions.py +218 -0
- wandb/automations/automations.py +85 -0
- wandb/automations/events.py +285 -0
- wandb/automations/integrations.py +45 -0
- wandb/automations/scopes.py +78 -0
- wandb/beta/workflows.py +324 -0
- wandb/bin/gpu_stats +0 -0
- wandb/bin/wandb-core +0 -0
- wandb/cli/__init__.py +0 -0
- wandb/cli/beta.py +175 -0
- wandb/cli/cli.py +2883 -0
- wandb/data_types.py +66 -0
- wandb/docker/__init__.py +290 -0
- wandb/docker/names.py +40 -0
- wandb/docker/wandb-entrypoint.sh +33 -0
- wandb/env.py +535 -0
- wandb/errors/__init__.py +17 -0
- wandb/errors/errors.py +40 -0
- wandb/errors/links.py +73 -0
- wandb/errors/term.py +415 -0
- wandb/errors/util.py +57 -0
- wandb/errors/warnings.py +2 -0
- wandb/filesync/__init__.py +0 -0
- wandb/filesync/dir_watcher.py +404 -0
- wandb/filesync/stats.py +100 -0
- wandb/filesync/step_checksum.py +142 -0
- wandb/filesync/step_prepare.py +179 -0
- wandb/filesync/step_upload.py +287 -0
- wandb/filesync/upload_job.py +142 -0
- wandb/integration/__init__.py +0 -0
- wandb/integration/catboost/__init__.py +5 -0
- wandb/integration/catboost/catboost.py +182 -0
- wandb/integration/cohere/__init__.py +3 -0
- wandb/integration/cohere/cohere.py +21 -0
- wandb/integration/cohere/resolver.py +347 -0
- wandb/integration/diffusers/__init__.py +3 -0
- wandb/integration/diffusers/autologger.py +76 -0
- wandb/integration/diffusers/pipeline_resolver.py +50 -0
- wandb/integration/diffusers/resolvers/__init__.py +9 -0
- wandb/integration/diffusers/resolvers/multimodal.py +881 -0
- wandb/integration/diffusers/resolvers/utils.py +102 -0
- wandb/integration/fastai/__init__.py +243 -0
- wandb/integration/gym/__init__.py +98 -0
- wandb/integration/huggingface/__init__.py +3 -0
- wandb/integration/huggingface/huggingface.py +18 -0
- wandb/integration/huggingface/resolver.py +213 -0
- wandb/integration/keras/__init__.py +11 -0
- wandb/integration/keras/callbacks/__init__.py +5 -0
- wandb/integration/keras/callbacks/metrics_logger.py +129 -0
- wandb/integration/keras/callbacks/model_checkpoint.py +188 -0
- wandb/integration/keras/callbacks/tables_builder.py +228 -0
- wandb/integration/keras/keras.py +1086 -0
- wandb/integration/kfp/__init__.py +6 -0
- wandb/integration/kfp/helpers.py +28 -0
- wandb/integration/kfp/kfp_patch.py +335 -0
- wandb/integration/kfp/wandb_logging.py +182 -0
- wandb/integration/langchain/__init__.py +3 -0
- wandb/integration/langchain/wandb_tracer.py +49 -0
- wandb/integration/lightgbm/__init__.py +239 -0
- wandb/integration/lightning/__init__.py +0 -0
- wandb/integration/lightning/fabric/__init__.py +3 -0
- wandb/integration/lightning/fabric/logger.py +763 -0
- wandb/integration/metaflow/__init__.py +9 -0
- wandb/integration/metaflow/data_pandas.py +74 -0
- wandb/integration/metaflow/data_pytorch.py +75 -0
- wandb/integration/metaflow/data_sklearn.py +76 -0
- wandb/integration/metaflow/errors.py +13 -0
- wandb/integration/metaflow/metaflow.py +327 -0
- wandb/integration/openai/__init__.py +3 -0
- wandb/integration/openai/fine_tuning.py +480 -0
- wandb/integration/openai/openai.py +22 -0
- wandb/integration/openai/resolver.py +240 -0
- wandb/integration/prodigy/__init__.py +3 -0
- wandb/integration/prodigy/prodigy.py +291 -0
- wandb/integration/sacred/__init__.py +117 -0
- wandb/integration/sagemaker/__init__.py +14 -0
- wandb/integration/sagemaker/auth.py +29 -0
- wandb/integration/sagemaker/config.py +58 -0
- wandb/integration/sagemaker/files.py +2 -0
- wandb/integration/sagemaker/resources.py +63 -0
- wandb/integration/sb3/__init__.py +3 -0
- wandb/integration/sb3/sb3.py +147 -0
- wandb/integration/sklearn/__init__.py +37 -0
- wandb/integration/sklearn/calculate/__init__.py +32 -0
- wandb/integration/sklearn/calculate/calibration_curves.py +125 -0
- wandb/integration/sklearn/calculate/class_proportions.py +68 -0
- wandb/integration/sklearn/calculate/confusion_matrix.py +93 -0
- wandb/integration/sklearn/calculate/decision_boundaries.py +40 -0
- wandb/integration/sklearn/calculate/elbow_curve.py +55 -0
- wandb/integration/sklearn/calculate/feature_importances.py +67 -0
- wandb/integration/sklearn/calculate/learning_curve.py +64 -0
- wandb/integration/sklearn/calculate/outlier_candidates.py +69 -0
- wandb/integration/sklearn/calculate/residuals.py +86 -0
- wandb/integration/sklearn/calculate/silhouette.py +118 -0
- wandb/integration/sklearn/calculate/summary_metrics.py +62 -0
- wandb/integration/sklearn/plot/__init__.py +35 -0
- wandb/integration/sklearn/plot/classifier.py +329 -0
- wandb/integration/sklearn/plot/clusterer.py +146 -0
- wandb/integration/sklearn/plot/regressor.py +121 -0
- wandb/integration/sklearn/plot/shared.py +91 -0
- wandb/integration/sklearn/utils.py +184 -0
- wandb/integration/tensorboard/__init__.py +10 -0
- wandb/integration/tensorboard/log.py +351 -0
- wandb/integration/tensorboard/monkeypatch.py +186 -0
- wandb/integration/tensorflow/__init__.py +5 -0
- wandb/integration/tensorflow/estimator_hook.py +54 -0
- wandb/integration/torch/__init__.py +0 -0
- wandb/integration/torch/wandb_torch.py +554 -0
- wandb/integration/ultralytics/__init__.py +11 -0
- wandb/integration/ultralytics/bbox_utils.py +215 -0
- wandb/integration/ultralytics/callback.py +528 -0
- wandb/integration/ultralytics/classification_utils.py +83 -0
- wandb/integration/ultralytics/mask_utils.py +202 -0
- wandb/integration/ultralytics/pose_utils.py +103 -0
- wandb/integration/weave/__init__.py +6 -0
- wandb/integration/weave/interface.py +49 -0
- wandb/integration/weave/weave.py +63 -0
- wandb/integration/xgboost/__init__.py +11 -0
- wandb/integration/xgboost/xgboost.py +189 -0
- wandb/integration/yolov8/__init__.py +0 -0
- wandb/integration/yolov8/yolov8.py +284 -0
- wandb/jupyter.py +538 -0
- wandb/mpmain/__init__.py +0 -0
- wandb/mpmain/__main__.py +1 -0
- wandb/old/__init__.py +0 -0
- wandb/old/core.py +53 -0
- wandb/old/settings.py +176 -0
- wandb/old/summary.py +438 -0
- wandb/plot/__init__.py +30 -0
- wandb/plot/bar.py +71 -0
- wandb/plot/confusion_matrix.py +185 -0
- wandb/plot/custom_chart.py +147 -0
- wandb/plot/histogram.py +66 -0
- wandb/plot/line.py +75 -0
- wandb/plot/line_series.py +173 -0
- wandb/plot/pr_curve.py +186 -0
- wandb/plot/roc_curve.py +163 -0
- wandb/plot/scatter.py +66 -0
- wandb/plot/utils.py +184 -0
- wandb/plot/viz.py +41 -0
- wandb/proto/__init__.py +0 -0
- wandb/proto/v3/__init__.py +0 -0
- wandb/proto/v3/wandb_base_pb2.py +55 -0
- wandb/proto/v3/wandb_internal_pb2.py +1728 -0
- wandb/proto/v3/wandb_server_pb2.py +228 -0
- wandb/proto/v3/wandb_settings_pb2.py +122 -0
- wandb/proto/v3/wandb_telemetry_pb2.py +106 -0
- wandb/proto/v4/__init__.py +0 -0
- wandb/proto/v4/wandb_base_pb2.py +30 -0
- wandb/proto/v4/wandb_internal_pb2.py +382 -0
- wandb/proto/v4/wandb_server_pb2.py +67 -0
- wandb/proto/v4/wandb_settings_pb2.py +47 -0
- wandb/proto/v4/wandb_telemetry_pb2.py +41 -0
- wandb/proto/v5/wandb_base_pb2.py +31 -0
- wandb/proto/v5/wandb_internal_pb2.py +383 -0
- wandb/proto/v5/wandb_server_pb2.py +68 -0
- wandb/proto/v5/wandb_settings_pb2.py +48 -0
- wandb/proto/v5/wandb_telemetry_pb2.py +42 -0
- wandb/proto/v6/wandb_base_pb2.py +41 -0
- wandb/proto/v6/wandb_internal_pb2.py +393 -0
- wandb/proto/v6/wandb_server_pb2.py +78 -0
- wandb/proto/v6/wandb_settings_pb2.py +58 -0
- wandb/proto/v6/wandb_telemetry_pb2.py +52 -0
- wandb/proto/wandb_base_pb2.py +12 -0
- wandb/proto/wandb_deprecated.py +59 -0
- wandb/proto/wandb_generate_deprecated.py +30 -0
- wandb/proto/wandb_generate_proto.py +49 -0
- wandb/proto/wandb_internal_pb2.py +18 -0
- wandb/proto/wandb_server_pb2.py +12 -0
- wandb/proto/wandb_settings_pb2.py +12 -0
- wandb/proto/wandb_telemetry_pb2.py +12 -0
- wandb/py.typed +0 -0
- wandb/sdk/__init__.py +37 -0
- wandb/sdk/artifacts/__init__.py +0 -0
- wandb/sdk/artifacts/_factories.py +17 -0
- wandb/sdk/artifacts/_generated/__init__.py +508 -0
- wandb/sdk/artifacts/_generated/add_aliases.py +21 -0
- wandb/sdk/artifacts/_generated/artifact_by_id.py +17 -0
- wandb/sdk/artifacts/_generated/artifact_by_name.py +22 -0
- wandb/sdk/artifacts/_generated/artifact_collection_membership_file_urls.py +43 -0
- wandb/sdk/artifacts/_generated/artifact_collection_membership_files.py +43 -0
- wandb/sdk/artifacts/_generated/artifact_created_by.py +47 -0
- wandb/sdk/artifacts/_generated/artifact_file_urls.py +22 -0
- wandb/sdk/artifacts/_generated/artifact_type.py +31 -0
- wandb/sdk/artifacts/_generated/artifact_used_by.py +43 -0
- wandb/sdk/artifacts/_generated/artifact_version_files.py +36 -0
- wandb/sdk/artifacts/_generated/artifact_via_membership_by_name.py +26 -0
- wandb/sdk/artifacts/_generated/create_artifact_collection_tag_assignments.py +36 -0
- wandb/sdk/artifacts/_generated/delete_aliases.py +21 -0
- wandb/sdk/artifacts/_generated/delete_artifact.py +28 -0
- wandb/sdk/artifacts/_generated/delete_artifact_collection_tag_assignments.py +25 -0
- wandb/sdk/artifacts/_generated/delete_artifact_portfolio.py +35 -0
- wandb/sdk/artifacts/_generated/delete_artifact_sequence.py +35 -0
- wandb/sdk/artifacts/_generated/enums.py +22 -0
- wandb/sdk/artifacts/_generated/fetch_artifact_manifest.py +38 -0
- wandb/sdk/artifacts/_generated/fetch_linked_artifacts.py +67 -0
- wandb/sdk/artifacts/_generated/fetch_registries.py +32 -0
- wandb/sdk/artifacts/_generated/fragments.py +459 -0
- wandb/sdk/artifacts/_generated/input_types.py +46 -0
- wandb/sdk/artifacts/_generated/link_artifact.py +27 -0
- wandb/sdk/artifacts/_generated/move_artifact_collection.py +35 -0
- wandb/sdk/artifacts/_generated/operations.py +1223 -0
- wandb/sdk/artifacts/_generated/project_artifact_collection.py +101 -0
- wandb/sdk/artifacts/_generated/project_artifact_collections.py +33 -0
- wandb/sdk/artifacts/_generated/project_artifact_type.py +24 -0
- wandb/sdk/artifacts/_generated/project_artifact_types.py +24 -0
- wandb/sdk/artifacts/_generated/project_artifacts.py +42 -0
- wandb/sdk/artifacts/_generated/registry_collections.py +34 -0
- wandb/sdk/artifacts/_generated/registry_versions.py +34 -0
- wandb/sdk/artifacts/_generated/run_input_artifacts.py +51 -0
- wandb/sdk/artifacts/_generated/run_output_artifacts.py +51 -0
- wandb/sdk/artifacts/_generated/unlink_artifact.py +25 -0
- wandb/sdk/artifacts/_generated/update_artifact.py +26 -0
- wandb/sdk/artifacts/_generated/update_artifact_portfolio.py +35 -0
- wandb/sdk/artifacts/_generated/update_artifact_sequence.py +35 -0
- wandb/sdk/artifacts/_graphql_fragments.py +19 -0
- wandb/sdk/artifacts/_internal_artifact.py +54 -0
- wandb/sdk/artifacts/_validators.py +309 -0
- wandb/sdk/artifacts/artifact.py +2702 -0
- wandb/sdk/artifacts/artifact_download_logger.py +45 -0
- wandb/sdk/artifacts/artifact_file_cache.py +251 -0
- wandb/sdk/artifacts/artifact_instance_cache.py +17 -0
- wandb/sdk/artifacts/artifact_manifest.py +76 -0
- wandb/sdk/artifacts/artifact_manifest_entry.py +258 -0
- wandb/sdk/artifacts/artifact_manifests/__init__.py +0 -0
- wandb/sdk/artifacts/artifact_manifests/artifact_manifest_v1.py +94 -0
- wandb/sdk/artifacts/artifact_saver.py +277 -0
- wandb/sdk/artifacts/artifact_state.py +13 -0
- wandb/sdk/artifacts/artifact_ttl.py +9 -0
- wandb/sdk/artifacts/exceptions.py +71 -0
- wandb/sdk/artifacts/staging.py +27 -0
- wandb/sdk/artifacts/storage_handler.py +62 -0
- wandb/sdk/artifacts/storage_handlers/__init__.py +0 -0
- wandb/sdk/artifacts/storage_handlers/azure_handler.py +214 -0
- wandb/sdk/artifacts/storage_handlers/gcs_handler.py +224 -0
- wandb/sdk/artifacts/storage_handlers/http_handler.py +114 -0
- wandb/sdk/artifacts/storage_handlers/local_file_handler.py +142 -0
- wandb/sdk/artifacts/storage_handlers/multi_handler.py +56 -0
- wandb/sdk/artifacts/storage_handlers/s3_handler.py +339 -0
- wandb/sdk/artifacts/storage_handlers/tracking_handler.py +68 -0
- wandb/sdk/artifacts/storage_handlers/wb_artifact_handler.py +131 -0
- wandb/sdk/artifacts/storage_handlers/wb_local_artifact_handler.py +74 -0
- wandb/sdk/artifacts/storage_layout.py +8 -0
- wandb/sdk/artifacts/storage_policies/__init__.py +4 -0
- wandb/sdk/artifacts/storage_policies/register.py +1 -0
- wandb/sdk/artifacts/storage_policies/wandb_storage_policy.py +580 -0
- wandb/sdk/artifacts/storage_policy.py +75 -0
- wandb/sdk/backend/__init__.py +0 -0
- wandb/sdk/backend/backend.py +57 -0
- wandb/sdk/data_types/__init__.py +0 -0
- wandb/sdk/data_types/_dtypes.py +914 -0
- wandb/sdk/data_types/_private.py +10 -0
- wandb/sdk/data_types/audio.py +208 -0
- wandb/sdk/data_types/base_types/__init__.py +0 -0
- wandb/sdk/data_types/base_types/json_metadata.py +55 -0
- wandb/sdk/data_types/base_types/media.py +339 -0
- wandb/sdk/data_types/base_types/wb_value.py +295 -0
- wandb/sdk/data_types/bokeh.py +87 -0
- wandb/sdk/data_types/graph.py +439 -0
- wandb/sdk/data_types/helper_types/__init__.py +0 -0
- wandb/sdk/data_types/helper_types/bounding_boxes_2d.py +327 -0
- wandb/sdk/data_types/helper_types/classes.py +159 -0
- wandb/sdk/data_types/helper_types/image_mask.py +251 -0
- wandb/sdk/data_types/histogram.py +107 -0
- wandb/sdk/data_types/html.py +165 -0
- wandb/sdk/data_types/image.py +974 -0
- wandb/sdk/data_types/molecule.py +250 -0
- wandb/sdk/data_types/object_3d.py +495 -0
- wandb/sdk/data_types/plotly.py +95 -0
- wandb/sdk/data_types/saved_model.py +435 -0
- wandb/sdk/data_types/table.py +1468 -0
- wandb/sdk/data_types/table_decorators.py +108 -0
- wandb/sdk/data_types/trace_tree.py +440 -0
- wandb/sdk/data_types/utils.py +260 -0
- wandb/sdk/data_types/video.py +303 -0
- wandb/sdk/integration_utils/__init__.py +0 -0
- wandb/sdk/integration_utils/auto_logging.py +232 -0
- wandb/sdk/integration_utils/data_logging.py +475 -0
- wandb/sdk/interface/__init__.py +0 -0
- wandb/sdk/interface/constants.py +4 -0
- wandb/sdk/interface/interface.py +1056 -0
- wandb/sdk/interface/interface_queue.py +40 -0
- wandb/sdk/interface/interface_shared.py +471 -0
- wandb/sdk/interface/interface_sock.py +49 -0
- wandb/sdk/interface/summary_record.py +67 -0
- wandb/sdk/internal/__init__.py +0 -0
- wandb/sdk/internal/_generated/__init__.py +15 -0
- wandb/sdk/internal/_generated/enums.py +4 -0
- wandb/sdk/internal/_generated/input_types.py +4 -0
- wandb/sdk/internal/_generated/operations.py +15 -0
- wandb/sdk/internal/_generated/server_features_query.py +27 -0
- wandb/sdk/internal/context.py +89 -0
- wandb/sdk/internal/datastore.py +293 -0
- wandb/sdk/internal/file_pusher.py +177 -0
- wandb/sdk/internal/file_stream.py +686 -0
- wandb/sdk/internal/handler.py +854 -0
- wandb/sdk/internal/incremental_table_util.py +53 -0
- wandb/sdk/internal/internal_api.py +4723 -0
- wandb/sdk/internal/job_builder.py +639 -0
- wandb/sdk/internal/profiler.py +79 -0
- wandb/sdk/internal/progress.py +77 -0
- wandb/sdk/internal/run.py +27 -0
- wandb/sdk/internal/sample.py +70 -0
- wandb/sdk/internal/sender.py +1692 -0
- wandb/sdk/internal/sender_config.py +203 -0
- wandb/sdk/internal/settings_static.py +120 -0
- wandb/sdk/internal/tb_watcher.py +519 -0
- wandb/sdk/internal/thread_local_settings.py +18 -0
- wandb/sdk/launch/__init__.py +15 -0
- wandb/sdk/launch/_launch.py +331 -0
- wandb/sdk/launch/_launch_add.py +255 -0
- wandb/sdk/launch/_project_spec.py +565 -0
- wandb/sdk/launch/agent/__init__.py +5 -0
- wandb/sdk/launch/agent/agent.py +931 -0
- wandb/sdk/launch/agent/config.py +296 -0
- wandb/sdk/launch/agent/job_status_tracker.py +55 -0
- wandb/sdk/launch/agent/run_queue_item_file_saver.py +39 -0
- wandb/sdk/launch/builder/__init__.py +0 -0
- wandb/sdk/launch/builder/abstract.py +156 -0
- wandb/sdk/launch/builder/build.py +296 -0
- wandb/sdk/launch/builder/context_manager.py +235 -0
- wandb/sdk/launch/builder/docker_builder.py +177 -0
- wandb/sdk/launch/builder/kaniko_builder.py +595 -0
- wandb/sdk/launch/builder/noop.py +58 -0
- wandb/sdk/launch/builder/templates/_wandb_bootstrap.py +188 -0
- wandb/sdk/launch/builder/templates/dockerfile.py +92 -0
- wandb/sdk/launch/create_job.py +541 -0
- wandb/sdk/launch/environment/abstract.py +29 -0
- wandb/sdk/launch/environment/aws_environment.py +322 -0
- wandb/sdk/launch/environment/azure_environment.py +105 -0
- wandb/sdk/launch/environment/gcp_environment.py +334 -0
- wandb/sdk/launch/environment/local_environment.py +65 -0
- wandb/sdk/launch/errors.py +13 -0
- wandb/sdk/launch/git_reference.py +109 -0
- wandb/sdk/launch/inputs/files.py +148 -0
- wandb/sdk/launch/inputs/internal.py +314 -0
- wandb/sdk/launch/inputs/manage.py +113 -0
- wandb/sdk/launch/inputs/schema.py +40 -0
- wandb/sdk/launch/loader.py +249 -0
- wandb/sdk/launch/registry/abstract.py +48 -0
- wandb/sdk/launch/registry/anon.py +29 -0
- wandb/sdk/launch/registry/azure_container_registry.py +124 -0
- wandb/sdk/launch/registry/elastic_container_registry.py +192 -0
- wandb/sdk/launch/registry/google_artifact_registry.py +219 -0
- wandb/sdk/launch/registry/local_registry.py +65 -0
- wandb/sdk/launch/runner/__init__.py +0 -0
- wandb/sdk/launch/runner/abstract.py +185 -0
- wandb/sdk/launch/runner/kubernetes_monitor.py +473 -0
- wandb/sdk/launch/runner/kubernetes_runner.py +1285 -0
- wandb/sdk/launch/runner/local_container.py +301 -0
- wandb/sdk/launch/runner/local_process.py +78 -0
- wandb/sdk/launch/runner/sagemaker_runner.py +424 -0
- wandb/sdk/launch/runner/vertex_runner.py +225 -0
- wandb/sdk/launch/sweeps/__init__.py +37 -0
- wandb/sdk/launch/sweeps/scheduler.py +739 -0
- wandb/sdk/launch/sweeps/scheduler_sweep.py +90 -0
- wandb/sdk/launch/sweeps/utils.py +324 -0
- wandb/sdk/launch/utils.py +746 -0
- wandb/sdk/launch/wandb_reference.py +138 -0
- wandb/sdk/lib/__init__.py +5 -0
- wandb/sdk/lib/apikey.py +334 -0
- wandb/sdk/lib/asyncio_compat.py +213 -0
- wandb/sdk/lib/asyncio_manager.py +252 -0
- wandb/sdk/lib/capped_dict.py +26 -0
- wandb/sdk/lib/config_util.py +101 -0
- wandb/sdk/lib/console_capture.py +219 -0
- wandb/sdk/lib/credentials.py +141 -0
- wandb/sdk/lib/deprecate.py +27 -0
- wandb/sdk/lib/disabled.py +30 -0
- wandb/sdk/lib/exit_hooks.py +54 -0
- wandb/sdk/lib/file_stream_utils.py +118 -0
- wandb/sdk/lib/filenames.py +64 -0
- wandb/sdk/lib/filesystem.py +372 -0
- wandb/sdk/lib/fsm.py +165 -0
- wandb/sdk/lib/gitlib.py +240 -0
- wandb/sdk/lib/gql_request.py +65 -0
- wandb/sdk/lib/handler_util.py +21 -0
- wandb/sdk/lib/hashutil.py +106 -0
- wandb/sdk/lib/import_hooks.py +275 -0
- wandb/sdk/lib/interrupt.py +37 -0
- wandb/sdk/lib/ipython.py +126 -0
- wandb/sdk/lib/json_util.py +75 -0
- wandb/sdk/lib/lazyloader.py +63 -0
- wandb/sdk/lib/module.py +72 -0
- wandb/sdk/lib/paths.py +106 -0
- wandb/sdk/lib/preinit.py +42 -0
- wandb/sdk/lib/printer.py +571 -0
- wandb/sdk/lib/printer_asyncio.py +48 -0
- wandb/sdk/lib/progress.py +320 -0
- wandb/sdk/lib/proto_util.py +90 -0
- wandb/sdk/lib/redirect.py +876 -0
- wandb/sdk/lib/retry.py +395 -0
- wandb/sdk/lib/run_moment.py +82 -0
- wandb/sdk/lib/runid.py +12 -0
- wandb/sdk/lib/server.py +58 -0
- wandb/sdk/lib/service/ipc_support.py +13 -0
- wandb/sdk/lib/service/service_client.py +106 -0
- wandb/sdk/lib/service/service_connection.py +192 -0
- wandb/sdk/lib/service/service_port_file.py +105 -0
- wandb/sdk/lib/service/service_process.py +111 -0
- wandb/sdk/lib/service/service_token.py +181 -0
- wandb/sdk/lib/sparkline.py +44 -0
- wandb/sdk/lib/telemetry.py +100 -0
- wandb/sdk/lib/timed_input.py +133 -0
- wandb/sdk/lib/timer.py +19 -0
- wandb/sdk/lib/wb_logging.py +161 -0
- wandb/sdk/mailbox/__init__.py +23 -0
- wandb/sdk/mailbox/mailbox.py +143 -0
- wandb/sdk/mailbox/mailbox_handle.py +132 -0
- wandb/sdk/mailbox/response_handle.py +99 -0
- wandb/sdk/mailbox/wait_with_progress.py +100 -0
- wandb/sdk/projects/_generated/__init__.py +47 -0
- wandb/sdk/projects/_generated/delete_project.py +22 -0
- wandb/sdk/projects/_generated/enums.py +4 -0
- wandb/sdk/projects/_generated/fetch_registry.py +22 -0
- wandb/sdk/projects/_generated/fragments.py +41 -0
- wandb/sdk/projects/_generated/input_types.py +13 -0
- wandb/sdk/projects/_generated/operations.py +88 -0
- wandb/sdk/projects/_generated/rename_project.py +27 -0
- wandb/sdk/projects/_generated/upsert_registry_project.py +27 -0
- wandb/sdk/verify/__init__.py +0 -0
- wandb/sdk/verify/verify.py +555 -0
- wandb/sdk/wandb_alerts.py +12 -0
- wandb/sdk/wandb_config.py +323 -0
- wandb/sdk/wandb_helper.py +54 -0
- wandb/sdk/wandb_init.py +1581 -0
- wandb/sdk/wandb_login.py +332 -0
- wandb/sdk/wandb_metric.py +112 -0
- wandb/sdk/wandb_require.py +88 -0
- wandb/sdk/wandb_require_helpers.py +44 -0
- wandb/sdk/wandb_run.py +4088 -0
- wandb/sdk/wandb_settings.py +2105 -0
- wandb/sdk/wandb_setup.py +560 -0
- wandb/sdk/wandb_summary.py +150 -0
- wandb/sdk/wandb_sweep.py +120 -0
- wandb/sdk/wandb_sync.py +71 -0
- wandb/sdk/wandb_watch.py +146 -0
- wandb/sklearn.py +35 -0
- wandb/sync/__init__.py +3 -0
- wandb/sync/sync.py +452 -0
- wandb/trigger.py +29 -0
- wandb/util.py +2040 -0
- wandb/vendor/__init__.py +0 -0
- wandb/vendor/gql-0.2.0/setup.py +40 -0
- wandb/vendor/gql-0.2.0/tests/__init__.py +0 -0
- wandb/vendor/gql-0.2.0/tests/starwars/__init__.py +0 -0
- wandb/vendor/gql-0.2.0/tests/starwars/fixtures.py +96 -0
- wandb/vendor/gql-0.2.0/tests/starwars/schema.py +146 -0
- wandb/vendor/gql-0.2.0/tests/starwars/test_dsl.py +293 -0
- wandb/vendor/gql-0.2.0/tests/starwars/test_query.py +355 -0
- wandb/vendor/gql-0.2.0/tests/starwars/test_validation.py +171 -0
- wandb/vendor/gql-0.2.0/tests/test_client.py +31 -0
- wandb/vendor/gql-0.2.0/tests/test_transport.py +89 -0
- wandb/vendor/gql-0.2.0/wandb_gql/__init__.py +4 -0
- wandb/vendor/gql-0.2.0/wandb_gql/client.py +75 -0
- wandb/vendor/gql-0.2.0/wandb_gql/dsl.py +152 -0
- wandb/vendor/gql-0.2.0/wandb_gql/gql.py +10 -0
- wandb/vendor/gql-0.2.0/wandb_gql/transport/__init__.py +0 -0
- wandb/vendor/gql-0.2.0/wandb_gql/transport/http.py +6 -0
- wandb/vendor/gql-0.2.0/wandb_gql/transport/local_schema.py +15 -0
- wandb/vendor/gql-0.2.0/wandb_gql/transport/requests.py +46 -0
- wandb/vendor/gql-0.2.0/wandb_gql/utils.py +21 -0
- wandb/vendor/graphql-core-1.1/setup.py +86 -0
- wandb/vendor/graphql-core-1.1/wandb_graphql/__init__.py +287 -0
- wandb/vendor/graphql-core-1.1/wandb_graphql/error/__init__.py +6 -0
- wandb/vendor/graphql-core-1.1/wandb_graphql/error/base.py +42 -0
- wandb/vendor/graphql-core-1.1/wandb_graphql/error/format_error.py +11 -0
- wandb/vendor/graphql-core-1.1/wandb_graphql/error/located_error.py +29 -0
- wandb/vendor/graphql-core-1.1/wandb_graphql/error/syntax_error.py +36 -0
- wandb/vendor/graphql-core-1.1/wandb_graphql/execution/__init__.py +26 -0
- wandb/vendor/graphql-core-1.1/wandb_graphql/execution/base.py +311 -0
- wandb/vendor/graphql-core-1.1/wandb_graphql/execution/executor.py +398 -0
- wandb/vendor/graphql-core-1.1/wandb_graphql/execution/executors/__init__.py +0 -0
- wandb/vendor/graphql-core-1.1/wandb_graphql/execution/executors/asyncio.py +53 -0
- wandb/vendor/graphql-core-1.1/wandb_graphql/execution/executors/gevent.py +22 -0
- wandb/vendor/graphql-core-1.1/wandb_graphql/execution/executors/process.py +32 -0
- wandb/vendor/graphql-core-1.1/wandb_graphql/execution/executors/sync.py +7 -0
- wandb/vendor/graphql-core-1.1/wandb_graphql/execution/executors/thread.py +35 -0
- wandb/vendor/graphql-core-1.1/wandb_graphql/execution/executors/utils.py +6 -0
- wandb/vendor/graphql-core-1.1/wandb_graphql/execution/experimental/__init__.py +0 -0
- wandb/vendor/graphql-core-1.1/wandb_graphql/execution/experimental/executor.py +66 -0
- wandb/vendor/graphql-core-1.1/wandb_graphql/execution/experimental/fragment.py +252 -0
- wandb/vendor/graphql-core-1.1/wandb_graphql/execution/experimental/resolver.py +151 -0
- wandb/vendor/graphql-core-1.1/wandb_graphql/execution/experimental/utils.py +7 -0
- wandb/vendor/graphql-core-1.1/wandb_graphql/execution/middleware.py +57 -0
- wandb/vendor/graphql-core-1.1/wandb_graphql/execution/values.py +145 -0
- wandb/vendor/graphql-core-1.1/wandb_graphql/graphql.py +60 -0
- wandb/vendor/graphql-core-1.1/wandb_graphql/language/__init__.py +0 -0
- wandb/vendor/graphql-core-1.1/wandb_graphql/language/ast.py +1349 -0
- wandb/vendor/graphql-core-1.1/wandb_graphql/language/base.py +19 -0
- wandb/vendor/graphql-core-1.1/wandb_graphql/language/lexer.py +435 -0
- wandb/vendor/graphql-core-1.1/wandb_graphql/language/location.py +30 -0
- wandb/vendor/graphql-core-1.1/wandb_graphql/language/parser.py +779 -0
- wandb/vendor/graphql-core-1.1/wandb_graphql/language/printer.py +193 -0
- wandb/vendor/graphql-core-1.1/wandb_graphql/language/source.py +18 -0
- wandb/vendor/graphql-core-1.1/wandb_graphql/language/visitor.py +222 -0
- wandb/vendor/graphql-core-1.1/wandb_graphql/language/visitor_meta.py +82 -0
- wandb/vendor/graphql-core-1.1/wandb_graphql/pyutils/__init__.py +0 -0
- wandb/vendor/graphql-core-1.1/wandb_graphql/pyutils/cached_property.py +17 -0
- wandb/vendor/graphql-core-1.1/wandb_graphql/pyutils/contain_subset.py +28 -0
- wandb/vendor/graphql-core-1.1/wandb_graphql/pyutils/default_ordered_dict.py +40 -0
- wandb/vendor/graphql-core-1.1/wandb_graphql/pyutils/ordereddict.py +8 -0
- wandb/vendor/graphql-core-1.1/wandb_graphql/pyutils/pair_set.py +43 -0
- wandb/vendor/graphql-core-1.1/wandb_graphql/pyutils/version.py +78 -0
- wandb/vendor/graphql-core-1.1/wandb_graphql/type/__init__.py +67 -0
- wandb/vendor/graphql-core-1.1/wandb_graphql/type/definition.py +619 -0
- wandb/vendor/graphql-core-1.1/wandb_graphql/type/directives.py +132 -0
- wandb/vendor/graphql-core-1.1/wandb_graphql/type/introspection.py +440 -0
- wandb/vendor/graphql-core-1.1/wandb_graphql/type/scalars.py +131 -0
- wandb/vendor/graphql-core-1.1/wandb_graphql/type/schema.py +100 -0
- wandb/vendor/graphql-core-1.1/wandb_graphql/type/typemap.py +145 -0
- wandb/vendor/graphql-core-1.1/wandb_graphql/utils/__init__.py +0 -0
- wandb/vendor/graphql-core-1.1/wandb_graphql/utils/assert_valid_name.py +9 -0
- wandb/vendor/graphql-core-1.1/wandb_graphql/utils/ast_from_value.py +65 -0
- wandb/vendor/graphql-core-1.1/wandb_graphql/utils/ast_to_code.py +49 -0
- wandb/vendor/graphql-core-1.1/wandb_graphql/utils/ast_to_dict.py +24 -0
- wandb/vendor/graphql-core-1.1/wandb_graphql/utils/base.py +75 -0
- wandb/vendor/graphql-core-1.1/wandb_graphql/utils/build_ast_schema.py +291 -0
- wandb/vendor/graphql-core-1.1/wandb_graphql/utils/build_client_schema.py +250 -0
- wandb/vendor/graphql-core-1.1/wandb_graphql/utils/concat_ast.py +9 -0
- wandb/vendor/graphql-core-1.1/wandb_graphql/utils/extend_schema.py +357 -0
- wandb/vendor/graphql-core-1.1/wandb_graphql/utils/get_field_def.py +27 -0
- wandb/vendor/graphql-core-1.1/wandb_graphql/utils/get_operation_ast.py +21 -0
- wandb/vendor/graphql-core-1.1/wandb_graphql/utils/introspection_query.py +90 -0
- wandb/vendor/graphql-core-1.1/wandb_graphql/utils/is_valid_literal_value.py +67 -0
- wandb/vendor/graphql-core-1.1/wandb_graphql/utils/is_valid_value.py +66 -0
- wandb/vendor/graphql-core-1.1/wandb_graphql/utils/quoted_or_list.py +21 -0
- wandb/vendor/graphql-core-1.1/wandb_graphql/utils/schema_printer.py +168 -0
- wandb/vendor/graphql-core-1.1/wandb_graphql/utils/suggestion_list.py +56 -0
- wandb/vendor/graphql-core-1.1/wandb_graphql/utils/type_comparators.py +69 -0
- wandb/vendor/graphql-core-1.1/wandb_graphql/utils/type_from_ast.py +21 -0
- wandb/vendor/graphql-core-1.1/wandb_graphql/utils/type_info.py +149 -0
- wandb/vendor/graphql-core-1.1/wandb_graphql/utils/value_from_ast.py +69 -0
- wandb/vendor/graphql-core-1.1/wandb_graphql/validation/__init__.py +4 -0
- wandb/vendor/graphql-core-1.1/wandb_graphql/validation/rules/__init__.py +79 -0
- wandb/vendor/graphql-core-1.1/wandb_graphql/validation/rules/arguments_of_correct_type.py +24 -0
- wandb/vendor/graphql-core-1.1/wandb_graphql/validation/rules/base.py +8 -0
- wandb/vendor/graphql-core-1.1/wandb_graphql/validation/rules/default_values_of_correct_type.py +44 -0
- wandb/vendor/graphql-core-1.1/wandb_graphql/validation/rules/fields_on_correct_type.py +113 -0
- wandb/vendor/graphql-core-1.1/wandb_graphql/validation/rules/fragments_on_composite_types.py +33 -0
- wandb/vendor/graphql-core-1.1/wandb_graphql/validation/rules/known_argument_names.py +70 -0
- wandb/vendor/graphql-core-1.1/wandb_graphql/validation/rules/known_directives.py +97 -0
- wandb/vendor/graphql-core-1.1/wandb_graphql/validation/rules/known_fragment_names.py +19 -0
- wandb/vendor/graphql-core-1.1/wandb_graphql/validation/rules/known_type_names.py +43 -0
- wandb/vendor/graphql-core-1.1/wandb_graphql/validation/rules/lone_anonymous_operation.py +23 -0
- wandb/vendor/graphql-core-1.1/wandb_graphql/validation/rules/no_fragment_cycles.py +59 -0
- wandb/vendor/graphql-core-1.1/wandb_graphql/validation/rules/no_undefined_variables.py +36 -0
- wandb/vendor/graphql-core-1.1/wandb_graphql/validation/rules/no_unused_fragments.py +38 -0
- wandb/vendor/graphql-core-1.1/wandb_graphql/validation/rules/no_unused_variables.py +37 -0
- wandb/vendor/graphql-core-1.1/wandb_graphql/validation/rules/overlapping_fields_can_be_merged.py +529 -0
- wandb/vendor/graphql-core-1.1/wandb_graphql/validation/rules/possible_fragment_spreads.py +44 -0
- wandb/vendor/graphql-core-1.1/wandb_graphql/validation/rules/provided_non_null_arguments.py +46 -0
- wandb/vendor/graphql-core-1.1/wandb_graphql/validation/rules/scalar_leafs.py +33 -0
- wandb/vendor/graphql-core-1.1/wandb_graphql/validation/rules/unique_argument_names.py +32 -0
- wandb/vendor/graphql-core-1.1/wandb_graphql/validation/rules/unique_fragment_names.py +28 -0
- wandb/vendor/graphql-core-1.1/wandb_graphql/validation/rules/unique_input_field_names.py +33 -0
- wandb/vendor/graphql-core-1.1/wandb_graphql/validation/rules/unique_operation_names.py +31 -0
- wandb/vendor/graphql-core-1.1/wandb_graphql/validation/rules/unique_variable_names.py +27 -0
- wandb/vendor/graphql-core-1.1/wandb_graphql/validation/rules/variables_are_input_types.py +21 -0
- wandb/vendor/graphql-core-1.1/wandb_graphql/validation/rules/variables_in_allowed_position.py +53 -0
- wandb/vendor/graphql-core-1.1/wandb_graphql/validation/validation.py +158 -0
- wandb/vendor/promise-2.3.0/conftest.py +30 -0
- wandb/vendor/promise-2.3.0/setup.py +64 -0
- wandb/vendor/promise-2.3.0/tests/__init__.py +0 -0
- wandb/vendor/promise-2.3.0/tests/conftest.py +8 -0
- wandb/vendor/promise-2.3.0/tests/test_awaitable.py +32 -0
- wandb/vendor/promise-2.3.0/tests/test_awaitable_35.py +47 -0
- wandb/vendor/promise-2.3.0/tests/test_benchmark.py +116 -0
- wandb/vendor/promise-2.3.0/tests/test_complex_threads.py +23 -0
- wandb/vendor/promise-2.3.0/tests/test_dataloader.py +452 -0
- wandb/vendor/promise-2.3.0/tests/test_dataloader_awaitable_35.py +99 -0
- wandb/vendor/promise-2.3.0/tests/test_dataloader_extra.py +65 -0
- wandb/vendor/promise-2.3.0/tests/test_extra.py +670 -0
- wandb/vendor/promise-2.3.0/tests/test_issues.py +132 -0
- wandb/vendor/promise-2.3.0/tests/test_promise_list.py +70 -0
- wandb/vendor/promise-2.3.0/tests/test_spec.py +584 -0
- wandb/vendor/promise-2.3.0/tests/test_thread_safety.py +115 -0
- wandb/vendor/promise-2.3.0/tests/utils.py +3 -0
- wandb/vendor/promise-2.3.0/wandb_promise/__init__.py +38 -0
- wandb/vendor/promise-2.3.0/wandb_promise/async_.py +135 -0
- wandb/vendor/promise-2.3.0/wandb_promise/compat.py +32 -0
- wandb/vendor/promise-2.3.0/wandb_promise/dataloader.py +326 -0
- wandb/vendor/promise-2.3.0/wandb_promise/iterate_promise.py +12 -0
- wandb/vendor/promise-2.3.0/wandb_promise/promise.py +848 -0
- wandb/vendor/promise-2.3.0/wandb_promise/promise_list.py +151 -0
- wandb/vendor/promise-2.3.0/wandb_promise/pyutils/__init__.py +0 -0
- wandb/vendor/promise-2.3.0/wandb_promise/pyutils/version.py +83 -0
- wandb/vendor/promise-2.3.0/wandb_promise/schedulers/__init__.py +0 -0
- wandb/vendor/promise-2.3.0/wandb_promise/schedulers/asyncio.py +22 -0
- wandb/vendor/promise-2.3.0/wandb_promise/schedulers/gevent.py +21 -0
- wandb/vendor/promise-2.3.0/wandb_promise/schedulers/immediate.py +27 -0
- wandb/vendor/promise-2.3.0/wandb_promise/schedulers/thread.py +18 -0
- wandb/vendor/promise-2.3.0/wandb_promise/utils.py +56 -0
- wandb/vendor/pygments/__init__.py +90 -0
- wandb/vendor/pygments/cmdline.py +568 -0
- wandb/vendor/pygments/console.py +74 -0
- wandb/vendor/pygments/filter.py +74 -0
- wandb/vendor/pygments/filters/__init__.py +350 -0
- wandb/vendor/pygments/formatter.py +95 -0
- wandb/vendor/pygments/formatters/__init__.py +153 -0
- wandb/vendor/pygments/formatters/_mapping.py +85 -0
- wandb/vendor/pygments/formatters/bbcode.py +109 -0
- wandb/vendor/pygments/formatters/html.py +851 -0
- wandb/vendor/pygments/formatters/img.py +600 -0
- wandb/vendor/pygments/formatters/irc.py +182 -0
- wandb/vendor/pygments/formatters/latex.py +482 -0
- wandb/vendor/pygments/formatters/other.py +160 -0
- wandb/vendor/pygments/formatters/rtf.py +147 -0
- wandb/vendor/pygments/formatters/svg.py +153 -0
- wandb/vendor/pygments/formatters/terminal.py +136 -0
- wandb/vendor/pygments/formatters/terminal256.py +309 -0
- wandb/vendor/pygments/lexer.py +871 -0
- wandb/vendor/pygments/lexers/__init__.py +329 -0
- wandb/vendor/pygments/lexers/_asy_builtins.py +1645 -0
- wandb/vendor/pygments/lexers/_cl_builtins.py +232 -0
- wandb/vendor/pygments/lexers/_cocoa_builtins.py +72 -0
- wandb/vendor/pygments/lexers/_csound_builtins.py +1346 -0
- wandb/vendor/pygments/lexers/_lasso_builtins.py +5327 -0
- wandb/vendor/pygments/lexers/_lua_builtins.py +295 -0
- wandb/vendor/pygments/lexers/_mapping.py +500 -0
- wandb/vendor/pygments/lexers/_mql_builtins.py +1172 -0
- wandb/vendor/pygments/lexers/_openedge_builtins.py +2547 -0
- wandb/vendor/pygments/lexers/_php_builtins.py +4756 -0
- wandb/vendor/pygments/lexers/_postgres_builtins.py +621 -0
- wandb/vendor/pygments/lexers/_scilab_builtins.py +3094 -0
- wandb/vendor/pygments/lexers/_sourcemod_builtins.py +1163 -0
- wandb/vendor/pygments/lexers/_stan_builtins.py +532 -0
- wandb/vendor/pygments/lexers/_stata_builtins.py +419 -0
- wandb/vendor/pygments/lexers/_tsql_builtins.py +1004 -0
- wandb/vendor/pygments/lexers/_vim_builtins.py +1939 -0
- wandb/vendor/pygments/lexers/actionscript.py +240 -0
- wandb/vendor/pygments/lexers/agile.py +24 -0
- wandb/vendor/pygments/lexers/algebra.py +221 -0
- wandb/vendor/pygments/lexers/ambient.py +76 -0
- wandb/vendor/pygments/lexers/ampl.py +87 -0
- wandb/vendor/pygments/lexers/apl.py +101 -0
- wandb/vendor/pygments/lexers/archetype.py +318 -0
- wandb/vendor/pygments/lexers/asm.py +641 -0
- wandb/vendor/pygments/lexers/automation.py +374 -0
- wandb/vendor/pygments/lexers/basic.py +500 -0
- wandb/vendor/pygments/lexers/bibtex.py +160 -0
- wandb/vendor/pygments/lexers/business.py +612 -0
- wandb/vendor/pygments/lexers/c_cpp.py +252 -0
- wandb/vendor/pygments/lexers/c_like.py +541 -0
- wandb/vendor/pygments/lexers/capnproto.py +78 -0
- wandb/vendor/pygments/lexers/chapel.py +102 -0
- wandb/vendor/pygments/lexers/clean.py +288 -0
- wandb/vendor/pygments/lexers/compiled.py +34 -0
- wandb/vendor/pygments/lexers/configs.py +833 -0
- wandb/vendor/pygments/lexers/console.py +114 -0
- wandb/vendor/pygments/lexers/crystal.py +393 -0
- wandb/vendor/pygments/lexers/csound.py +366 -0
- wandb/vendor/pygments/lexers/css.py +689 -0
- wandb/vendor/pygments/lexers/d.py +251 -0
- wandb/vendor/pygments/lexers/dalvik.py +125 -0
- wandb/vendor/pygments/lexers/data.py +555 -0
- wandb/vendor/pygments/lexers/diff.py +165 -0
- wandb/vendor/pygments/lexers/dotnet.py +691 -0
- wandb/vendor/pygments/lexers/dsls.py +878 -0
- wandb/vendor/pygments/lexers/dylan.py +289 -0
- wandb/vendor/pygments/lexers/ecl.py +125 -0
- wandb/vendor/pygments/lexers/eiffel.py +65 -0
- wandb/vendor/pygments/lexers/elm.py +121 -0
- wandb/vendor/pygments/lexers/erlang.py +533 -0
- wandb/vendor/pygments/lexers/esoteric.py +277 -0
- wandb/vendor/pygments/lexers/ezhil.py +69 -0
- wandb/vendor/pygments/lexers/factor.py +344 -0
- wandb/vendor/pygments/lexers/fantom.py +250 -0
- wandb/vendor/pygments/lexers/felix.py +273 -0
- wandb/vendor/pygments/lexers/forth.py +177 -0
- wandb/vendor/pygments/lexers/fortran.py +205 -0
- wandb/vendor/pygments/lexers/foxpro.py +428 -0
- wandb/vendor/pygments/lexers/functional.py +21 -0
- wandb/vendor/pygments/lexers/go.py +101 -0
- wandb/vendor/pygments/lexers/grammar_notation.py +213 -0
- wandb/vendor/pygments/lexers/graph.py +80 -0
- wandb/vendor/pygments/lexers/graphics.py +553 -0
- wandb/vendor/pygments/lexers/haskell.py +843 -0
- wandb/vendor/pygments/lexers/haxe.py +936 -0
- wandb/vendor/pygments/lexers/hdl.py +382 -0
- wandb/vendor/pygments/lexers/hexdump.py +103 -0
- wandb/vendor/pygments/lexers/html.py +602 -0
- wandb/vendor/pygments/lexers/idl.py +270 -0
- wandb/vendor/pygments/lexers/igor.py +288 -0
- wandb/vendor/pygments/lexers/inferno.py +96 -0
- wandb/vendor/pygments/lexers/installers.py +322 -0
- wandb/vendor/pygments/lexers/int_fiction.py +1343 -0
- wandb/vendor/pygments/lexers/iolang.py +63 -0
- wandb/vendor/pygments/lexers/j.py +146 -0
- wandb/vendor/pygments/lexers/javascript.py +1525 -0
- wandb/vendor/pygments/lexers/julia.py +333 -0
- wandb/vendor/pygments/lexers/jvm.py +1573 -0
- wandb/vendor/pygments/lexers/lisp.py +2621 -0
- wandb/vendor/pygments/lexers/make.py +202 -0
- wandb/vendor/pygments/lexers/markup.py +595 -0
- wandb/vendor/pygments/lexers/math.py +21 -0
- wandb/vendor/pygments/lexers/matlab.py +663 -0
- wandb/vendor/pygments/lexers/ml.py +769 -0
- wandb/vendor/pygments/lexers/modeling.py +358 -0
- wandb/vendor/pygments/lexers/modula2.py +1561 -0
- wandb/vendor/pygments/lexers/monte.py +204 -0
- wandb/vendor/pygments/lexers/ncl.py +894 -0
- wandb/vendor/pygments/lexers/nimrod.py +159 -0
- wandb/vendor/pygments/lexers/nit.py +64 -0
- wandb/vendor/pygments/lexers/nix.py +136 -0
- wandb/vendor/pygments/lexers/oberon.py +105 -0
- wandb/vendor/pygments/lexers/objective.py +504 -0
- wandb/vendor/pygments/lexers/ooc.py +85 -0
- wandb/vendor/pygments/lexers/other.py +41 -0
- wandb/vendor/pygments/lexers/parasail.py +79 -0
- wandb/vendor/pygments/lexers/parsers.py +835 -0
- wandb/vendor/pygments/lexers/pascal.py +644 -0
- wandb/vendor/pygments/lexers/pawn.py +199 -0
- wandb/vendor/pygments/lexers/perl.py +620 -0
- wandb/vendor/pygments/lexers/php.py +267 -0
- wandb/vendor/pygments/lexers/praat.py +294 -0
- wandb/vendor/pygments/lexers/prolog.py +306 -0
- wandb/vendor/pygments/lexers/python.py +939 -0
- wandb/vendor/pygments/lexers/qvt.py +152 -0
- wandb/vendor/pygments/lexers/r.py +453 -0
- wandb/vendor/pygments/lexers/rdf.py +270 -0
- wandb/vendor/pygments/lexers/rebol.py +431 -0
- wandb/vendor/pygments/lexers/resource.py +85 -0
- wandb/vendor/pygments/lexers/rnc.py +67 -0
- wandb/vendor/pygments/lexers/roboconf.py +82 -0
- wandb/vendor/pygments/lexers/robotframework.py +560 -0
- wandb/vendor/pygments/lexers/ruby.py +519 -0
- wandb/vendor/pygments/lexers/rust.py +220 -0
- wandb/vendor/pygments/lexers/sas.py +228 -0
- wandb/vendor/pygments/lexers/scripting.py +1222 -0
- wandb/vendor/pygments/lexers/shell.py +794 -0
- wandb/vendor/pygments/lexers/smalltalk.py +195 -0
- wandb/vendor/pygments/lexers/smv.py +79 -0
- wandb/vendor/pygments/lexers/snobol.py +83 -0
- wandb/vendor/pygments/lexers/special.py +103 -0
- wandb/vendor/pygments/lexers/sql.py +681 -0
- wandb/vendor/pygments/lexers/stata.py +108 -0
- wandb/vendor/pygments/lexers/supercollider.py +90 -0
- wandb/vendor/pygments/lexers/tcl.py +145 -0
- wandb/vendor/pygments/lexers/templates.py +2283 -0
- wandb/vendor/pygments/lexers/testing.py +207 -0
- wandb/vendor/pygments/lexers/text.py +25 -0
- wandb/vendor/pygments/lexers/textedit.py +169 -0
- wandb/vendor/pygments/lexers/textfmts.py +297 -0
- wandb/vendor/pygments/lexers/theorem.py +458 -0
- wandb/vendor/pygments/lexers/trafficscript.py +54 -0
- wandb/vendor/pygments/lexers/typoscript.py +226 -0
- wandb/vendor/pygments/lexers/urbi.py +133 -0
- wandb/vendor/pygments/lexers/varnish.py +190 -0
- wandb/vendor/pygments/lexers/verification.py +111 -0
- wandb/vendor/pygments/lexers/web.py +24 -0
- wandb/vendor/pygments/lexers/webmisc.py +988 -0
- wandb/vendor/pygments/lexers/whiley.py +116 -0
- wandb/vendor/pygments/lexers/x10.py +69 -0
- wandb/vendor/pygments/modeline.py +44 -0
- wandb/vendor/pygments/plugin.py +68 -0
- wandb/vendor/pygments/regexopt.py +92 -0
- wandb/vendor/pygments/scanner.py +105 -0
- wandb/vendor/pygments/sphinxext.py +158 -0
- wandb/vendor/pygments/style.py +155 -0
- wandb/vendor/pygments/styles/__init__.py +80 -0
- wandb/vendor/pygments/styles/abap.py +29 -0
- wandb/vendor/pygments/styles/algol.py +63 -0
- wandb/vendor/pygments/styles/algol_nu.py +63 -0
- wandb/vendor/pygments/styles/arduino.py +98 -0
- wandb/vendor/pygments/styles/autumn.py +65 -0
- wandb/vendor/pygments/styles/borland.py +51 -0
- wandb/vendor/pygments/styles/bw.py +49 -0
- wandb/vendor/pygments/styles/colorful.py +81 -0
- wandb/vendor/pygments/styles/default.py +73 -0
- wandb/vendor/pygments/styles/emacs.py +72 -0
- wandb/vendor/pygments/styles/friendly.py +72 -0
- wandb/vendor/pygments/styles/fruity.py +42 -0
- wandb/vendor/pygments/styles/igor.py +29 -0
- wandb/vendor/pygments/styles/lovelace.py +97 -0
- wandb/vendor/pygments/styles/manni.py +75 -0
- wandb/vendor/pygments/styles/monokai.py +106 -0
- wandb/vendor/pygments/styles/murphy.py +80 -0
- wandb/vendor/pygments/styles/native.py +65 -0
- wandb/vendor/pygments/styles/paraiso_dark.py +125 -0
- wandb/vendor/pygments/styles/paraiso_light.py +125 -0
- wandb/vendor/pygments/styles/pastie.py +75 -0
- wandb/vendor/pygments/styles/perldoc.py +69 -0
- wandb/vendor/pygments/styles/rainbow_dash.py +89 -0
- wandb/vendor/pygments/styles/rrt.py +33 -0
- wandb/vendor/pygments/styles/sas.py +44 -0
- wandb/vendor/pygments/styles/stata.py +40 -0
- wandb/vendor/pygments/styles/tango.py +141 -0
- wandb/vendor/pygments/styles/trac.py +63 -0
- wandb/vendor/pygments/styles/vim.py +63 -0
- wandb/vendor/pygments/styles/vs.py +38 -0
- wandb/vendor/pygments/styles/xcode.py +51 -0
- wandb/vendor/pygments/token.py +213 -0
- wandb/vendor/pygments/unistring.py +217 -0
- wandb/vendor/pygments/util.py +388 -0
- wandb/vendor/watchdog_0_9_0/wandb_watchdog/__init__.py +17 -0
- wandb/vendor/watchdog_0_9_0/wandb_watchdog/events.py +615 -0
- wandb/vendor/watchdog_0_9_0/wandb_watchdog/observers/__init__.py +98 -0
- wandb/vendor/watchdog_0_9_0/wandb_watchdog/observers/api.py +369 -0
- wandb/vendor/watchdog_0_9_0/wandb_watchdog/observers/fsevents.py +172 -0
- wandb/vendor/watchdog_0_9_0/wandb_watchdog/observers/fsevents2.py +239 -0
- wandb/vendor/watchdog_0_9_0/wandb_watchdog/observers/inotify.py +218 -0
- wandb/vendor/watchdog_0_9_0/wandb_watchdog/observers/inotify_buffer.py +81 -0
- wandb/vendor/watchdog_0_9_0/wandb_watchdog/observers/inotify_c.py +575 -0
- wandb/vendor/watchdog_0_9_0/wandb_watchdog/observers/kqueue.py +730 -0
- wandb/vendor/watchdog_0_9_0/wandb_watchdog/observers/polling.py +145 -0
- wandb/vendor/watchdog_0_9_0/wandb_watchdog/observers/read_directory_changes.py +133 -0
- wandb/vendor/watchdog_0_9_0/wandb_watchdog/observers/winapi.py +348 -0
- wandb/vendor/watchdog_0_9_0/wandb_watchdog/patterns.py +265 -0
- wandb/vendor/watchdog_0_9_0/wandb_watchdog/tricks/__init__.py +174 -0
- wandb/vendor/watchdog_0_9_0/wandb_watchdog/utils/__init__.py +151 -0
- wandb/vendor/watchdog_0_9_0/wandb_watchdog/utils/bricks.py +249 -0
- wandb/vendor/watchdog_0_9_0/wandb_watchdog/utils/compat.py +29 -0
- wandb/vendor/watchdog_0_9_0/wandb_watchdog/utils/decorators.py +198 -0
- wandb/vendor/watchdog_0_9_0/wandb_watchdog/utils/delayed_queue.py +88 -0
- wandb/vendor/watchdog_0_9_0/wandb_watchdog/utils/dirsnapshot.py +293 -0
- wandb/vendor/watchdog_0_9_0/wandb_watchdog/utils/echo.py +157 -0
- wandb/vendor/watchdog_0_9_0/wandb_watchdog/utils/event_backport.py +41 -0
- wandb/vendor/watchdog_0_9_0/wandb_watchdog/utils/importlib2.py +40 -0
- wandb/vendor/watchdog_0_9_0/wandb_watchdog/utils/platform.py +57 -0
- wandb/vendor/watchdog_0_9_0/wandb_watchdog/utils/unicode_paths.py +64 -0
- wandb/vendor/watchdog_0_9_0/wandb_watchdog/utils/win32stat.py +123 -0
- wandb/vendor/watchdog_0_9_0/wandb_watchdog/version.py +28 -0
- wandb/vendor/watchdog_0_9_0/wandb_watchdog/watchmedo.py +577 -0
- wandb/wandb_agent.py +580 -0
- wandb/wandb_controller.py +719 -0
- wandb/wandb_run.py +8 -0
- wandb-0.21.2.dist-info/METADATA +223 -0
- wandb-0.21.2.dist-info/RECORD +904 -0
- wandb-0.21.2.dist-info/WHEEL +4 -0
- wandb-0.21.2.dist-info/entry_points.txt +3 -0
- wandb-0.21.2.dist-info/licenses/LICENSE +21 -0
wandb/apis/public/api.py
ADDED
@@ -0,0 +1,2449 @@
|
|
1
|
+
"""Use the Public API to export or update data that you have saved to W&B.
|
2
|
+
|
3
|
+
Before using this API, you'll want to log data from your script — check the
|
4
|
+
[Quickstart](https://docs.wandb.ai/quickstart) for more details.
|
5
|
+
|
6
|
+
You might use the Public API to
|
7
|
+
- update metadata or metrics for an experiment after it has been completed,
|
8
|
+
- pull down your results as a dataframe for post-hoc analysis in a Jupyter notebook, or
|
9
|
+
- check your saved model artifacts for those tagged as `ready-to-deploy`.
|
10
|
+
|
11
|
+
For more on using the Public API, check out [our guide](https://docs.wandb.com/guides/track/public-api-guide).
|
12
|
+
"""
|
13
|
+
|
14
|
+
import json
|
15
|
+
import logging
|
16
|
+
import os
|
17
|
+
import urllib
|
18
|
+
from http import HTTPStatus
|
19
|
+
from typing import (
|
20
|
+
TYPE_CHECKING,
|
21
|
+
Any,
|
22
|
+
Dict,
|
23
|
+
Iterator,
|
24
|
+
List,
|
25
|
+
Literal,
|
26
|
+
Optional,
|
27
|
+
Set,
|
28
|
+
Union,
|
29
|
+
)
|
30
|
+
|
31
|
+
import requests
|
32
|
+
from pydantic import ValidationError
|
33
|
+
from typing_extensions import Unpack
|
34
|
+
from wandb_gql import Client, gql
|
35
|
+
from wandb_gql.client import RetryError
|
36
|
+
|
37
|
+
import wandb
|
38
|
+
from wandb import env, util
|
39
|
+
from wandb._iterutils import one
|
40
|
+
from wandb.apis import public
|
41
|
+
from wandb.apis.normalize import normalize_exceptions
|
42
|
+
from wandb.apis.public.const import RETRY_TIMEDELTA
|
43
|
+
from wandb.apis.public.registries._utils import fetch_org_entity_from_organization
|
44
|
+
from wandb.apis.public.registries.registries_search import Registries
|
45
|
+
from wandb.apis.public.registries.registry import Registry
|
46
|
+
from wandb.apis.public.utils import (
|
47
|
+
PathType,
|
48
|
+
fetch_org_from_settings_or_entity,
|
49
|
+
gql_compat,
|
50
|
+
parse_org_from_registry_path,
|
51
|
+
)
|
52
|
+
from wandb.proto.wandb_deprecated import Deprecated
|
53
|
+
from wandb.proto.wandb_internal_pb2 import ServerFeature
|
54
|
+
from wandb.sdk import wandb_login
|
55
|
+
from wandb.sdk.artifacts._validators import is_artifact_registry_project
|
56
|
+
from wandb.sdk.internal.internal_api import Api as InternalApi
|
57
|
+
from wandb.sdk.internal.thread_local_settings import _thread_local_api_settings
|
58
|
+
from wandb.sdk.launch.utils import LAUNCH_DEFAULT_PROJECT
|
59
|
+
from wandb.sdk.lib import retry, runid
|
60
|
+
from wandb.sdk.lib.deprecate import deprecate
|
61
|
+
from wandb.sdk.lib.gql_request import GraphQLSession
|
62
|
+
|
63
|
+
if TYPE_CHECKING:
|
64
|
+
from wandb.automations import (
|
65
|
+
ActionType,
|
66
|
+
Automation,
|
67
|
+
EventType,
|
68
|
+
Integration,
|
69
|
+
NewAutomation,
|
70
|
+
SlackIntegration,
|
71
|
+
WebhookIntegration,
|
72
|
+
)
|
73
|
+
from wandb.automations._utils import WriteAutomationsKwargs
|
74
|
+
|
75
|
+
logger = logging.getLogger(__name__)
|
76
|
+
|
77
|
+
|
78
|
+
class RetryingClient:
|
79
|
+
"""A GraphQL client that retries requests on failure.
|
80
|
+
|
81
|
+
<!-- lazydoc-ignore-class: internal -->
|
82
|
+
"""
|
83
|
+
|
84
|
+
INFO_QUERY = gql(
|
85
|
+
"""
|
86
|
+
query ServerInfo{
|
87
|
+
serverInfo {
|
88
|
+
cliVersionInfo
|
89
|
+
latestLocalVersionInfo {
|
90
|
+
outOfDate
|
91
|
+
latestVersionString
|
92
|
+
versionOnThisInstanceString
|
93
|
+
}
|
94
|
+
}
|
95
|
+
}
|
96
|
+
"""
|
97
|
+
)
|
98
|
+
|
99
|
+
def __init__(self, client: Client):
|
100
|
+
self._server_info = None
|
101
|
+
self._client = client
|
102
|
+
|
103
|
+
@property
|
104
|
+
def app_url(self):
|
105
|
+
return util.app_url(self._client.transport.url.replace("/graphql", "")) + "/"
|
106
|
+
|
107
|
+
@retry.retriable(
|
108
|
+
retry_timedelta=RETRY_TIMEDELTA,
|
109
|
+
check_retry_fn=util.no_retry_auth,
|
110
|
+
retryable_exceptions=(RetryError, requests.RequestException),
|
111
|
+
)
|
112
|
+
def execute(
|
113
|
+
self, *args, **kwargs
|
114
|
+
): # User not encouraged to use this class directly
|
115
|
+
try:
|
116
|
+
return self._client.execute(*args, **kwargs)
|
117
|
+
except requests.exceptions.ReadTimeout:
|
118
|
+
if "timeout" not in kwargs:
|
119
|
+
timeout = self._client.transport.default_timeout
|
120
|
+
wandb.termwarn(
|
121
|
+
f"A graphql request initiated by the public wandb API timed out (timeout={timeout} sec). "
|
122
|
+
f"Create a new API with an integer timeout larger than {timeout}, e.g., `api = wandb.Api(timeout={timeout + 10})` "
|
123
|
+
f"to increase the graphql timeout."
|
124
|
+
)
|
125
|
+
raise
|
126
|
+
|
127
|
+
@property
|
128
|
+
def server_info(self):
|
129
|
+
if self._server_info is None:
|
130
|
+
self._server_info = self.execute(self.INFO_QUERY).get("serverInfo")
|
131
|
+
return self._server_info
|
132
|
+
|
133
|
+
def version_supported(
|
134
|
+
self, min_version: str
|
135
|
+
) -> bool: # User not encouraged to use this class directly
|
136
|
+
from packaging.version import parse
|
137
|
+
|
138
|
+
return parse(min_version) <= parse(
|
139
|
+
self.server_info["cliVersionInfo"]["max_cli_version"]
|
140
|
+
)
|
141
|
+
|
142
|
+
|
143
|
+
class Api:
|
144
|
+
"""Used for querying the W&B server.
|
145
|
+
|
146
|
+
Examples:
|
147
|
+
```python
|
148
|
+
import wandb
|
149
|
+
|
150
|
+
wandb.Api()
|
151
|
+
```
|
152
|
+
"""
|
153
|
+
|
154
|
+
_HTTP_TIMEOUT = env.get_http_timeout(19)
|
155
|
+
DEFAULT_ENTITY_QUERY = gql(
|
156
|
+
"""
|
157
|
+
query Viewer{
|
158
|
+
viewer {
|
159
|
+
id
|
160
|
+
entity
|
161
|
+
}
|
162
|
+
}
|
163
|
+
"""
|
164
|
+
)
|
165
|
+
|
166
|
+
VIEWER_QUERY = gql(
|
167
|
+
"""
|
168
|
+
query Viewer{
|
169
|
+
viewer {
|
170
|
+
id
|
171
|
+
flags
|
172
|
+
entity
|
173
|
+
username
|
174
|
+
email
|
175
|
+
admin
|
176
|
+
apiKeys {
|
177
|
+
edges {
|
178
|
+
node {
|
179
|
+
id
|
180
|
+
name
|
181
|
+
description
|
182
|
+
}
|
183
|
+
}
|
184
|
+
}
|
185
|
+
teams {
|
186
|
+
edges {
|
187
|
+
node {
|
188
|
+
name
|
189
|
+
}
|
190
|
+
}
|
191
|
+
}
|
192
|
+
}
|
193
|
+
}
|
194
|
+
"""
|
195
|
+
)
|
196
|
+
USERS_QUERY = gql(
|
197
|
+
"""
|
198
|
+
query SearchUsers($query: String) {
|
199
|
+
users(query: $query) {
|
200
|
+
edges {
|
201
|
+
node {
|
202
|
+
id
|
203
|
+
flags
|
204
|
+
entity
|
205
|
+
admin
|
206
|
+
email
|
207
|
+
deletedAt
|
208
|
+
username
|
209
|
+
apiKeys {
|
210
|
+
edges {
|
211
|
+
node {
|
212
|
+
id
|
213
|
+
name
|
214
|
+
description
|
215
|
+
}
|
216
|
+
}
|
217
|
+
}
|
218
|
+
teams {
|
219
|
+
edges {
|
220
|
+
node {
|
221
|
+
name
|
222
|
+
}
|
223
|
+
}
|
224
|
+
}
|
225
|
+
}
|
226
|
+
}
|
227
|
+
}
|
228
|
+
}
|
229
|
+
"""
|
230
|
+
)
|
231
|
+
|
232
|
+
CREATE_PROJECT = gql(
|
233
|
+
"""
|
234
|
+
mutation upsertModel(
|
235
|
+
$description: String
|
236
|
+
$entityName: String
|
237
|
+
$id: String
|
238
|
+
$name: String
|
239
|
+
$framework: String
|
240
|
+
$access: String
|
241
|
+
$views: JSONString
|
242
|
+
) {
|
243
|
+
upsertModel(
|
244
|
+
input: {
|
245
|
+
description: $description
|
246
|
+
entityName: $entityName
|
247
|
+
id: $id
|
248
|
+
name: $name
|
249
|
+
framework: $framework
|
250
|
+
access: $access
|
251
|
+
views: $views
|
252
|
+
}
|
253
|
+
) {
|
254
|
+
project {
|
255
|
+
id
|
256
|
+
name
|
257
|
+
entityName
|
258
|
+
description
|
259
|
+
access
|
260
|
+
views
|
261
|
+
}
|
262
|
+
model {
|
263
|
+
id
|
264
|
+
name
|
265
|
+
entityName
|
266
|
+
description
|
267
|
+
access
|
268
|
+
views
|
269
|
+
}
|
270
|
+
inserted
|
271
|
+
}
|
272
|
+
}
|
273
|
+
"""
|
274
|
+
)
|
275
|
+
|
276
|
+
def __init__(
|
277
|
+
self,
|
278
|
+
overrides: Optional[Dict[str, Any]] = None,
|
279
|
+
timeout: Optional[int] = None,
|
280
|
+
api_key: Optional[str] = None,
|
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
|
+
"""
|
293
|
+
self.settings = InternalApi().settings()
|
294
|
+
|
295
|
+
_overrides = overrides or {}
|
296
|
+
self.settings.update(_overrides)
|
297
|
+
self.settings["base_url"] = self.settings["base_url"].rstrip("/")
|
298
|
+
if "organization" in _overrides:
|
299
|
+
self.settings["organization"] = _overrides["organization"]
|
300
|
+
if "username" in _overrides and "entity" not in _overrides:
|
301
|
+
wandb.termwarn(
|
302
|
+
'Passing "username" to Api is deprecated. please use "entity" instead.'
|
303
|
+
)
|
304
|
+
self.settings["entity"] = _overrides["username"]
|
305
|
+
|
306
|
+
self._api_key = api_key
|
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
|
+
)
|
319
|
+
|
320
|
+
self._viewer = None
|
321
|
+
self._projects = {}
|
322
|
+
self._runs = {}
|
323
|
+
self._sweeps = {}
|
324
|
+
self._reports = {}
|
325
|
+
self._default_entity = None
|
326
|
+
self._timeout = timeout if timeout is not None else self._HTTP_TIMEOUT
|
327
|
+
auth = None
|
328
|
+
if not _thread_local_api_settings.cookies:
|
329
|
+
auth = ("api", self.api_key)
|
330
|
+
proxies = self.settings.get("_proxies") or json.loads(
|
331
|
+
os.environ.get("WANDB__PROXIES", "{}")
|
332
|
+
)
|
333
|
+
self._base_client = Client(
|
334
|
+
transport=GraphQLSession(
|
335
|
+
headers={
|
336
|
+
"User-Agent": self.user_agent,
|
337
|
+
"Use-Admin-Privileges": "true",
|
338
|
+
**(_thread_local_api_settings.headers or {}),
|
339
|
+
},
|
340
|
+
use_json=True,
|
341
|
+
# this timeout won't apply when the DNS lookup fails. in that case, it will be 60s
|
342
|
+
# https://bugs.python.org/issue22889
|
343
|
+
timeout=self._timeout,
|
344
|
+
auth=auth,
|
345
|
+
url="{}/graphql".format(self.settings["base_url"]),
|
346
|
+
cookies=_thread_local_api_settings.cookies,
|
347
|
+
proxies=proxies,
|
348
|
+
)
|
349
|
+
)
|
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
|
+
)
|
370
|
+
|
371
|
+
def create_project(self, name: str, entity: str) -> None:
|
372
|
+
"""Create a new project.
|
373
|
+
|
374
|
+
Args:
|
375
|
+
name: The name of the new project.
|
376
|
+
entity: The entity of the new project.
|
377
|
+
"""
|
378
|
+
self.client.execute(self.CREATE_PROJECT, {"entityName": entity, "name": name})
|
379
|
+
|
380
|
+
def create_run(
|
381
|
+
self,
|
382
|
+
*,
|
383
|
+
run_id: Optional[str] = None,
|
384
|
+
project: Optional[str] = None,
|
385
|
+
entity: Optional[str] = None,
|
386
|
+
) -> "public.Run":
|
387
|
+
"""Create a new run.
|
388
|
+
|
389
|
+
Args:
|
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.
|
396
|
+
|
397
|
+
Returns:
|
398
|
+
The newly created `Run`.
|
399
|
+
"""
|
400
|
+
if entity is None:
|
401
|
+
entity = self.default_entity
|
402
|
+
return public.Run.create(self, run_id=run_id, project=project, entity=entity)
|
403
|
+
|
404
|
+
def create_run_queue(
|
405
|
+
self,
|
406
|
+
name: str,
|
407
|
+
type: "public.RunQueueResourceType",
|
408
|
+
entity: Optional[str] = None,
|
409
|
+
prioritization_mode: Optional["public.RunQueuePrioritizationMode"] = None,
|
410
|
+
config: Optional[dict] = None,
|
411
|
+
template_variables: Optional[dict] = None,
|
412
|
+
) -> "public.RunQueue":
|
413
|
+
"""Create a new run queue in W&B Launch.
|
414
|
+
|
415
|
+
Args:
|
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.
|
428
|
+
|
429
|
+
Returns:
|
430
|
+
The newly created `RunQueue`.
|
431
|
+
|
432
|
+
Raises:
|
433
|
+
`ValueError` if any of the parameters are invalid
|
434
|
+
`wandb.Error` on wandb API errors
|
435
|
+
"""
|
436
|
+
# TODO(np): Need to check server capabilities for this feature
|
437
|
+
# 0. assert params are valid/normalized
|
438
|
+
if entity is None:
|
439
|
+
entity = self.settings["entity"] or self.default_entity
|
440
|
+
if entity is None:
|
441
|
+
raise ValueError(
|
442
|
+
"entity must be passed as a parameter, or set in settings"
|
443
|
+
)
|
444
|
+
|
445
|
+
if len(name) == 0:
|
446
|
+
raise ValueError("name must be non-empty")
|
447
|
+
if len(name) > 64:
|
448
|
+
raise ValueError("name must be less than 64 characters")
|
449
|
+
|
450
|
+
if type not in [
|
451
|
+
"local-container",
|
452
|
+
"local-process",
|
453
|
+
"kubernetes",
|
454
|
+
"sagemaker",
|
455
|
+
"gcp-vertex",
|
456
|
+
]:
|
457
|
+
raise ValueError(
|
458
|
+
"resource_type must be one of 'local-container', 'local-process', 'kubernetes', 'sagemaker', or 'gcp-vertex'"
|
459
|
+
)
|
460
|
+
|
461
|
+
if prioritization_mode:
|
462
|
+
prioritization_mode = prioritization_mode.upper()
|
463
|
+
if prioritization_mode not in ["V0"]:
|
464
|
+
raise ValueError("prioritization_mode must be 'V0' if present")
|
465
|
+
|
466
|
+
if config is None:
|
467
|
+
config = {}
|
468
|
+
|
469
|
+
# 1. create required default launch project in the entity
|
470
|
+
self.create_project(LAUNCH_DEFAULT_PROJECT, entity)
|
471
|
+
|
472
|
+
api = InternalApi(
|
473
|
+
default_settings={
|
474
|
+
"entity": entity,
|
475
|
+
"project": self.project(LAUNCH_DEFAULT_PROJECT),
|
476
|
+
},
|
477
|
+
retry_timedelta=RETRY_TIMEDELTA,
|
478
|
+
)
|
479
|
+
|
480
|
+
# 2. create default resource config, receive config id
|
481
|
+
config_json = json.dumps({"resource_args": {type: config}})
|
482
|
+
create_config_result = api.create_default_resource_config(
|
483
|
+
entity, type, config_json, template_variables
|
484
|
+
)
|
485
|
+
if not create_config_result["success"]:
|
486
|
+
raise wandb.Error("failed to create default resource config")
|
487
|
+
config_id = create_config_result["defaultResourceConfigID"]
|
488
|
+
|
489
|
+
# 3. create run queue
|
490
|
+
create_queue_result = api.create_run_queue(
|
491
|
+
entity,
|
492
|
+
LAUNCH_DEFAULT_PROJECT,
|
493
|
+
name,
|
494
|
+
"PROJECT",
|
495
|
+
prioritization_mode,
|
496
|
+
config_id,
|
497
|
+
)
|
498
|
+
if not create_queue_result["success"]:
|
499
|
+
raise wandb.Error("failed to create run queue")
|
500
|
+
|
501
|
+
return public.RunQueue(
|
502
|
+
client=self.client,
|
503
|
+
name=name,
|
504
|
+
entity=entity,
|
505
|
+
prioritization_mode=prioritization_mode,
|
506
|
+
_access="PROJECT",
|
507
|
+
_default_resource_config_id=config_id,
|
508
|
+
_default_resource_config=config,
|
509
|
+
)
|
510
|
+
|
511
|
+
def create_custom_chart(
|
512
|
+
self,
|
513
|
+
entity: str,
|
514
|
+
name: str,
|
515
|
+
display_name: str,
|
516
|
+
spec_type: Literal["vega2"],
|
517
|
+
access: Literal["private", "public"],
|
518
|
+
spec: Union[str, dict],
|
519
|
+
) -> str:
|
520
|
+
"""Create a custom chart preset and return its id.
|
521
|
+
|
522
|
+
Args:
|
523
|
+
entity: The entity (user or team) that owns the chart
|
524
|
+
name: Unique identifier for the chart preset
|
525
|
+
display_name: Human-readable name shown in the UI
|
526
|
+
spec_type: Type of specification. Must be "vega2" for Vega-Lite v2 specifications.
|
527
|
+
access: Access level for the chart:
|
528
|
+
- "private": Chart is only accessible to the entity that created it
|
529
|
+
- "public": Chart is publicly accessible
|
530
|
+
spec: The Vega/Vega-Lite specification as a dictionary or JSON string
|
531
|
+
|
532
|
+
Returns:
|
533
|
+
The ID of the created chart preset in the format "entity/name"
|
534
|
+
|
535
|
+
Raises:
|
536
|
+
wandb.Error: If chart creation fails
|
537
|
+
UnsupportedError: If the server doesn't support custom charts
|
538
|
+
|
539
|
+
Example:
|
540
|
+
```python
|
541
|
+
import wandb
|
542
|
+
|
543
|
+
api = wandb.Api()
|
544
|
+
|
545
|
+
# Define a simple bar chart specification
|
546
|
+
vega_spec = {
|
547
|
+
"$schema": "https://vega.github.io/schema/vega-lite/v6.json",
|
548
|
+
"mark": "bar",
|
549
|
+
"data": {"name": "wandb"},
|
550
|
+
"encoding": {
|
551
|
+
"x": {"field": "${field:x}", "type": "ordinal"},
|
552
|
+
"y": {"field": "${field:y}", "type": "quantitative"},
|
553
|
+
},
|
554
|
+
}
|
555
|
+
|
556
|
+
# Create the custom chart
|
557
|
+
chart_id = api.create_custom_chart(
|
558
|
+
entity="my-team",
|
559
|
+
name="my-bar-chart",
|
560
|
+
display_name="My Custom Bar Chart",
|
561
|
+
spec_type="vega2",
|
562
|
+
access="private",
|
563
|
+
spec=vega_spec,
|
564
|
+
)
|
565
|
+
|
566
|
+
# Use with wandb.plot_table()
|
567
|
+
chart = wandb.plot_table(
|
568
|
+
vega_spec_name=chart_id,
|
569
|
+
data_table=my_table,
|
570
|
+
fields={"x": "category", "y": "value"},
|
571
|
+
)
|
572
|
+
```
|
573
|
+
"""
|
574
|
+
# Convert user-facing lowercase access to backend uppercase
|
575
|
+
backend_access = access.upper()
|
576
|
+
|
577
|
+
api = InternalApi(retry_timedelta=RETRY_TIMEDELTA)
|
578
|
+
result = api.create_custom_chart(
|
579
|
+
entity=entity,
|
580
|
+
name=name,
|
581
|
+
display_name=display_name,
|
582
|
+
spec_type=spec_type,
|
583
|
+
access=backend_access,
|
584
|
+
spec=spec,
|
585
|
+
)
|
586
|
+
if result is None or result.get("chart") is None:
|
587
|
+
raise wandb.Error("failed to create custom chart")
|
588
|
+
return result["chart"]["id"]
|
589
|
+
|
590
|
+
def upsert_run_queue(
|
591
|
+
self,
|
592
|
+
name: str,
|
593
|
+
resource_config: dict,
|
594
|
+
resource_type: "public.RunQueueResourceType",
|
595
|
+
entity: Optional[str] = None,
|
596
|
+
template_variables: Optional[dict] = None,
|
597
|
+
external_links: Optional[dict] = None,
|
598
|
+
prioritization_mode: Optional["public.RunQueuePrioritizationMode"] = None,
|
599
|
+
):
|
600
|
+
"""Upsert a run queue in W&B Launch.
|
601
|
+
|
602
|
+
Args:
|
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
|
618
|
+
|
619
|
+
Returns:
|
620
|
+
The upserted `RunQueue`.
|
621
|
+
|
622
|
+
Raises:
|
623
|
+
ValueError if any of the parameters are invalid
|
624
|
+
wandb.Error on wandb API errors
|
625
|
+
"""
|
626
|
+
if entity is None:
|
627
|
+
entity = self.settings["entity"] or self.default_entity
|
628
|
+
if entity is None:
|
629
|
+
raise ValueError(
|
630
|
+
"entity must be passed as a parameter, or set in settings"
|
631
|
+
)
|
632
|
+
|
633
|
+
if len(name) == 0:
|
634
|
+
raise ValueError("name must be non-empty")
|
635
|
+
if len(name) > 64:
|
636
|
+
raise ValueError("name must be less than 64 characters")
|
637
|
+
|
638
|
+
prioritization_mode = prioritization_mode or "DISABLED"
|
639
|
+
prioritization_mode = prioritization_mode.upper()
|
640
|
+
if prioritization_mode not in ["V0", "DISABLED"]:
|
641
|
+
raise ValueError(
|
642
|
+
"prioritization_mode must be 'V0' or 'DISABLED' if present"
|
643
|
+
)
|
644
|
+
|
645
|
+
if resource_type not in [
|
646
|
+
"local-container",
|
647
|
+
"local-process",
|
648
|
+
"kubernetes",
|
649
|
+
"sagemaker",
|
650
|
+
"gcp-vertex",
|
651
|
+
]:
|
652
|
+
raise ValueError(
|
653
|
+
"resource_type must be one of 'local-container', 'local-process', 'kubernetes', 'sagemaker', or 'gcp-vertex'"
|
654
|
+
)
|
655
|
+
|
656
|
+
self.create_project(LAUNCH_DEFAULT_PROJECT, entity)
|
657
|
+
api = InternalApi(
|
658
|
+
default_settings={
|
659
|
+
"entity": entity,
|
660
|
+
"project": self.project(LAUNCH_DEFAULT_PROJECT),
|
661
|
+
},
|
662
|
+
retry_timedelta=RETRY_TIMEDELTA,
|
663
|
+
)
|
664
|
+
# User provides external_links as a dict with name: url format
|
665
|
+
# but backend stores it as a list of dicts with url and label keys.
|
666
|
+
external_links = external_links or {}
|
667
|
+
external_links = {
|
668
|
+
"links": [
|
669
|
+
{
|
670
|
+
"label": key,
|
671
|
+
"url": value,
|
672
|
+
}
|
673
|
+
for key, value in external_links.items()
|
674
|
+
]
|
675
|
+
}
|
676
|
+
upsert_run_queue_result = api.upsert_run_queue(
|
677
|
+
name,
|
678
|
+
entity,
|
679
|
+
resource_type,
|
680
|
+
{"resource_args": {resource_type: resource_config}},
|
681
|
+
template_variables=template_variables,
|
682
|
+
external_links=external_links,
|
683
|
+
prioritization_mode=prioritization_mode,
|
684
|
+
)
|
685
|
+
if not upsert_run_queue_result["success"]:
|
686
|
+
raise wandb.Error("failed to create run queue")
|
687
|
+
schema_errors = (
|
688
|
+
upsert_run_queue_result.get("configSchemaValidationErrors") or []
|
689
|
+
)
|
690
|
+
for error in schema_errors:
|
691
|
+
wandb.termwarn(f"resource config validation: {error}")
|
692
|
+
|
693
|
+
return public.RunQueue(
|
694
|
+
client=self.client,
|
695
|
+
name=name,
|
696
|
+
entity=entity,
|
697
|
+
)
|
698
|
+
|
699
|
+
def create_user(self, email: str, admin: Optional[bool] = False):
|
700
|
+
"""Create a new user.
|
701
|
+
|
702
|
+
Args:
|
703
|
+
email: The email address of the user.
|
704
|
+
admin: Set user as a global instance administrator.
|
705
|
+
|
706
|
+
Returns:
|
707
|
+
A `User` object.
|
708
|
+
"""
|
709
|
+
return public.User.create(self, email, admin)
|
710
|
+
|
711
|
+
def sync_tensorboard(self, root_dir, run_id=None, project=None, entity=None):
|
712
|
+
"""Sync a local directory containing tfevent files to wandb."""
|
713
|
+
from wandb.sync import SyncManager # TODO: circular import madness
|
714
|
+
|
715
|
+
run_id = run_id or runid.generate_id()
|
716
|
+
project = project or self.settings.get("project") or "uncategorized"
|
717
|
+
entity = entity or self.default_entity
|
718
|
+
# TODO: pipe through log_path to inform the user how to debug
|
719
|
+
sm = SyncManager(
|
720
|
+
project=project,
|
721
|
+
entity=entity,
|
722
|
+
run_id=run_id,
|
723
|
+
mark_synced=False,
|
724
|
+
app_url=self.client.app_url,
|
725
|
+
view=False,
|
726
|
+
verbose=False,
|
727
|
+
sync_tensorboard=True,
|
728
|
+
)
|
729
|
+
sm.add(root_dir)
|
730
|
+
sm.start()
|
731
|
+
while not sm.is_done():
|
732
|
+
_ = sm.poll()
|
733
|
+
return self.run("/".join([entity, project, run_id]))
|
734
|
+
|
735
|
+
@property
|
736
|
+
def client(self) -> RetryingClient:
|
737
|
+
"""Returns the client object."""
|
738
|
+
return self._client
|
739
|
+
|
740
|
+
@property
|
741
|
+
def user_agent(self) -> str:
|
742
|
+
"""Returns W&B public user agent."""
|
743
|
+
return "W&B Public Client {}".format(wandb.__version__)
|
744
|
+
|
745
|
+
@property
|
746
|
+
def api_key(self) -> Optional[str]:
|
747
|
+
"""Returns W&B API key."""
|
748
|
+
# just use thread local api key if it's set
|
749
|
+
if _thread_local_api_settings.api_key:
|
750
|
+
return _thread_local_api_settings.api_key
|
751
|
+
if self._api_key is not None:
|
752
|
+
return self._api_key
|
753
|
+
auth = requests.utils.get_netrc_auth(self.settings["base_url"])
|
754
|
+
key = None
|
755
|
+
if auth:
|
756
|
+
key = auth[-1]
|
757
|
+
# Environment should take precedence
|
758
|
+
if os.getenv("WANDB_API_KEY"):
|
759
|
+
key = os.environ["WANDB_API_KEY"]
|
760
|
+
self._api_key = key # memoize key
|
761
|
+
return key
|
762
|
+
|
763
|
+
@property
|
764
|
+
def default_entity(self) -> Optional[str]:
|
765
|
+
"""Returns the default W&B entity."""
|
766
|
+
if self._default_entity is None:
|
767
|
+
res = self._client.execute(self.DEFAULT_ENTITY_QUERY)
|
768
|
+
self._default_entity = (res.get("viewer") or {}).get("entity")
|
769
|
+
return self._default_entity
|
770
|
+
|
771
|
+
@property
|
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
|
+
"""
|
779
|
+
if self._viewer is None:
|
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)
|
789
|
+
self._default_entity = self._viewer.entity
|
790
|
+
return self._viewer
|
791
|
+
|
792
|
+
def flush(self):
|
793
|
+
"""Flush the local cache.
|
794
|
+
|
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.
|
798
|
+
"""
|
799
|
+
self._runs = {}
|
800
|
+
|
801
|
+
def from_path(self, path: str):
|
802
|
+
"""Return a run, sweep, project or report from a path.
|
803
|
+
|
804
|
+
Args:
|
805
|
+
path: The path to the project, run, sweep or report
|
806
|
+
|
807
|
+
Returns:
|
808
|
+
A `Project`, `Run`, `Sweep`, or `BetaReport` instance.
|
809
|
+
|
810
|
+
Raises:
|
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
|
+
```
|
829
|
+
"""
|
830
|
+
parts = path.strip("/ ").split("/")
|
831
|
+
if len(parts) == 1:
|
832
|
+
return self.project(path)
|
833
|
+
elif len(parts) == 2:
|
834
|
+
return self.project(parts[1], parts[0])
|
835
|
+
elif len(parts) == 3:
|
836
|
+
return self.run(path)
|
837
|
+
elif len(parts) == 4:
|
838
|
+
if parts[2].startswith("run"):
|
839
|
+
return self.run(path)
|
840
|
+
elif parts[2].startswith("sweep"):
|
841
|
+
return self.sweep(path)
|
842
|
+
elif parts[2].startswith("report"):
|
843
|
+
if "--" not in parts[-1]:
|
844
|
+
if "-" in parts[-1]:
|
845
|
+
raise wandb.Error(
|
846
|
+
"Invalid report path, should be team/project/reports/Name--XXXX"
|
847
|
+
)
|
848
|
+
else:
|
849
|
+
parts[-1] = "--" + parts[-1]
|
850
|
+
name, id = parts[-1].split("--")
|
851
|
+
return public.BetaReport(
|
852
|
+
self.client,
|
853
|
+
{
|
854
|
+
"displayName": urllib.parse.unquote(name.replace("-", " ")),
|
855
|
+
"id": id,
|
856
|
+
"spec": "{}",
|
857
|
+
},
|
858
|
+
parts[0],
|
859
|
+
parts[1],
|
860
|
+
)
|
861
|
+
raise wandb.Error(
|
862
|
+
"Invalid path, should be TEAM/PROJECT/TYPE/ID where TYPE is runs, sweeps, or reports"
|
863
|
+
)
|
864
|
+
|
865
|
+
def _parse_project_path(self, path):
|
866
|
+
"""Return project and entity for project specified by path."""
|
867
|
+
project = self.settings["project"] or "uncategorized"
|
868
|
+
entity = self.settings["entity"] or self.default_entity
|
869
|
+
if path is None:
|
870
|
+
return entity, project
|
871
|
+
parts = path.split("/", 1)
|
872
|
+
if len(parts) == 1:
|
873
|
+
return entity, path
|
874
|
+
return parts
|
875
|
+
|
876
|
+
def _parse_path(self, path):
|
877
|
+
"""Parse url, filepath, or docker paths.
|
878
|
+
|
879
|
+
Allows paths in the following formats:
|
880
|
+
- url: entity/project/runs/id
|
881
|
+
- path: entity/project/id
|
882
|
+
- docker: entity/project:id
|
883
|
+
|
884
|
+
Entity is optional and will fall back to the current logged-in user.
|
885
|
+
"""
|
886
|
+
project = self.settings["project"] or "uncategorized"
|
887
|
+
entity = self.settings["entity"] or self.default_entity
|
888
|
+
parts = (
|
889
|
+
path.replace("/runs/", "/").replace("/sweeps/", "/").strip("/ ").split("/")
|
890
|
+
)
|
891
|
+
if ":" in parts[-1]:
|
892
|
+
id = parts[-1].split(":")[-1]
|
893
|
+
parts[-1] = parts[-1].split(":")[0]
|
894
|
+
elif parts[-1]:
|
895
|
+
id = parts[-1]
|
896
|
+
if len(parts) == 1 and project != "uncategorized":
|
897
|
+
pass
|
898
|
+
elif len(parts) > 1:
|
899
|
+
project = parts[1]
|
900
|
+
if entity and id == project:
|
901
|
+
project = parts[0]
|
902
|
+
else:
|
903
|
+
entity = parts[0]
|
904
|
+
if len(parts) == 3:
|
905
|
+
entity = parts[0]
|
906
|
+
else:
|
907
|
+
project = parts[0]
|
908
|
+
return entity, project, id
|
909
|
+
|
910
|
+
def _parse_artifact_path(self, path):
|
911
|
+
"""Return project, entity and artifact name for project specified by path."""
|
912
|
+
project = self.settings["project"] or "uncategorized"
|
913
|
+
entity = self.settings["entity"] or self.default_entity
|
914
|
+
if path is None:
|
915
|
+
return entity, project
|
916
|
+
|
917
|
+
path, colon, alias = path.partition(":")
|
918
|
+
full_alias = colon + alias
|
919
|
+
|
920
|
+
parts = path.split("/")
|
921
|
+
if len(parts) > 3:
|
922
|
+
raise ValueError("Invalid artifact path: {}".format(path))
|
923
|
+
elif len(parts) == 1:
|
924
|
+
return entity, project, path + full_alias
|
925
|
+
elif len(parts) == 2:
|
926
|
+
return entity, parts[0], parts[1] + full_alias
|
927
|
+
parts[-1] += full_alias
|
928
|
+
return parts
|
929
|
+
|
930
|
+
def projects(
|
931
|
+
self, entity: Optional[str] = None, per_page: int = 200
|
932
|
+
) -> "public.Projects":
|
933
|
+
"""Get projects for a given entity.
|
934
|
+
|
935
|
+
Args:
|
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.
|
941
|
+
|
942
|
+
Returns:
|
943
|
+
A `Projects` object which is an iterable collection of `Project`objects.
|
944
|
+
"""
|
945
|
+
if entity is None:
|
946
|
+
entity = self.settings["entity"] or self.default_entity
|
947
|
+
if entity is None:
|
948
|
+
raise ValueError(
|
949
|
+
"entity must be passed as a parameter, or set in settings"
|
950
|
+
)
|
951
|
+
if entity not in self._projects:
|
952
|
+
self._projects[entity] = public.Projects(
|
953
|
+
self.client, entity, per_page=per_page
|
954
|
+
)
|
955
|
+
return self._projects[entity]
|
956
|
+
|
957
|
+
def project(self, name: str, entity: Optional[str] = None) -> "public.Project":
|
958
|
+
"""Return the `Project` with the given name (and entity, if given).
|
959
|
+
|
960
|
+
Args:
|
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`.
|
965
|
+
|
966
|
+
Returns:
|
967
|
+
A `Project` object.
|
968
|
+
"""
|
969
|
+
# For registry artifacts, capture potential org user inputted before resolving entity
|
970
|
+
org = entity if is_artifact_registry_project(name) else ""
|
971
|
+
|
972
|
+
if entity is None:
|
973
|
+
entity = self.settings["entity"] or self.default_entity
|
974
|
+
|
975
|
+
# For registry artifacts, resolve org-based entity
|
976
|
+
if is_artifact_registry_project(name):
|
977
|
+
settings_entity = self.settings["entity"] or self.default_entity
|
978
|
+
entity = InternalApi()._resolve_org_entity_name(
|
979
|
+
entity=settings_entity, organization=org
|
980
|
+
)
|
981
|
+
return public.Project(self.client, entity, name, {})
|
982
|
+
|
983
|
+
def reports(
|
984
|
+
self, path: str = "", name: Optional[str] = None, per_page: int = 50
|
985
|
+
) -> "public.Reports":
|
986
|
+
"""Get reports for a given project path.
|
987
|
+
|
988
|
+
Note: `wandb.Api.reports()` API is in beta and will likely change in
|
989
|
+
future releases.
|
990
|
+
|
991
|
+
Args:
|
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.
|
999
|
+
|
1000
|
+
Returns:
|
1001
|
+
A `Reports` object which is an iterable collection of
|
1002
|
+
`BetaReport` objects.
|
1003
|
+
|
1004
|
+
Examples:
|
1005
|
+
```python
|
1006
|
+
import wandb
|
1007
|
+
|
1008
|
+
wandb.Api.reports("entity/project")
|
1009
|
+
```
|
1010
|
+
"""
|
1011
|
+
entity, project, _ = self._parse_path(path + "/fake_run")
|
1012
|
+
|
1013
|
+
if name:
|
1014
|
+
name = urllib.parse.unquote(name)
|
1015
|
+
key = "/".join([entity, project, str(name)])
|
1016
|
+
else:
|
1017
|
+
key = "/".join([entity, project])
|
1018
|
+
|
1019
|
+
if key not in self._reports:
|
1020
|
+
self._reports[key] = public.Reports(
|
1021
|
+
self.client,
|
1022
|
+
public.Project(self.client, entity, project, {}),
|
1023
|
+
name=name,
|
1024
|
+
per_page=per_page,
|
1025
|
+
)
|
1026
|
+
return self._reports[key]
|
1027
|
+
|
1028
|
+
def create_team(
|
1029
|
+
self, team: str, admin_username: Optional[str] = None
|
1030
|
+
) -> "public.Team":
|
1031
|
+
"""Create a new team.
|
1032
|
+
|
1033
|
+
Args:
|
1034
|
+
team: The name of the team
|
1035
|
+
admin_username: Username of the admin user of the team.
|
1036
|
+
Defaults to the current user.
|
1037
|
+
|
1038
|
+
Returns:
|
1039
|
+
A `Team` object.
|
1040
|
+
"""
|
1041
|
+
return public.Team.create(self, team, admin_username)
|
1042
|
+
|
1043
|
+
def team(self, team: str) -> "public.Team":
|
1044
|
+
"""Return the matching `Team` with the given name.
|
1045
|
+
|
1046
|
+
Args:
|
1047
|
+
team: The name of the team.
|
1048
|
+
|
1049
|
+
Returns:
|
1050
|
+
A `Team` object.
|
1051
|
+
"""
|
1052
|
+
return public.Team(self.client, team)
|
1053
|
+
|
1054
|
+
def user(self, username_or_email: str) -> Optional["public.User"]:
|
1055
|
+
"""Return a user from a username or email address.
|
1056
|
+
|
1057
|
+
This function only works for local administrators. Use `api.viewer`
|
1058
|
+
to get your own user object.
|
1059
|
+
|
1060
|
+
Args:
|
1061
|
+
username_or_email: The username or email address of the user.
|
1062
|
+
|
1063
|
+
Returns:
|
1064
|
+
A `User` object or None if a user is not found.
|
1065
|
+
"""
|
1066
|
+
res = self._client.execute(self.USERS_QUERY, {"query": username_or_email})
|
1067
|
+
if len(res["users"]["edges"]) == 0:
|
1068
|
+
return None
|
1069
|
+
elif len(res["users"]["edges"]) > 1:
|
1070
|
+
wandb.termwarn(
|
1071
|
+
"Found multiple users, returning the first user matching {}".format(
|
1072
|
+
username_or_email
|
1073
|
+
)
|
1074
|
+
)
|
1075
|
+
return public.User(self._client, res["users"]["edges"][0]["node"])
|
1076
|
+
|
1077
|
+
def users(self, username_or_email: str) -> List["public.User"]:
|
1078
|
+
"""Return all users from a partial username or email address query.
|
1079
|
+
|
1080
|
+
This function only works for local administrators. Use `api.viewer`
|
1081
|
+
to get your own user object.
|
1082
|
+
|
1083
|
+
Args:
|
1084
|
+
username_or_email: The prefix or suffix of the user you want to find.
|
1085
|
+
|
1086
|
+
Returns:
|
1087
|
+
An array of `User` objects.
|
1088
|
+
"""
|
1089
|
+
res = self._client.execute(self.USERS_QUERY, {"query": username_or_email})
|
1090
|
+
return [
|
1091
|
+
public.User(self._client, edge["node"]) for edge in res["users"]["edges"]
|
1092
|
+
]
|
1093
|
+
|
1094
|
+
def runs(
|
1095
|
+
self,
|
1096
|
+
path: Optional[str] = None,
|
1097
|
+
filters: Optional[Dict[str, Any]] = None,
|
1098
|
+
order: str = "+created_at",
|
1099
|
+
per_page: int = 50,
|
1100
|
+
include_sweeps: bool = True,
|
1101
|
+
):
|
1102
|
+
"""Returns a `Runs` object, which lazily iterates over `Run` objects.
|
1103
|
+
|
1104
|
+
Fields you can filter by include:
|
1105
|
+
- `createdAt`: The timestamp when the run was created. (in ISO 8601 format, e.g. "2023-01-01T12:00:00Z")
|
1106
|
+
- `displayName`: The human-readable display name of the run. (e.g. "eager-fox-1")
|
1107
|
+
- `duration`: The total runtime of the run in seconds.
|
1108
|
+
- `group`: The group name used to organize related runs together.
|
1109
|
+
- `host`: The hostname where the run was executed.
|
1110
|
+
- `jobType`: The type of job or purpose of the run.
|
1111
|
+
- `name`: The unique identifier of the run. (e.g. "a1b2cdef")
|
1112
|
+
- `state`: The current state of the run.
|
1113
|
+
- `tags`: The tags associated with the run.
|
1114
|
+
- `username`: The username of the user who initiated the run
|
1115
|
+
|
1116
|
+
Additionally, you can filter by items in the run config or summary metrics.
|
1117
|
+
Such as `config.experiment_name`, `summary_metrics.loss`, etc.
|
1118
|
+
|
1119
|
+
For more complex filtering, you can use MongoDB query operators.
|
1120
|
+
For details, see: https://docs.mongodb.com/manual/reference/operator/query
|
1121
|
+
The following operations are supported:
|
1122
|
+
- `$and`
|
1123
|
+
- `$or`
|
1124
|
+
- `$nor`
|
1125
|
+
- `$eq`
|
1126
|
+
- `$ne`
|
1127
|
+
- `$gt`
|
1128
|
+
- `$gte`
|
1129
|
+
- `$lt`
|
1130
|
+
- `$lte`
|
1131
|
+
- `$in`
|
1132
|
+
- `$nin`
|
1133
|
+
- `$exists`
|
1134
|
+
- `$regex`
|
1135
|
+
|
1136
|
+
|
1137
|
+
|
1138
|
+
Args:
|
1139
|
+
path: (str) path to project, should be in the form: "entity/project"
|
1140
|
+
filters: (dict) queries for specific runs using the MongoDB query language.
|
1141
|
+
You can filter by run properties such as config.key, summary_metrics.key, state, entity, createdAt, etc.
|
1142
|
+
For example: `{"config.experiment_name": "foo"}` would find runs with a config entry
|
1143
|
+
of experiment name set to "foo"
|
1144
|
+
order: (str) Order can be `created_at`, `heartbeat_at`, `config.*.value`, or `summary_metrics.*`.
|
1145
|
+
If you prepend order with a + order is ascending (default).
|
1146
|
+
If you prepend order with a - order is descending.
|
1147
|
+
The default order is run.created_at from oldest to newest.
|
1148
|
+
per_page: (int) Sets the page size for query pagination.
|
1149
|
+
include_sweeps: (bool) Whether to include the sweep runs in the results.
|
1150
|
+
|
1151
|
+
Returns:
|
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
|
+
```
|
1194
|
+
"""
|
1195
|
+
entity, project = self._parse_project_path(path)
|
1196
|
+
filters = filters or {}
|
1197
|
+
key = (path or "") + str(filters) + str(order)
|
1198
|
+
if not self._runs.get(key):
|
1199
|
+
self._runs[key] = public.Runs(
|
1200
|
+
self.client,
|
1201
|
+
entity,
|
1202
|
+
project,
|
1203
|
+
filters=filters,
|
1204
|
+
order=order,
|
1205
|
+
per_page=per_page,
|
1206
|
+
include_sweeps=include_sweeps,
|
1207
|
+
)
|
1208
|
+
return self._runs[key]
|
1209
|
+
|
1210
|
+
@normalize_exceptions
|
1211
|
+
def run(self, path=""):
|
1212
|
+
"""Return a single run by parsing path in the form `entity/project/run_id`.
|
1213
|
+
|
1214
|
+
Args:
|
1215
|
+
path: Path to run in the form `entity/project/run_id`.
|
1216
|
+
If `api.entity` is set, this can be in the form `project/run_id`
|
1217
|
+
and if `api.project` is set this can just be the run_id.
|
1218
|
+
|
1219
|
+
Returns:
|
1220
|
+
A `Run` object.
|
1221
|
+
"""
|
1222
|
+
entity, project, run_id = self._parse_path(path)
|
1223
|
+
if not self._runs.get(path):
|
1224
|
+
self._runs[path] = public.Run(self.client, entity, project, run_id)
|
1225
|
+
return self._runs[path]
|
1226
|
+
|
1227
|
+
def queued_run(
|
1228
|
+
self,
|
1229
|
+
entity: str,
|
1230
|
+
project: str,
|
1231
|
+
queue_name: str,
|
1232
|
+
run_queue_item_id: str,
|
1233
|
+
project_queue=None,
|
1234
|
+
priority=None,
|
1235
|
+
):
|
1236
|
+
"""Return a single queued run based on the path.
|
1237
|
+
|
1238
|
+
Parses paths of the form `entity/project/queue_id/run_queue_item_id`.
|
1239
|
+
"""
|
1240
|
+
return public.QueuedRun(
|
1241
|
+
self.client,
|
1242
|
+
entity,
|
1243
|
+
project,
|
1244
|
+
queue_name,
|
1245
|
+
run_queue_item_id,
|
1246
|
+
project_queue=project_queue,
|
1247
|
+
priority=priority,
|
1248
|
+
)
|
1249
|
+
|
1250
|
+
def run_queue(
|
1251
|
+
self,
|
1252
|
+
entity: str,
|
1253
|
+
name: str,
|
1254
|
+
):
|
1255
|
+
"""Return the named `RunQueue` for entity.
|
1256
|
+
|
1257
|
+
See `Api.create_run_queue` for more information on how to create a run queue.
|
1258
|
+
"""
|
1259
|
+
return public.RunQueue(
|
1260
|
+
self.client,
|
1261
|
+
name,
|
1262
|
+
entity,
|
1263
|
+
)
|
1264
|
+
|
1265
|
+
@normalize_exceptions
|
1266
|
+
def sweep(self, path=""):
|
1267
|
+
"""Return a sweep by parsing path in the form `entity/project/sweep_id`.
|
1268
|
+
|
1269
|
+
Args:
|
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
|
1273
|
+
this can just be the sweep_id.
|
1274
|
+
|
1275
|
+
Returns:
|
1276
|
+
A `Sweep` object.
|
1277
|
+
"""
|
1278
|
+
entity, project, sweep_id = self._parse_path(path)
|
1279
|
+
if not self._sweeps.get(path):
|
1280
|
+
self._sweeps[path] = public.Sweep(self.client, entity, project, sweep_id)
|
1281
|
+
return self._sweeps[path]
|
1282
|
+
|
1283
|
+
@normalize_exceptions
|
1284
|
+
def artifact_types(self, project: Optional[str] = None) -> "public.ArtifactTypes":
|
1285
|
+
"""Returns a collection of matching artifact types.
|
1286
|
+
|
1287
|
+
Args:
|
1288
|
+
project: The project name or path to filter on.
|
1289
|
+
|
1290
|
+
Returns:
|
1291
|
+
An iterable `ArtifactTypes` object.
|
1292
|
+
"""
|
1293
|
+
project_path = project
|
1294
|
+
entity, project = self._parse_project_path(project_path)
|
1295
|
+
# If its a Registry project, the entity is considered to be an org instead
|
1296
|
+
if is_artifact_registry_project(project):
|
1297
|
+
settings_entity = self.settings["entity"] or self.default_entity
|
1298
|
+
org = parse_org_from_registry_path(project_path, PathType.PROJECT)
|
1299
|
+
entity = InternalApi()._resolve_org_entity_name(
|
1300
|
+
entity=settings_entity, organization=org
|
1301
|
+
)
|
1302
|
+
return public.ArtifactTypes(self.client, entity, project)
|
1303
|
+
|
1304
|
+
@normalize_exceptions
|
1305
|
+
def artifact_type(
|
1306
|
+
self, type_name: str, project: Optional[str] = None
|
1307
|
+
) -> "public.ArtifactType":
|
1308
|
+
"""Returns the matching `ArtifactType`.
|
1309
|
+
|
1310
|
+
Args:
|
1311
|
+
type_name: The name of the artifact type to retrieve.
|
1312
|
+
project: If given, a project name or path to filter on.
|
1313
|
+
|
1314
|
+
Returns:
|
1315
|
+
An `ArtifactType` object.
|
1316
|
+
"""
|
1317
|
+
project_path = project
|
1318
|
+
entity, project = self._parse_project_path(project_path)
|
1319
|
+
# If its an Registry artifact, the entity is an org instead
|
1320
|
+
if is_artifact_registry_project(project):
|
1321
|
+
org = parse_org_from_registry_path(project_path, PathType.PROJECT)
|
1322
|
+
settings_entity = self.settings["entity"] or self.default_entity
|
1323
|
+
entity = InternalApi()._resolve_org_entity_name(
|
1324
|
+
entity=settings_entity, organization=org
|
1325
|
+
)
|
1326
|
+
return public.ArtifactType(self.client, entity, project, type_name)
|
1327
|
+
|
1328
|
+
@normalize_exceptions
|
1329
|
+
def artifact_collections(
|
1330
|
+
self, project_name: str, type_name: str, per_page: int = 50
|
1331
|
+
) -> "public.ArtifactCollections":
|
1332
|
+
"""Returns a collection of matching artifact collections.
|
1333
|
+
|
1334
|
+
Args:
|
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.
|
1339
|
+
|
1340
|
+
Returns:
|
1341
|
+
An iterable `ArtifactCollections` object.
|
1342
|
+
"""
|
1343
|
+
entity, project = self._parse_project_path(project_name)
|
1344
|
+
# If iterating through Registry project, the entity is considered to be an org instead
|
1345
|
+
if is_artifact_registry_project(project):
|
1346
|
+
org = parse_org_from_registry_path(project_name, PathType.PROJECT)
|
1347
|
+
settings_entity = self.settings["entity"] or self.default_entity
|
1348
|
+
entity = InternalApi()._resolve_org_entity_name(
|
1349
|
+
entity=settings_entity, organization=org
|
1350
|
+
)
|
1351
|
+
return public.ArtifactCollections(
|
1352
|
+
self.client, entity, project, type_name, per_page=per_page
|
1353
|
+
)
|
1354
|
+
|
1355
|
+
@normalize_exceptions
|
1356
|
+
def artifact_collection(
|
1357
|
+
self, type_name: str, name: str
|
1358
|
+
) -> "public.ArtifactCollection":
|
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.
|
1363
|
+
|
1364
|
+
Args:
|
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.
|
1369
|
+
|
1370
|
+
Returns:
|
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
|
+
```
|
1392
|
+
"""
|
1393
|
+
entity, project, collection_name = self._parse_artifact_path(name)
|
1394
|
+
# If its an Registry artifact, the entity is considered to be an org instead
|
1395
|
+
if is_artifact_registry_project(project):
|
1396
|
+
org = parse_org_from_registry_path(name, PathType.ARTIFACT)
|
1397
|
+
settings_entity = self.settings["entity"] or self.default_entity
|
1398
|
+
entity = InternalApi()._resolve_org_entity_name(
|
1399
|
+
entity=settings_entity, organization=org
|
1400
|
+
)
|
1401
|
+
|
1402
|
+
if entity is None:
|
1403
|
+
raise ValueError(
|
1404
|
+
"Could not determine entity. Please include the entity as part of the collection name path."
|
1405
|
+
)
|
1406
|
+
|
1407
|
+
return public.ArtifactCollection(
|
1408
|
+
self.client, entity, project, collection_name, type_name
|
1409
|
+
)
|
1410
|
+
|
1411
|
+
@normalize_exceptions
|
1412
|
+
def artifact_versions(self, type_name, name, per_page=50):
|
1413
|
+
"""Deprecated. Use `Api.artifacts(type_name, name)` method instead."""
|
1414
|
+
deprecate(
|
1415
|
+
field_name=Deprecated.api__artifact_versions,
|
1416
|
+
warning_message=(
|
1417
|
+
"Api.artifact_versions(type_name, name) is deprecated, "
|
1418
|
+
"use Api.artifacts(type_name, name) instead."
|
1419
|
+
),
|
1420
|
+
)
|
1421
|
+
return self.artifacts(type_name, name, per_page=per_page)
|
1422
|
+
|
1423
|
+
@normalize_exceptions
|
1424
|
+
def artifacts(
|
1425
|
+
self,
|
1426
|
+
type_name: str,
|
1427
|
+
name: str,
|
1428
|
+
per_page: int = 50,
|
1429
|
+
tags: Optional[List[str]] = None,
|
1430
|
+
) -> "public.Artifacts":
|
1431
|
+
"""Return an `Artifacts` collection.
|
1432
|
+
|
1433
|
+
Args:
|
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.
|
1442
|
+
|
1443
|
+
Returns:
|
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
|
+
```
|
1457
|
+
"""
|
1458
|
+
entity, project, collection_name = self._parse_artifact_path(name)
|
1459
|
+
# If its an Registry project, the entity is considered to be an org instead
|
1460
|
+
if is_artifact_registry_project(project):
|
1461
|
+
org = parse_org_from_registry_path(name, PathType.ARTIFACT)
|
1462
|
+
settings_entity = self.settings["entity"] or self.default_entity
|
1463
|
+
entity = InternalApi()._resolve_org_entity_name(
|
1464
|
+
entity=settings_entity, organization=org
|
1465
|
+
)
|
1466
|
+
return public.Artifacts(
|
1467
|
+
self.client,
|
1468
|
+
entity,
|
1469
|
+
project,
|
1470
|
+
collection_name,
|
1471
|
+
type_name,
|
1472
|
+
per_page=per_page,
|
1473
|
+
tags=tags,
|
1474
|
+
)
|
1475
|
+
|
1476
|
+
@normalize_exceptions
|
1477
|
+
def _artifact(
|
1478
|
+
self, name: str, type: Optional[str] = None, enable_tracking: bool = False
|
1479
|
+
):
|
1480
|
+
if name is None:
|
1481
|
+
raise ValueError("You must specify name= to fetch an artifact.")
|
1482
|
+
entity, project, artifact_name = self._parse_artifact_path(name)
|
1483
|
+
|
1484
|
+
# If its an Registry artifact, the entity is an org instead
|
1485
|
+
if is_artifact_registry_project(project):
|
1486
|
+
organization = (
|
1487
|
+
name.split("/")[0]
|
1488
|
+
if name.count("/") == 2
|
1489
|
+
else self.settings["organization"]
|
1490
|
+
)
|
1491
|
+
# set entity to match the settings since in above code it was potentially set to an org
|
1492
|
+
settings_entity = self.settings["entity"] or self.default_entity
|
1493
|
+
# Registry artifacts are under the org entity. Because we offer a shorthand and alias for this path,
|
1494
|
+
# we need to fetch the org entity to for the user behind the scenes.
|
1495
|
+
entity = InternalApi()._resolve_org_entity_name(
|
1496
|
+
entity=settings_entity, organization=organization
|
1497
|
+
)
|
1498
|
+
|
1499
|
+
if entity is None:
|
1500
|
+
raise ValueError(
|
1501
|
+
"Could not determine entity. Please include the entity as part of the artifact name path."
|
1502
|
+
)
|
1503
|
+
|
1504
|
+
artifact = wandb.Artifact._from_name(
|
1505
|
+
entity=entity,
|
1506
|
+
project=project,
|
1507
|
+
name=artifact_name,
|
1508
|
+
client=self.client,
|
1509
|
+
enable_tracking=enable_tracking,
|
1510
|
+
)
|
1511
|
+
if type is not None and artifact.type != type:
|
1512
|
+
raise ValueError(
|
1513
|
+
f"type {type} specified but this artifact is of type {artifact.type}"
|
1514
|
+
)
|
1515
|
+
return artifact
|
1516
|
+
|
1517
|
+
@normalize_exceptions
|
1518
|
+
def artifact(self, name: str, type: Optional[str] = None):
|
1519
|
+
"""Returns a single artifact.
|
1520
|
+
|
1521
|
+
Args:
|
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.
|
1530
|
+
|
1531
|
+
Returns:
|
1532
|
+
An `Artifact` object.
|
1533
|
+
|
1534
|
+
Raises:
|
1535
|
+
ValueError: If the artifact name is not specified.
|
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
|
+
```
|
1560
|
+
|
1561
|
+
Note:
|
1562
|
+
This method is intended for external use only. Do not call `api.artifact()` within the wandb repository code.
|
1563
|
+
"""
|
1564
|
+
return self._artifact(name=name, type=type, enable_tracking=True)
|
1565
|
+
|
1566
|
+
@normalize_exceptions
|
1567
|
+
def job(self, name: Optional[str], path: Optional[str] = None) -> "public.Job":
|
1568
|
+
"""Return a `Job` object.
|
1569
|
+
|
1570
|
+
Args:
|
1571
|
+
name: The name of the job.
|
1572
|
+
path: The root path to download the job artifact.
|
1573
|
+
|
1574
|
+
Returns:
|
1575
|
+
A `Job` object.
|
1576
|
+
"""
|
1577
|
+
if name is None:
|
1578
|
+
raise ValueError("You must specify name= to fetch a job.")
|
1579
|
+
elif name.count("/") != 2 or ":" not in name:
|
1580
|
+
raise ValueError(
|
1581
|
+
"Invalid job specification. A job must be of the form: <entity>/<project>/<job-name>:<alias-or-version>"
|
1582
|
+
)
|
1583
|
+
return public.Job(self, name, path)
|
1584
|
+
|
1585
|
+
@normalize_exceptions
|
1586
|
+
def list_jobs(self, entity: str, project: str) -> List[Dict[str, Any]]:
|
1587
|
+
"""Return a list of jobs, if any, for the given entity and project.
|
1588
|
+
|
1589
|
+
Args:
|
1590
|
+
entity: The entity for the listed jobs.
|
1591
|
+
project: The project for the listed jobs.
|
1592
|
+
|
1593
|
+
Returns:
|
1594
|
+
A list of matching jobs.
|
1595
|
+
"""
|
1596
|
+
if entity is None:
|
1597
|
+
raise ValueError("Specify an entity when listing jobs")
|
1598
|
+
if project is None:
|
1599
|
+
raise ValueError("Specify a project when listing jobs")
|
1600
|
+
|
1601
|
+
query = gql(
|
1602
|
+
"""
|
1603
|
+
query ArtifactOfType(
|
1604
|
+
$entityName: String!,
|
1605
|
+
$projectName: String!,
|
1606
|
+
$artifactTypeName: String!,
|
1607
|
+
) {
|
1608
|
+
project(name: $projectName, entityName: $entityName) {
|
1609
|
+
artifactType(name: $artifactTypeName) {
|
1610
|
+
artifactCollections {
|
1611
|
+
edges {
|
1612
|
+
node {
|
1613
|
+
artifacts {
|
1614
|
+
edges {
|
1615
|
+
node {
|
1616
|
+
id
|
1617
|
+
state
|
1618
|
+
aliases {
|
1619
|
+
alias
|
1620
|
+
}
|
1621
|
+
artifactSequence {
|
1622
|
+
name
|
1623
|
+
}
|
1624
|
+
}
|
1625
|
+
}
|
1626
|
+
}
|
1627
|
+
}
|
1628
|
+
}
|
1629
|
+
}
|
1630
|
+
}
|
1631
|
+
}
|
1632
|
+
}
|
1633
|
+
"""
|
1634
|
+
)
|
1635
|
+
|
1636
|
+
try:
|
1637
|
+
artifact_query = self._client.execute(
|
1638
|
+
query,
|
1639
|
+
{
|
1640
|
+
"projectName": project,
|
1641
|
+
"entityName": entity,
|
1642
|
+
"artifactTypeName": "job",
|
1643
|
+
},
|
1644
|
+
)
|
1645
|
+
|
1646
|
+
if not artifact_query or not artifact_query["project"]:
|
1647
|
+
wandb.termerror(
|
1648
|
+
f"Project: '{project}' not found in entity: '{entity}' or access denied."
|
1649
|
+
)
|
1650
|
+
return []
|
1651
|
+
|
1652
|
+
if artifact_query["project"]["artifactType"] is None:
|
1653
|
+
return []
|
1654
|
+
|
1655
|
+
artifacts = artifact_query["project"]["artifactType"][
|
1656
|
+
"artifactCollections"
|
1657
|
+
]["edges"]
|
1658
|
+
|
1659
|
+
return [x["node"]["artifacts"] for x in artifacts]
|
1660
|
+
except requests.exceptions.HTTPError:
|
1661
|
+
return False
|
1662
|
+
|
1663
|
+
@normalize_exceptions
|
1664
|
+
def artifact_exists(self, name: str, type: Optional[str] = None) -> bool:
|
1665
|
+
"""Whether an artifact version exists within the specified project and entity.
|
1666
|
+
|
1667
|
+
Args:
|
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.
|
1675
|
+
|
1676
|
+
Returns:
|
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
|
+
|
1692
|
+
"""
|
1693
|
+
try:
|
1694
|
+
self._artifact(name, type)
|
1695
|
+
except wandb.errors.CommError:
|
1696
|
+
return False
|
1697
|
+
|
1698
|
+
return True
|
1699
|
+
|
1700
|
+
@normalize_exceptions
|
1701
|
+
def artifact_collection_exists(self, name: str, type: str) -> bool:
|
1702
|
+
"""Whether an artifact collection exists within a specified project and entity.
|
1703
|
+
|
1704
|
+
Args:
|
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.
|
1712
|
+
|
1713
|
+
Returns:
|
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
|
+
```
|
1725
|
+
"""
|
1726
|
+
try:
|
1727
|
+
self.artifact_collection(type, name)
|
1728
|
+
except wandb.errors.CommError:
|
1729
|
+
return False
|
1730
|
+
|
1731
|
+
return True
|
1732
|
+
|
1733
|
+
def registries(
|
1734
|
+
self,
|
1735
|
+
organization: Optional[str] = None,
|
1736
|
+
filter: Optional[Dict[str, Any]] = None,
|
1737
|
+
) -> Registries:
|
1738
|
+
"""Returns a lazy iterator of `Registry` objects.
|
1739
|
+
|
1740
|
+
Use the iterator to search and filter registries, collections,
|
1741
|
+
or artifact versions across your organization's registry.
|
1742
|
+
|
1743
|
+
Args:
|
1744
|
+
organization: (str, optional) The organization of the registry to fetch.
|
1745
|
+
If not specified, use the organization specified in the user's settings.
|
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
|
1748
|
+
`name`, `description`, `created_at`, `updated_at`.
|
1749
|
+
Fields available to filter for collections are
|
1750
|
+
`name`, `tag`, `description`, `created_at`, `updated_at`
|
1751
|
+
Fields available to filter for versions are
|
1752
|
+
`tag`, `alias`, `created_at`, `updated_at`, `metadata`
|
1753
|
+
|
1754
|
+
Returns:
|
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
|
+
```
|
1788
|
+
"""
|
1789
|
+
if not InternalApi()._server_supports(ServerFeature.ARTIFACT_REGISTRY_SEARCH):
|
1790
|
+
raise RuntimeError(
|
1791
|
+
"Registry search API is not enabled on this wandb server version. "
|
1792
|
+
"Please upgrade your server version or contact support at support@wandb.com."
|
1793
|
+
)
|
1794
|
+
|
1795
|
+
organization = organization or fetch_org_from_settings_or_entity(
|
1796
|
+
self.settings, self.default_entity
|
1797
|
+
)
|
1798
|
+
return Registries(self.client, organization, filter)
|
1799
|
+
|
1800
|
+
def registry(self, name: str, organization: Optional[str] = None) -> Registry:
|
1801
|
+
"""Return a registry given a registry name.
|
1802
|
+
|
1803
|
+
Args:
|
1804
|
+
name: The name of the registry. This is without the `wandb-registry-`
|
1805
|
+
prefix.
|
1806
|
+
organization: The organization of the registry.
|
1807
|
+
If no organization is set in the settings, the organization will be
|
1808
|
+
fetched from the entity if the entity only belongs to one
|
1809
|
+
organization.
|
1810
|
+
|
1811
|
+
Returns:
|
1812
|
+
A registry object.
|
1813
|
+
|
1814
|
+
Examples:
|
1815
|
+
Fetch and update a registry
|
1816
|
+
|
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
|
+
```
|
1825
|
+
"""
|
1826
|
+
if not InternalApi()._server_supports(ServerFeature.ARTIFACT_REGISTRY_SEARCH):
|
1827
|
+
raise RuntimeError(
|
1828
|
+
"api.registry() is not enabled on this wandb server version. "
|
1829
|
+
"Please upgrade your server version or contact support at support@wandb.com."
|
1830
|
+
)
|
1831
|
+
organization = organization or fetch_org_from_settings_or_entity(
|
1832
|
+
self.settings, self.default_entity
|
1833
|
+
)
|
1834
|
+
org_entity = fetch_org_entity_from_organization(self.client, organization)
|
1835
|
+
registry = Registry(self.client, organization, org_entity, name)
|
1836
|
+
registry.load()
|
1837
|
+
return registry
|
1838
|
+
|
1839
|
+
def create_registry(
|
1840
|
+
self,
|
1841
|
+
name: str,
|
1842
|
+
visibility: Literal["organization", "restricted"],
|
1843
|
+
organization: Optional[str] = None,
|
1844
|
+
description: Optional[str] = None,
|
1845
|
+
artifact_types: Optional[List[str]] = None,
|
1846
|
+
) -> Registry:
|
1847
|
+
"""Create a new registry.
|
1848
|
+
|
1849
|
+
Args:
|
1850
|
+
name: The name of the registry. Name must be unique within the organization.
|
1851
|
+
visibility: The visibility of the registry.
|
1852
|
+
organization: Anyone in the organization can view this registry. You can
|
1853
|
+
edit their roles later from the settings in the UI.
|
1854
|
+
restricted: Only invited members via the UI can access this registry.
|
1855
|
+
Public sharing is disabled.
|
1856
|
+
organization: The organization of the registry.
|
1857
|
+
If no organization is set in the settings, the organization will be
|
1858
|
+
fetched from the entity if the entity only belongs to one organization.
|
1859
|
+
description: The description of the registry.
|
1860
|
+
artifact_types: The accepted artifact types of the registry. A type is no
|
1861
|
+
more than 128 characters and do not include characters `/` or `:`. If
|
1862
|
+
not specified, all types are accepted.
|
1863
|
+
Allowed types added to the registry cannot be removed later.
|
1864
|
+
|
1865
|
+
Returns:
|
1866
|
+
A registry object.
|
1867
|
+
|
1868
|
+
Examples:
|
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
|
+
```
|
1881
|
+
"""
|
1882
|
+
if not InternalApi()._server_supports(
|
1883
|
+
ServerFeature.INCLUDE_ARTIFACT_TYPES_IN_REGISTRY_CREATION
|
1884
|
+
):
|
1885
|
+
raise RuntimeError(
|
1886
|
+
"create_registry api is not enabled on this wandb server version. "
|
1887
|
+
"Please upgrade your server version or contact support at support@wandb.com."
|
1888
|
+
)
|
1889
|
+
|
1890
|
+
organization = organization or fetch_org_from_settings_or_entity(
|
1891
|
+
self.settings, self.default_entity
|
1892
|
+
)
|
1893
|
+
|
1894
|
+
try:
|
1895
|
+
existing_registry = self.registry(name=name, organization=organization)
|
1896
|
+
except ValueError:
|
1897
|
+
existing_registry = None
|
1898
|
+
if existing_registry:
|
1899
|
+
raise ValueError(
|
1900
|
+
f"Registry {name!r} already exists in organization {organization!r},"
|
1901
|
+
" please use a different name."
|
1902
|
+
)
|
1903
|
+
|
1904
|
+
return Registry.create(
|
1905
|
+
self.client,
|
1906
|
+
organization,
|
1907
|
+
name,
|
1908
|
+
visibility,
|
1909
|
+
description,
|
1910
|
+
artifact_types,
|
1911
|
+
)
|
1912
|
+
|
1913
|
+
def integrations(
|
1914
|
+
self,
|
1915
|
+
entity: Optional[str] = None,
|
1916
|
+
*,
|
1917
|
+
per_page: int = 50,
|
1918
|
+
) -> Iterator["Integration"]:
|
1919
|
+
"""Return an iterator of all integrations for an entity.
|
1920
|
+
|
1921
|
+
Args:
|
1922
|
+
entity: The entity (e.g. team name) for which to
|
1923
|
+
fetch integrations. If not provided, the user's default entity
|
1924
|
+
will be used.
|
1925
|
+
per_page: Number of integrations to fetch per page.
|
1926
|
+
Defaults to 50. Usually there is no reason to change this.
|
1927
|
+
|
1928
|
+
Yields:
|
1929
|
+
Iterator[SlackIntegration | WebhookIntegration]: An iterator of any supported integrations.
|
1930
|
+
"""
|
1931
|
+
from wandb.apis.public.integrations import Integrations
|
1932
|
+
|
1933
|
+
params = {"entityName": entity or self.default_entity}
|
1934
|
+
return Integrations(client=self.client, variables=params, per_page=per_page)
|
1935
|
+
|
1936
|
+
def webhook_integrations(
|
1937
|
+
self, entity: Optional[str] = None, *, per_page: int = 50
|
1938
|
+
) -> Iterator["WebhookIntegration"]:
|
1939
|
+
"""Returns an iterator of webhook integrations for an entity.
|
1940
|
+
|
1941
|
+
Args:
|
1942
|
+
entity: The entity (e.g. team name) for which to
|
1943
|
+
fetch integrations. If not provided, the user's default entity
|
1944
|
+
will be used.
|
1945
|
+
per_page: Number of integrations to fetch per page.
|
1946
|
+
Defaults to 50. Usually there is no reason to change this.
|
1947
|
+
|
1948
|
+
Yields:
|
1949
|
+
Iterator[WebhookIntegration]: An iterator of webhook integrations.
|
1950
|
+
|
1951
|
+
Examples:
|
1952
|
+
Get all registered webhook integrations for the team "my-team":
|
1953
|
+
|
1954
|
+
```python
|
1955
|
+
import wandb
|
1956
|
+
|
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
|
+
```
|
1971
|
+
"""
|
1972
|
+
from wandb.apis.public.integrations import WebhookIntegrations
|
1973
|
+
|
1974
|
+
params = {"entityName": entity or self.default_entity}
|
1975
|
+
return WebhookIntegrations(
|
1976
|
+
client=self.client, variables=params, per_page=per_page
|
1977
|
+
)
|
1978
|
+
|
1979
|
+
def slack_integrations(
|
1980
|
+
self, *, entity: Optional[str] = None, per_page: int = 50
|
1981
|
+
) -> Iterator["SlackIntegration"]:
|
1982
|
+
"""Returns an iterator of Slack integrations for an entity.
|
1983
|
+
|
1984
|
+
Args:
|
1985
|
+
entity: The entity (e.g. team name) for which to
|
1986
|
+
fetch integrations. If not provided, the user's default entity
|
1987
|
+
will be used.
|
1988
|
+
per_page: Number of integrations to fetch per page.
|
1989
|
+
Defaults to 50. Usually there is no reason to change this.
|
1990
|
+
|
1991
|
+
Yields:
|
1992
|
+
Iterator[SlackIntegration]: An iterator of Slack integrations.
|
1993
|
+
|
1994
|
+
Examples:
|
1995
|
+
Get all registered Slack integrations for the team "my-team":
|
1996
|
+
|
1997
|
+
```python
|
1998
|
+
import wandb
|
1999
|
+
|
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
|
+
```
|
2014
|
+
"""
|
2015
|
+
from wandb.apis.public.integrations import SlackIntegrations
|
2016
|
+
|
2017
|
+
params = {"entityName": entity or self.default_entity}
|
2018
|
+
return SlackIntegrations(
|
2019
|
+
client=self.client, variables=params, per_page=per_page
|
2020
|
+
)
|
2021
|
+
|
2022
|
+
def _supports_automation(
|
2023
|
+
self,
|
2024
|
+
*,
|
2025
|
+
event: Optional["EventType"] = None,
|
2026
|
+
action: Optional["ActionType"] = None,
|
2027
|
+
) -> bool:
|
2028
|
+
"""Returns whether the server recognizes the automation event and/or action."""
|
2029
|
+
from wandb.automations._utils import (
|
2030
|
+
ALWAYS_SUPPORTED_ACTIONS,
|
2031
|
+
ALWAYS_SUPPORTED_EVENTS,
|
2032
|
+
)
|
2033
|
+
|
2034
|
+
api = InternalApi()
|
2035
|
+
supports_event = (
|
2036
|
+
(event is None)
|
2037
|
+
or (event in ALWAYS_SUPPORTED_EVENTS)
|
2038
|
+
or api._server_supports(f"AUTOMATION_EVENT_{event.value}")
|
2039
|
+
)
|
2040
|
+
supports_action = (
|
2041
|
+
(action is None)
|
2042
|
+
or (action in ALWAYS_SUPPORTED_ACTIONS)
|
2043
|
+
or api._server_supports(f"AUTOMATION_ACTION_{action.value}")
|
2044
|
+
)
|
2045
|
+
return supports_event and supports_action
|
2046
|
+
|
2047
|
+
def _omitted_automation_fragments(self) -> Set[str]:
|
2048
|
+
"""Returns the names of unsupported automation-related fragments.
|
2049
|
+
|
2050
|
+
Older servers won't recognize newer GraphQL types, so a valid request may
|
2051
|
+
unnecessarily error out because it won't recognize fragments defined on those types.
|
2052
|
+
|
2053
|
+
So e.g. if a server does not support `NO_OP` action types, then the following need to be
|
2054
|
+
removed from the body of the GraphQL request:
|
2055
|
+
|
2056
|
+
- Fragment definition:
|
2057
|
+
```
|
2058
|
+
fragment NoOpActionFields on NoOpTriggeredAction {
|
2059
|
+
noOp
|
2060
|
+
}
|
2061
|
+
```
|
2062
|
+
|
2063
|
+
- Fragment spread in selection set:
|
2064
|
+
```
|
2065
|
+
{
|
2066
|
+
...NoOpActionFields
|
2067
|
+
# ... other fields ...
|
2068
|
+
}
|
2069
|
+
```
|
2070
|
+
"""
|
2071
|
+
from wandb.automations import ActionType
|
2072
|
+
from wandb.automations._generated import (
|
2073
|
+
GenericWebhookActionFields,
|
2074
|
+
NoOpActionFields,
|
2075
|
+
NotificationActionFields,
|
2076
|
+
QueueJobActionFields,
|
2077
|
+
)
|
2078
|
+
|
2079
|
+
# Note: we can't currently define this as a constant outside the method
|
2080
|
+
# and still keep it nearby in this module, because it relies on pydantic v2-only imports
|
2081
|
+
fragment_names: dict[ActionType, str] = {
|
2082
|
+
ActionType.NO_OP: NoOpActionFields.__name__,
|
2083
|
+
ActionType.QUEUE_JOB: QueueJobActionFields.__name__,
|
2084
|
+
ActionType.NOTIFICATION: NotificationActionFields.__name__,
|
2085
|
+
ActionType.GENERIC_WEBHOOK: GenericWebhookActionFields.__name__,
|
2086
|
+
}
|
2087
|
+
|
2088
|
+
return set(
|
2089
|
+
name
|
2090
|
+
for action in ActionType
|
2091
|
+
if (not self._supports_automation(action=action))
|
2092
|
+
and (name := fragment_names.get(action))
|
2093
|
+
)
|
2094
|
+
|
2095
|
+
def automation(
|
2096
|
+
self,
|
2097
|
+
name: str,
|
2098
|
+
*,
|
2099
|
+
entity: Optional[str] = None,
|
2100
|
+
) -> "Automation":
|
2101
|
+
"""Returns the only Automation matching the parameters.
|
2102
|
+
|
2103
|
+
Args:
|
2104
|
+
name: The name of the automation to fetch.
|
2105
|
+
entity: The entity to fetch the automation for.
|
2106
|
+
|
2107
|
+
Raises:
|
2108
|
+
ValueError: If zero or multiple Automations match the search criteria.
|
2109
|
+
|
2110
|
+
Examples:
|
2111
|
+
Get an existing automation named "my-automation":
|
2112
|
+
|
2113
|
+
```python
|
2114
|
+
import wandb
|
2115
|
+
|
2116
|
+
api = wandb.Api()
|
2117
|
+
automation = api.automation(name="my-automation")
|
2118
|
+
```
|
2119
|
+
|
2120
|
+
Get an existing automation named "other-automation", from the entity "my-team":
|
2121
|
+
|
2122
|
+
```python
|
2123
|
+
automation = api.automation(name="other-automation", entity="my-team")
|
2124
|
+
```
|
2125
|
+
"""
|
2126
|
+
return one(
|
2127
|
+
self.automations(entity=entity, name=name),
|
2128
|
+
too_short=ValueError("No automations found"),
|
2129
|
+
too_long=ValueError("Multiple automations found"),
|
2130
|
+
)
|
2131
|
+
|
2132
|
+
def automations(
|
2133
|
+
self,
|
2134
|
+
entity: Optional[str] = None,
|
2135
|
+
*,
|
2136
|
+
name: Optional[str] = None,
|
2137
|
+
per_page: int = 50,
|
2138
|
+
) -> Iterator["Automation"]:
|
2139
|
+
"""Returns an iterator over all Automations that match the given parameters.
|
2140
|
+
|
2141
|
+
If no parameters are provided, the returned iterator will contain all
|
2142
|
+
Automations that the user has access to.
|
2143
|
+
|
2144
|
+
Args:
|
2145
|
+
entity: The entity to fetch the automations for.
|
2146
|
+
name: The name of the automation to fetch.
|
2147
|
+
per_page: The number of automations to fetch per page.
|
2148
|
+
Defaults to 50. Usually there is no reason to change this.
|
2149
|
+
|
2150
|
+
Returns:
|
2151
|
+
A list of automations.
|
2152
|
+
|
2153
|
+
Examples:
|
2154
|
+
Fetch all existing automations for the entity "my-team":
|
2155
|
+
|
2156
|
+
```python
|
2157
|
+
import wandb
|
2158
|
+
|
2159
|
+
api = wandb.Api()
|
2160
|
+
automations = api.automations(entity="my-team")
|
2161
|
+
```
|
2162
|
+
"""
|
2163
|
+
from wandb.apis.public.automations import Automations
|
2164
|
+
from wandb.automations._generated import (
|
2165
|
+
GET_AUTOMATIONS_BY_ENTITY_GQL,
|
2166
|
+
GET_AUTOMATIONS_GQL,
|
2167
|
+
)
|
2168
|
+
|
2169
|
+
# For now, we need to use different queries depending on whether entity is given
|
2170
|
+
variables = {"entityName": entity}
|
2171
|
+
if entity is None:
|
2172
|
+
gql_str = GET_AUTOMATIONS_GQL # Automations for viewer
|
2173
|
+
else:
|
2174
|
+
gql_str = GET_AUTOMATIONS_BY_ENTITY_GQL # Automations for entity
|
2175
|
+
|
2176
|
+
# If needed, rewrite the GraphQL field selection set to omit unsupported fields/fragments/types
|
2177
|
+
omit_fragments = self._omitted_automation_fragments()
|
2178
|
+
query = gql_compat(gql_str, omit_fragments=omit_fragments)
|
2179
|
+
iterator = Automations(
|
2180
|
+
client=self.client, variables=variables, per_page=per_page, _query=query
|
2181
|
+
)
|
2182
|
+
|
2183
|
+
# FIXME: this is crude, move this client-side filtering logic into backend
|
2184
|
+
if name is not None:
|
2185
|
+
iterator = filter(lambda x: x.name == name, iterator)
|
2186
|
+
yield from iterator
|
2187
|
+
|
2188
|
+
@normalize_exceptions
|
2189
|
+
def create_automation(
|
2190
|
+
self,
|
2191
|
+
obj: "NewAutomation",
|
2192
|
+
*,
|
2193
|
+
fetch_existing: bool = False,
|
2194
|
+
**kwargs: Unpack["WriteAutomationsKwargs"],
|
2195
|
+
) -> "Automation":
|
2196
|
+
"""Create a new Automation.
|
2197
|
+
|
2198
|
+
Args:
|
2199
|
+
obj:
|
2200
|
+
The automation to create.
|
2201
|
+
fetch_existing:
|
2202
|
+
If True, and a conflicting automation already exists, attempt
|
2203
|
+
to fetch the existing automation instead of raising an error.
|
2204
|
+
**kwargs:
|
2205
|
+
Any additional values to assign to the automation before
|
2206
|
+
creating it. If given, these will override any values that may
|
2207
|
+
already be set on the automation:
|
2208
|
+
- `name`: The name of the automation.
|
2209
|
+
- `description`: The description of the automation.
|
2210
|
+
- `enabled`: Whether the automation is enabled.
|
2211
|
+
- `scope`: The scope of the automation.
|
2212
|
+
- `event`: The event that triggers the automation.
|
2213
|
+
- `action`: The action that is triggered by the automation.
|
2214
|
+
|
2215
|
+
Returns:
|
2216
|
+
The saved Automation.
|
2217
|
+
|
2218
|
+
Examples:
|
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:
|
2221
|
+
|
2222
|
+
```python
|
2223
|
+
import wandb
|
2224
|
+
from wandb.automations import OnRunMetric, RunEvent, SendNotification
|
2225
|
+
|
2226
|
+
api = wandb.Api()
|
2227
|
+
|
2228
|
+
project = api.project("my-project", entity="my-team")
|
2229
|
+
|
2230
|
+
# Use the first Slack integration for the team
|
2231
|
+
slack_hook = next(api.slack_integrations(entity="my-team"))
|
2232
|
+
|
2233
|
+
event = OnRunMetric(
|
2234
|
+
scope=project,
|
2235
|
+
filter=RunEvent.metric("custom-metric") > 10,
|
2236
|
+
)
|
2237
|
+
action = SendNotification.from_integration(slack_hook)
|
2238
|
+
|
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
|
+
```
|
2245
|
+
"""
|
2246
|
+
from wandb.automations import Automation
|
2247
|
+
from wandb.automations._generated import CREATE_AUTOMATION_GQL, CreateAutomation
|
2248
|
+
from wandb.automations._utils import prepare_to_create
|
2249
|
+
|
2250
|
+
gql_input = prepare_to_create(obj, **kwargs)
|
2251
|
+
|
2252
|
+
if not self._supports_automation(
|
2253
|
+
event=(event := gql_input.triggering_event_type),
|
2254
|
+
action=(action := gql_input.triggered_action_type),
|
2255
|
+
):
|
2256
|
+
raise ValueError(
|
2257
|
+
f"Automation event or action ({event!r} -> {action!r}) "
|
2258
|
+
"is not supported on this wandb server version. "
|
2259
|
+
"Please upgrade your server version, or contact support at "
|
2260
|
+
"support@wandb.com."
|
2261
|
+
)
|
2262
|
+
|
2263
|
+
# If needed, rewrite the GraphQL field selection set to omit unsupported fields/fragments/types
|
2264
|
+
omit_fragments = self._omitted_automation_fragments()
|
2265
|
+
mutation = gql_compat(CREATE_AUTOMATION_GQL, omit_fragments=omit_fragments)
|
2266
|
+
variables = {"params": gql_input.model_dump(exclude_none=True)}
|
2267
|
+
|
2268
|
+
name = gql_input.name
|
2269
|
+
try:
|
2270
|
+
data = self.client.execute(mutation, variable_values=variables)
|
2271
|
+
except requests.HTTPError as e:
|
2272
|
+
status = HTTPStatus(e.response.status_code)
|
2273
|
+
if status is HTTPStatus.CONFLICT: # 409
|
2274
|
+
if fetch_existing:
|
2275
|
+
wandb.termlog(f"Automation {name!r} exists. Fetching it instead.")
|
2276
|
+
return self.automation(name=name)
|
2277
|
+
|
2278
|
+
raise ValueError(
|
2279
|
+
f"Automation {name!r} exists. Unable to create another with the same name."
|
2280
|
+
) from None
|
2281
|
+
raise
|
2282
|
+
|
2283
|
+
try:
|
2284
|
+
result = CreateAutomation.model_validate(data).result
|
2285
|
+
except ValidationError as e:
|
2286
|
+
msg = f"Invalid response while creating automation {name!r}"
|
2287
|
+
raise RuntimeError(msg) from e
|
2288
|
+
|
2289
|
+
if (result is None) or (result.trigger is None):
|
2290
|
+
msg = f"Empty response while creating automation {name!r}"
|
2291
|
+
raise RuntimeError(msg)
|
2292
|
+
|
2293
|
+
return Automation.model_validate(result.trigger)
|
2294
|
+
|
2295
|
+
@normalize_exceptions
|
2296
|
+
def update_automation(
|
2297
|
+
self,
|
2298
|
+
obj: "Automation",
|
2299
|
+
*,
|
2300
|
+
create_missing: bool = False,
|
2301
|
+
**kwargs: Unpack["WriteAutomationsKwargs"],
|
2302
|
+
) -> "Automation":
|
2303
|
+
"""Update an existing automation.
|
2304
|
+
|
2305
|
+
Args:
|
2306
|
+
obj: The automation to update. Must be an existing automation.
|
2307
|
+
create_missing (bool):
|
2308
|
+
If True, and the automation does not exist, create it.
|
2309
|
+
**kwargs:
|
2310
|
+
Any additional values to assign to the automation before
|
2311
|
+
updating it. If given, these will override any values that may
|
2312
|
+
already be set on the automation:
|
2313
|
+
- `name`: The name of the automation.
|
2314
|
+
- `description`: The description of the automation.
|
2315
|
+
- `enabled`: Whether the automation is enabled.
|
2316
|
+
- `scope`: The scope of the automation.
|
2317
|
+
- `event`: The event that triggers the automation.
|
2318
|
+
- `action`: The action that is triggered by the automation.
|
2319
|
+
|
2320
|
+
Returns:
|
2321
|
+
The updated automation.
|
2322
|
+
|
2323
|
+
Examples:
|
2324
|
+
Disable and edit the description of an existing automation ("my-automation"):
|
2325
|
+
|
2326
|
+
```python
|
2327
|
+
import wandb
|
2328
|
+
|
2329
|
+
api = wandb.Api()
|
2330
|
+
|
2331
|
+
automation = api.automation(name="my-automation")
|
2332
|
+
automation.enabled = False
|
2333
|
+
automation.description = "Kept for reference, but no longer used."
|
2334
|
+
|
2335
|
+
updated_automation = api.update_automation(automation)
|
2336
|
+
```
|
2337
|
+
|
2338
|
+
OR
|
2339
|
+
|
2340
|
+
```python
|
2341
|
+
import wandb
|
2342
|
+
|
2343
|
+
api = wandb.Api()
|
2344
|
+
|
2345
|
+
automation = api.automation(name="my-automation")
|
2346
|
+
|
2347
|
+
updated_automation = api.update_automation(
|
2348
|
+
automation,
|
2349
|
+
enabled=False,
|
2350
|
+
description="Kept for reference, but no longer used.",
|
2351
|
+
)
|
2352
|
+
```
|
2353
|
+
"""
|
2354
|
+
from wandb.automations import ActionType, Automation
|
2355
|
+
from wandb.automations._generated import UPDATE_AUTOMATION_GQL, UpdateAutomation
|
2356
|
+
from wandb.automations._utils import prepare_to_update
|
2357
|
+
|
2358
|
+
# Check if the server even supports updating automations.
|
2359
|
+
#
|
2360
|
+
# NOTE: Unfortunately, there is no current server feature flag for this. As a workaround,
|
2361
|
+
# we check whether the server supports the NO_OP action, which is a reasonably safe proxy
|
2362
|
+
# for whether it supports updating automations.
|
2363
|
+
if not self._supports_automation(action=ActionType.NO_OP):
|
2364
|
+
raise RuntimeError(
|
2365
|
+
"Updating existing automations is not enabled on this wandb server version. "
|
2366
|
+
"Please upgrade your server version, or contact support at support@wandb.com."
|
2367
|
+
)
|
2368
|
+
|
2369
|
+
gql_input = prepare_to_update(obj, **kwargs)
|
2370
|
+
|
2371
|
+
if not self._supports_automation(
|
2372
|
+
event=(event := gql_input.triggering_event_type),
|
2373
|
+
action=(action := gql_input.triggered_action_type),
|
2374
|
+
):
|
2375
|
+
raise ValueError(
|
2376
|
+
f"Automation event or action ({event.value} -> {action.value}) "
|
2377
|
+
"is not supported on this wandb server version. "
|
2378
|
+
"Please upgrade your server version, or contact support at "
|
2379
|
+
"support@wandb.com."
|
2380
|
+
)
|
2381
|
+
|
2382
|
+
# If needed, rewrite the GraphQL field selection set to omit unsupported fields/fragments/types
|
2383
|
+
omit_fragments = self._omitted_automation_fragments()
|
2384
|
+
mutation = gql_compat(UPDATE_AUTOMATION_GQL, omit_fragments=omit_fragments)
|
2385
|
+
variables = {"params": gql_input.model_dump(exclude_none=True)}
|
2386
|
+
|
2387
|
+
name = gql_input.name
|
2388
|
+
try:
|
2389
|
+
data = self.client.execute(mutation, variable_values=variables)
|
2390
|
+
except requests.HTTPError as e:
|
2391
|
+
status = HTTPStatus(e.response.status_code)
|
2392
|
+
if status is HTTPStatus.NOT_FOUND: # 404
|
2393
|
+
if create_missing:
|
2394
|
+
wandb.termlog(f"Automation {name!r} not found. Creating it.")
|
2395
|
+
return self.create_automation(obj)
|
2396
|
+
|
2397
|
+
raise ValueError(
|
2398
|
+
f"Automation {name!r} not found. Unable to edit it."
|
2399
|
+
) from e
|
2400
|
+
|
2401
|
+
# Not a (known) recoverable HTTP error
|
2402
|
+
wandb.termerror(f"Got response status {status!r}: {e.response.text!r}")
|
2403
|
+
raise
|
2404
|
+
|
2405
|
+
try:
|
2406
|
+
result = UpdateAutomation.model_validate(data).result
|
2407
|
+
except ValidationError as e:
|
2408
|
+
msg = f"Invalid response while updating automation {name!r}"
|
2409
|
+
raise RuntimeError(msg) from e
|
2410
|
+
|
2411
|
+
if (result is None) or (result.trigger is None):
|
2412
|
+
msg = f"Empty response while updating automation {name!r}"
|
2413
|
+
raise RuntimeError(msg)
|
2414
|
+
|
2415
|
+
return Automation.model_validate(result.trigger)
|
2416
|
+
|
2417
|
+
@normalize_exceptions
|
2418
|
+
def delete_automation(self, obj: Union["Automation", str]) -> Literal[True]:
|
2419
|
+
"""Delete an automation.
|
2420
|
+
|
2421
|
+
Args:
|
2422
|
+
obj: The automation to delete, or its ID.
|
2423
|
+
|
2424
|
+
Returns:
|
2425
|
+
True if the automation was deleted successfully.
|
2426
|
+
"""
|
2427
|
+
from wandb.automations._generated import DELETE_AUTOMATION_GQL, DeleteAutomation
|
2428
|
+
from wandb.automations._utils import extract_id
|
2429
|
+
|
2430
|
+
id_ = extract_id(obj)
|
2431
|
+
mutation = gql(DELETE_AUTOMATION_GQL)
|
2432
|
+
variables = {"id": id_}
|
2433
|
+
|
2434
|
+
data = self.client.execute(mutation, variable_values=variables)
|
2435
|
+
|
2436
|
+
try:
|
2437
|
+
result = DeleteAutomation.model_validate(data).result
|
2438
|
+
except ValidationError as e:
|
2439
|
+
msg = f"Invalid response while deleting automation {id_!r}"
|
2440
|
+
raise RuntimeError(msg) from e
|
2441
|
+
|
2442
|
+
if result is None:
|
2443
|
+
msg = f"Empty response while deleting automation {id_!r}"
|
2444
|
+
raise RuntimeError(msg)
|
2445
|
+
|
2446
|
+
if not result.success:
|
2447
|
+
raise RuntimeError(f"Failed to delete automation: {id_!r}")
|
2448
|
+
|
2449
|
+
return result.success
|