wandb 0.19.1__py3-none-musllinux_1_2_aarch64.whl
Sign up to get free protection for your applications and to get access to all the features.
- package_readme.md +97 -0
- wandb/__init__.py +246 -0
- wandb/__init__.pyi +1197 -0
- wandb/__main__.py +3 -0
- wandb/_globals.py +19 -0
- wandb/agents/__init__.py +0 -0
- wandb/agents/pyagent.py +363 -0
- wandb/analytics/__init__.py +3 -0
- wandb/analytics/sentry.py +263 -0
- wandb/apis/__init__.py +48 -0
- wandb/apis/attrs.py +51 -0
- wandb/apis/importers/__init__.py +1 -0
- wandb/apis/importers/internals/internal.py +385 -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 +1603 -0
- wandb/apis/internal.py +232 -0
- wandb/apis/normalize.py +73 -0
- wandb/apis/paginator.py +81 -0
- wandb/apis/public/__init__.py +34 -0
- wandb/apis/public/api.py +1387 -0
- wandb/apis/public/artifacts.py +1095 -0
- wandb/apis/public/const.py +4 -0
- wandb/apis/public/files.py +263 -0
- wandb/apis/public/history.py +149 -0
- wandb/apis/public/jobs.py +653 -0
- wandb/apis/public/projects.py +154 -0
- wandb/apis/public/query_generator.py +166 -0
- wandb/apis/public/reports.py +458 -0
- wandb/apis/public/runs.py +1012 -0
- wandb/apis/public/sweeps.py +240 -0
- wandb/apis/public/teams.py +198 -0
- wandb/apis/public/users.py +136 -0
- wandb/apis/public/utils.py +68 -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/beta/workflows.py +288 -0
- wandb/bin/gpu_stats +0 -0
- wandb/bin/wandb-core +0 -0
- wandb/cli/__init__.py +0 -0
- wandb/cli/beta.py +178 -0
- wandb/cli/cli.py +2812 -0
- wandb/data_types.py +66 -0
- wandb/docker/__init__.py +343 -0
- wandb/docker/auth.py +435 -0
- wandb/docker/wandb-entrypoint.sh +33 -0
- wandb/docker/www_authenticate.py +94 -0
- wandb/env.py +513 -0
- wandb/errors/__init__.py +17 -0
- wandb/errors/errors.py +37 -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 +403 -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 +178 -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 +882 -0
- wandb/integration/diffusers/resolvers/utils.py +102 -0
- wandb/integration/fastai/__init__.py +245 -0
- wandb/integration/gym/__init__.py +99 -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 +1089 -0
- wandb/integration/kfp/__init__.py +6 -0
- wandb/integration/kfp/helpers.py +28 -0
- wandb/integration/kfp/kfp_patch.py +334 -0
- wandb/integration/kfp/wandb_logging.py +182 -0
- wandb/integration/langchain/__init__.py +3 -0
- wandb/integration/langchain/wandb_tracer.py +48 -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 +764 -0
- wandb/integration/metaflow/__init__.py +3 -0
- wandb/integration/metaflow/metaflow.py +383 -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 +299 -0
- wandb/integration/sacred/__init__.py +117 -0
- wandb/integration/sagemaker/__init__.py +12 -0
- wandb/integration/sagemaker/auth.py +28 -0
- wandb/integration/sagemaker/config.py +49 -0
- wandb/integration/sagemaker/files.py +3 -0
- wandb/integration/sagemaker/resources.py +34 -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 +183 -0
- wandb/integration/tensorboard/__init__.py +10 -0
- wandb/integration/tensorboard/log.py +354 -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 +524 -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/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 +513 -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 +173 -0
- wandb/old/summary.py +440 -0
- wandb/plot/__init__.py +28 -0
- wandb/plot/bar.py +70 -0
- wandb/plot/confusion_matrix.py +181 -0
- wandb/plot/custom_chart.py +124 -0
- wandb/plot/histogram.py +65 -0
- wandb/plot/line.py +74 -0
- wandb/plot/line_series.py +176 -0
- wandb/plot/pr_curve.py +185 -0
- wandb/plot/roc_curve.py +163 -0
- wandb/plot/scatter.py +66 -0
- wandb/plot/utils.py +183 -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 +1658 -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 +370 -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 +371 -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/wandb_base_pb2.py +10 -0
- wandb/proto/wandb_deprecated.py +45 -0
- wandb/proto/wandb_generate_deprecated.py +30 -0
- wandb/proto/wandb_generate_proto.py +49 -0
- wandb/proto/wandb_internal_pb2.py +16 -0
- wandb/proto/wandb_server_pb2.py +10 -0
- wandb/proto/wandb_settings_pb2.py +10 -0
- wandb/proto/wandb_telemetry_pb2.py +10 -0
- wandb/py.typed +0 -0
- wandb/sdk/__init__.py +37 -0
- wandb/sdk/artifacts/__init__.py +0 -0
- wandb/sdk/artifacts/_validators.py +121 -0
- wandb/sdk/artifacts/artifact.py +2364 -0
- wandb/sdk/artifacts/artifact_download_logger.py +43 -0
- wandb/sdk/artifacts/artifact_file_cache.py +249 -0
- wandb/sdk/artifacts/artifact_instance_cache.py +17 -0
- wandb/sdk/artifacts/artifact_manifest.py +75 -0
- wandb/sdk/artifacts/artifact_manifest_entry.py +249 -0
- wandb/sdk/artifacts/artifact_manifests/__init__.py +0 -0
- wandb/sdk/artifacts/artifact_manifests/artifact_manifest_v1.py +92 -0
- wandb/sdk/artifacts/artifact_saver.py +265 -0
- wandb/sdk/artifacts/artifact_state.py +11 -0
- wandb/sdk/artifacts/artifact_ttl.py +7 -0
- wandb/sdk/artifacts/exceptions.py +57 -0
- wandb/sdk/artifacts/staging.py +25 -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 +213 -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 +139 -0
- wandb/sdk/artifacts/storage_handlers/multi_handler.py +56 -0
- wandb/sdk/artifacts/storage_handlers/s3_handler.py +298 -0
- wandb/sdk/artifacts/storage_handlers/tracking_handler.py +72 -0
- wandb/sdk/artifacts/storage_handlers/wb_artifact_handler.py +135 -0
- wandb/sdk/artifacts/storage_handlers/wb_local_artifact_handler.py +74 -0
- wandb/sdk/artifacts/storage_layout.py +6 -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 +378 -0
- wandb/sdk/artifacts/storage_policy.py +72 -0
- wandb/sdk/backend/__init__.py +0 -0
- wandb/sdk/backend/backend.py +221 -0
- wandb/sdk/data_types/__init__.py +0 -0
- wandb/sdk/data_types/_dtypes.py +918 -0
- wandb/sdk/data_types/_private.py +10 -0
- wandb/sdk/data_types/audio.py +165 -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 +376 -0
- wandb/sdk/data_types/base_types/wb_value.py +282 -0
- wandb/sdk/data_types/bokeh.py +70 -0
- wandb/sdk/data_types/graph.py +405 -0
- wandb/sdk/data_types/helper_types/__init__.py +0 -0
- wandb/sdk/data_types/helper_types/bounding_boxes_2d.py +305 -0
- wandb/sdk/data_types/helper_types/classes.py +159 -0
- wandb/sdk/data_types/helper_types/image_mask.py +241 -0
- wandb/sdk/data_types/histogram.py +94 -0
- wandb/sdk/data_types/html.py +115 -0
- wandb/sdk/data_types/image.py +847 -0
- wandb/sdk/data_types/molecule.py +241 -0
- wandb/sdk/data_types/object_3d.py +470 -0
- wandb/sdk/data_types/plotly.py +82 -0
- wandb/sdk/data_types/saved_model.py +445 -0
- wandb/sdk/data_types/table.py +1204 -0
- wandb/sdk/data_types/trace_tree.py +438 -0
- wandb/sdk/data_types/utils.py +228 -0
- wandb/sdk/data_types/video.py +268 -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 +1010 -0
- wandb/sdk/interface/interface_queue.py +53 -0
- wandb/sdk/interface/interface_relay.py +53 -0
- wandb/sdk/interface/interface_shared.py +546 -0
- wandb/sdk/interface/interface_sock.py +61 -0
- wandb/sdk/interface/message_future.py +27 -0
- wandb/sdk/interface/message_future_poll.py +50 -0
- wandb/sdk/interface/router.py +115 -0
- wandb/sdk/interface/router_queue.py +41 -0
- wandb/sdk/interface/router_relay.py +37 -0
- wandb/sdk/interface/router_sock.py +36 -0
- wandb/sdk/interface/summary_record.py +67 -0
- wandb/sdk/internal/__init__.py +0 -0
- wandb/sdk/internal/context.py +89 -0
- wandb/sdk/internal/datastore.py +297 -0
- wandb/sdk/internal/file_pusher.py +181 -0
- wandb/sdk/internal/file_stream.py +695 -0
- wandb/sdk/internal/flow_control.py +263 -0
- wandb/sdk/internal/handler.py +905 -0
- wandb/sdk/internal/internal.py +403 -0
- wandb/sdk/internal/internal_api.py +4587 -0
- wandb/sdk/internal/internal_util.py +97 -0
- wandb/sdk/internal/job_builder.py +638 -0
- wandb/sdk/internal/profiler.py +78 -0
- wandb/sdk/internal/progress.py +79 -0
- wandb/sdk/internal/run.py +25 -0
- wandb/sdk/internal/sample.py +70 -0
- wandb/sdk/internal/sender.py +1696 -0
- wandb/sdk/internal/sender_config.py +197 -0
- wandb/sdk/internal/settings_static.py +97 -0
- wandb/sdk/internal/system/__init__.py +0 -0
- wandb/sdk/internal/system/assets/__init__.py +25 -0
- wandb/sdk/internal/system/assets/aggregators.py +37 -0
- wandb/sdk/internal/system/assets/asset_registry.py +20 -0
- wandb/sdk/internal/system/assets/cpu.py +163 -0
- wandb/sdk/internal/system/assets/disk.py +210 -0
- wandb/sdk/internal/system/assets/gpu.py +416 -0
- wandb/sdk/internal/system/assets/gpu_amd.py +233 -0
- wandb/sdk/internal/system/assets/interfaces.py +205 -0
- wandb/sdk/internal/system/assets/ipu.py +177 -0
- wandb/sdk/internal/system/assets/memory.py +166 -0
- wandb/sdk/internal/system/assets/network.py +125 -0
- wandb/sdk/internal/system/assets/open_metrics.py +293 -0
- wandb/sdk/internal/system/assets/tpu.py +154 -0
- wandb/sdk/internal/system/assets/trainium.py +393 -0
- wandb/sdk/internal/system/env_probe_helpers.py +13 -0
- wandb/sdk/internal/system/system_info.py +250 -0
- wandb/sdk/internal/system/system_monitor.py +222 -0
- wandb/sdk/internal/tb_watcher.py +519 -0
- wandb/sdk/internal/thread_local_settings.py +18 -0
- wandb/sdk/internal/writer.py +204 -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 +566 -0
- wandb/sdk/launch/agent/__init__.py +5 -0
- wandb/sdk/launch/agent/agent.py +924 -0
- wandb/sdk/launch/agent/config.py +296 -0
- wandb/sdk/launch/agent/job_status_tracker.py +53 -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 +297 -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 +594 -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 +528 -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 +335 -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 +315 -0
- wandb/sdk/launch/inputs/manage.py +113 -0
- wandb/sdk/launch/inputs/schema.py +39 -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 +472 -0
- wandb/sdk/launch/runner/kubernetes_runner.py +963 -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 +426 -0
- wandb/sdk/launch/runner/vertex_runner.py +230 -0
- wandb/sdk/launch/sweeps/__init__.py +37 -0
- wandb/sdk/launch/sweeps/scheduler.py +740 -0
- wandb/sdk/launch/sweeps/scheduler_sweep.py +90 -0
- wandb/sdk/launch/sweeps/utils.py +316 -0
- wandb/sdk/launch/utils.py +747 -0
- wandb/sdk/launch/wandb_reference.py +138 -0
- wandb/sdk/lib/__init__.py +5 -0
- wandb/sdk/lib/apikey.py +269 -0
- wandb/sdk/lib/capped_dict.py +26 -0
- wandb/sdk/lib/config_util.py +101 -0
- wandb/sdk/lib/credentials.py +141 -0
- wandb/sdk/lib/deprecate.py +42 -0
- wandb/sdk/lib/disabled.py +29 -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 +180 -0
- wandb/sdk/lib/gitlib.py +239 -0
- wandb/sdk/lib/gql_request.py +65 -0
- wandb/sdk/lib/handler_util.py +21 -0
- wandb/sdk/lib/hashutil.py +84 -0
- wandb/sdk/lib/import_hooks.py +275 -0
- wandb/sdk/lib/ipython.py +126 -0
- wandb/sdk/lib/json_util.py +80 -0
- wandb/sdk/lib/lazyloader.py +63 -0
- wandb/sdk/lib/mailbox.py +456 -0
- wandb/sdk/lib/module.py +78 -0
- wandb/sdk/lib/paths.py +106 -0
- wandb/sdk/lib/preinit.py +42 -0
- wandb/sdk/lib/printer.py +548 -0
- wandb/sdk/lib/progress.py +279 -0
- wandb/sdk/lib/proto_util.py +90 -0
- wandb/sdk/lib/redirect.py +845 -0
- wandb/sdk/lib/retry.py +289 -0
- wandb/sdk/lib/run_moment.py +72 -0
- wandb/sdk/lib/runid.py +12 -0
- wandb/sdk/lib/server.py +38 -0
- wandb/sdk/lib/service_connection.py +216 -0
- wandb/sdk/lib/service_token.py +94 -0
- wandb/sdk/lib/sock_client.py +290 -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/service/__init__.py +0 -0
- wandb/sdk/service/_startup_debug.py +22 -0
- wandb/sdk/service/port_file.py +53 -0
- wandb/sdk/service/server.py +107 -0
- wandb/sdk/service/server_sock.py +274 -0
- wandb/sdk/service/service.py +242 -0
- wandb/sdk/service/streams.py +425 -0
- wandb/sdk/verify/__init__.py +0 -0
- wandb/sdk/verify/verify.py +501 -0
- wandb/sdk/wandb_alerts.py +12 -0
- wandb/sdk/wandb_config.py +322 -0
- wandb/sdk/wandb_helper.py +54 -0
- wandb/sdk/wandb_init.py +1313 -0
- wandb/sdk/wandb_login.py +339 -0
- wandb/sdk/wandb_metric.py +110 -0
- wandb/sdk/wandb_require.py +94 -0
- wandb/sdk/wandb_require_helpers.py +44 -0
- wandb/sdk/wandb_run.py +4066 -0
- wandb/sdk/wandb_settings.py +1309 -0
- wandb/sdk/wandb_setup.py +402 -0
- wandb/sdk/wandb_summary.py +150 -0
- wandb/sdk/wandb_sweep.py +119 -0
- wandb/sdk/wandb_sync.py +82 -0
- wandb/sdk/wandb_watch.py +150 -0
- wandb/sklearn.py +35 -0
- wandb/sync/__init__.py +3 -0
- wandb/sync/sync.py +442 -0
- wandb/trigger.py +29 -0
- wandb/util.py +1955 -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/pynvml/__init__.py +0 -0
- wandb/vendor/pynvml/pynvml.py +4779 -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 +588 -0
- wandb/wandb_controller.py +719 -0
- wandb/wandb_run.py +9 -0
- wandb-0.19.1.dist-info/METADATA +223 -0
- wandb-0.19.1.dist-info/RECORD +822 -0
- wandb-0.19.1.dist-info/WHEEL +5 -0
- wandb-0.19.1.dist-info/entry_points.txt +3 -0
- wandb-0.19.1.dist-info/licenses/LICENSE +21 -0
wandb/cli/cli.py
ADDED
@@ -0,0 +1,2812 @@
|
|
1
|
+
import asyncio
|
2
|
+
import configparser
|
3
|
+
import datetime
|
4
|
+
import getpass
|
5
|
+
import json
|
6
|
+
import logging
|
7
|
+
import os
|
8
|
+
import shlex
|
9
|
+
import shutil
|
10
|
+
import subprocess
|
11
|
+
import sys
|
12
|
+
import tempfile
|
13
|
+
import textwrap
|
14
|
+
import time
|
15
|
+
import traceback
|
16
|
+
from functools import wraps
|
17
|
+
from typing import Any, Dict, Optional
|
18
|
+
|
19
|
+
import click
|
20
|
+
import yaml
|
21
|
+
from click.exceptions import ClickException
|
22
|
+
|
23
|
+
# pycreds has a find_executable that works in windows
|
24
|
+
from dockerpycreds.utils import find_executable
|
25
|
+
|
26
|
+
import wandb
|
27
|
+
import wandb.env
|
28
|
+
import wandb.errors
|
29
|
+
import wandb.sdk.verify.verify as wandb_verify
|
30
|
+
from wandb import Config, Error, env, util, wandb_agent, wandb_sdk
|
31
|
+
from wandb.apis import InternalApi, PublicApi
|
32
|
+
from wandb.apis.public import RunQueue
|
33
|
+
from wandb.errors.links import url_registry
|
34
|
+
from wandb.sdk.artifacts._validators import is_artifact_registry_project
|
35
|
+
from wandb.sdk.artifacts.artifact_file_cache import get_artifact_file_cache
|
36
|
+
from wandb.sdk.internal.internal_api import Api as SDKInternalApi
|
37
|
+
from wandb.sdk.launch import utils as launch_utils
|
38
|
+
from wandb.sdk.launch._launch_add import _launch_add
|
39
|
+
from wandb.sdk.launch.errors import ExecutionError, LaunchError
|
40
|
+
from wandb.sdk.launch.sweeps import utils as sweep_utils
|
41
|
+
from wandb.sdk.launch.sweeps.scheduler import Scheduler
|
42
|
+
from wandb.sdk.lib import filesystem
|
43
|
+
from wandb.sync import SyncManager, get_run_from_path, get_runs
|
44
|
+
|
45
|
+
from .beta import beta
|
46
|
+
|
47
|
+
# Send cli logs to wandb/debug-cli.<username>.log by default and fallback to a temp dir.
|
48
|
+
_wandb_dir = wandb.old.core.wandb_dir(env.get_dir())
|
49
|
+
if not os.path.exists(_wandb_dir):
|
50
|
+
_wandb_dir = tempfile.gettempdir()
|
51
|
+
|
52
|
+
try:
|
53
|
+
_username = getpass.getuser()
|
54
|
+
except KeyError:
|
55
|
+
# getuser() could raise KeyError in restricted environments like
|
56
|
+
# chroot jails or docker containers. Return user id in these cases.
|
57
|
+
_username = str(os.getuid())
|
58
|
+
|
59
|
+
_wandb_log_path = os.path.join(_wandb_dir, f"debug-cli.{_username}.log")
|
60
|
+
|
61
|
+
logging.basicConfig(
|
62
|
+
filename=_wandb_log_path,
|
63
|
+
level=logging.INFO,
|
64
|
+
format="%(asctime)s %(levelname)s %(message)s",
|
65
|
+
datefmt="%Y-%m-%d %H:%M:%S",
|
66
|
+
)
|
67
|
+
logging.basicConfig(stream=sys.stdout, level=logging.INFO)
|
68
|
+
logger = logging.getLogger("wandb")
|
69
|
+
|
70
|
+
# Click Contexts
|
71
|
+
CONTEXT = {"default_map": {}}
|
72
|
+
RUN_CONTEXT = {
|
73
|
+
"default_map": {},
|
74
|
+
"allow_extra_args": True,
|
75
|
+
"ignore_unknown_options": True,
|
76
|
+
}
|
77
|
+
|
78
|
+
|
79
|
+
def cli_unsupported(argument):
|
80
|
+
wandb.termerror(f"Unsupported argument `{argument}`")
|
81
|
+
sys.exit(1)
|
82
|
+
|
83
|
+
|
84
|
+
class ClickWandbException(ClickException):
|
85
|
+
def format_message(self):
|
86
|
+
# log_file = util.get_log_file_path()
|
87
|
+
log_file = ""
|
88
|
+
orig_type = f"{self.orig_type.__module__}.{self.orig_type.__name__}"
|
89
|
+
if issubclass(self.orig_type, Error):
|
90
|
+
return click.style(str(self.message), fg="red")
|
91
|
+
else:
|
92
|
+
return (
|
93
|
+
f"An Exception was raised, see {log_file} for full traceback.\n"
|
94
|
+
f"{orig_type}: {self.message}"
|
95
|
+
)
|
96
|
+
|
97
|
+
|
98
|
+
def display_error(func):
|
99
|
+
"""Function decorator for catching common errors and re-raising as wandb.Error."""
|
100
|
+
|
101
|
+
@wraps(func)
|
102
|
+
def wrapper(*args, **kwargs):
|
103
|
+
try:
|
104
|
+
return func(*args, **kwargs)
|
105
|
+
except wandb.Error as e:
|
106
|
+
exc_type, exc_value, exc_traceback = sys.exc_info()
|
107
|
+
lines = traceback.format_exception(exc_type, exc_value, exc_traceback)
|
108
|
+
logger.error("".join(lines))
|
109
|
+
wandb.termerror(f"Find detailed error logs at: {_wandb_log_path}")
|
110
|
+
click_exc = ClickWandbException(e)
|
111
|
+
click_exc.orig_type = exc_type
|
112
|
+
raise click_exc.with_traceback(sys.exc_info()[2])
|
113
|
+
|
114
|
+
return wrapper
|
115
|
+
|
116
|
+
|
117
|
+
_api = None # caching api instance allows patching from unit tests
|
118
|
+
|
119
|
+
|
120
|
+
def _get_cling_api(reset=None):
|
121
|
+
"""Get a reference to the internal api with cling settings."""
|
122
|
+
# TODO: move CLI to wandb-core backend
|
123
|
+
wandb.require("legacy-service")
|
124
|
+
|
125
|
+
global _api
|
126
|
+
if reset:
|
127
|
+
_api = None
|
128
|
+
wandb_sdk.wandb_setup._setup(_reset=True)
|
129
|
+
if _api is None:
|
130
|
+
# TODO(jhr): make a settings object that is better for non runs.
|
131
|
+
# only override the necessary setting
|
132
|
+
wandb.setup(settings=wandb.Settings(x_cli_only_mode=True))
|
133
|
+
_api = InternalApi()
|
134
|
+
return _api
|
135
|
+
|
136
|
+
|
137
|
+
def prompt_for_project(ctx, entity):
|
138
|
+
"""Ask the user for a project, creating one if necessary."""
|
139
|
+
result = ctx.invoke(projects, entity=entity, display=False)
|
140
|
+
api = _get_cling_api()
|
141
|
+
try:
|
142
|
+
if len(result) == 0:
|
143
|
+
project = click.prompt("Enter a name for your first project")
|
144
|
+
# description = editor()
|
145
|
+
project = api.upsert_project(project, entity=entity)["name"]
|
146
|
+
else:
|
147
|
+
project_names = [project["name"] for project in result] + ["Create New"]
|
148
|
+
wandb.termlog("Which project should we use?")
|
149
|
+
result = util.prompt_choices(project_names)
|
150
|
+
if result:
|
151
|
+
project = result
|
152
|
+
else:
|
153
|
+
project = "Create New"
|
154
|
+
# TODO: check with the server if the project exists
|
155
|
+
if project == "Create New":
|
156
|
+
project = click.prompt(
|
157
|
+
"Enter a name for your new project", value_proc=api.format_project
|
158
|
+
)
|
159
|
+
# description = editor()
|
160
|
+
project = api.upsert_project(project, entity=entity)["name"]
|
161
|
+
|
162
|
+
except wandb.errors.CommError as e:
|
163
|
+
raise ClickException(str(e))
|
164
|
+
|
165
|
+
return project
|
166
|
+
|
167
|
+
|
168
|
+
class RunGroup(click.Group):
|
169
|
+
@display_error
|
170
|
+
def get_command(self, ctx, cmd_name):
|
171
|
+
# TODO: check if cmd_name is a file in the current dir and not require `run`?
|
172
|
+
rv = click.Group.get_command(self, ctx, cmd_name)
|
173
|
+
if rv is not None:
|
174
|
+
return rv
|
175
|
+
return None
|
176
|
+
|
177
|
+
|
178
|
+
@click.command(cls=RunGroup, invoke_without_command=True)
|
179
|
+
@click.version_option(version=wandb.__version__)
|
180
|
+
@click.pass_context
|
181
|
+
def cli(ctx):
|
182
|
+
if ctx.invoked_subcommand is None:
|
183
|
+
click.echo(ctx.get_help())
|
184
|
+
|
185
|
+
|
186
|
+
@cli.command(context_settings=CONTEXT, help="List projects", hidden=True)
|
187
|
+
@click.option(
|
188
|
+
"--entity",
|
189
|
+
"-e",
|
190
|
+
default=None,
|
191
|
+
envvar=env.ENTITY,
|
192
|
+
help="The entity to scope the listing to.",
|
193
|
+
)
|
194
|
+
@display_error
|
195
|
+
def projects(entity, display=True):
|
196
|
+
api = _get_cling_api()
|
197
|
+
projects = api.list_projects(entity=entity)
|
198
|
+
if len(projects) == 0:
|
199
|
+
message = "No projects found for {}".format(entity)
|
200
|
+
else:
|
201
|
+
message = 'Latest projects for "{}"'.format(entity)
|
202
|
+
if display:
|
203
|
+
click.echo(click.style(message, bold=True))
|
204
|
+
for project in projects:
|
205
|
+
click.echo(
|
206
|
+
"".join(
|
207
|
+
(
|
208
|
+
click.style(project["name"], fg="blue", bold=True),
|
209
|
+
" - ",
|
210
|
+
str(project["description"] or "").split("\n")[0],
|
211
|
+
)
|
212
|
+
)
|
213
|
+
)
|
214
|
+
return projects
|
215
|
+
|
216
|
+
|
217
|
+
@cli.command(context_settings=CONTEXT, help="Login to Weights & Biases")
|
218
|
+
@click.argument("key", nargs=-1)
|
219
|
+
@click.option("--cloud", is_flag=True, help="Login to the cloud instead of local")
|
220
|
+
@click.option("--host", default=None, help="Login to a specific instance of W&B")
|
221
|
+
@click.option(
|
222
|
+
"--relogin", default=None, is_flag=True, help="Force relogin if already logged in."
|
223
|
+
)
|
224
|
+
@click.option("--anonymously", default=False, is_flag=True, help="Log in anonymously")
|
225
|
+
@click.option("--verify", default=False, is_flag=True, help="Verify login credentials")
|
226
|
+
@display_error
|
227
|
+
def login(key, host, cloud, relogin, anonymously, verify, no_offline=False):
|
228
|
+
# TODO: move CLI to wandb-core backend
|
229
|
+
wandb.require("legacy-service")
|
230
|
+
|
231
|
+
# TODO: handle no_offline
|
232
|
+
anon_mode = "must" if anonymously else "never"
|
233
|
+
|
234
|
+
wandb_sdk.wandb_login._handle_host_wandb_setting(host, cloud)
|
235
|
+
# A change in click or the test harness means key can be none...
|
236
|
+
key = key[0] if key is not None and len(key) > 0 else None
|
237
|
+
if key:
|
238
|
+
relogin = True
|
239
|
+
|
240
|
+
login_settings = dict(
|
241
|
+
x_cli_only_mode=True,
|
242
|
+
x_disable_viewer=relogin and not verify,
|
243
|
+
anonymous=anon_mode,
|
244
|
+
base_url=host,
|
245
|
+
)
|
246
|
+
|
247
|
+
try:
|
248
|
+
wandb.setup(
|
249
|
+
settings=wandb.Settings(
|
250
|
+
**{k: v for k, v in login_settings.items() if v is not None}
|
251
|
+
)
|
252
|
+
)
|
253
|
+
except TypeError as e:
|
254
|
+
wandb.termerror(str(e))
|
255
|
+
sys.exit(1)
|
256
|
+
|
257
|
+
wandb.login(
|
258
|
+
relogin=relogin,
|
259
|
+
key=key,
|
260
|
+
anonymous=anon_mode,
|
261
|
+
host=host,
|
262
|
+
force=True,
|
263
|
+
verify=verify,
|
264
|
+
)
|
265
|
+
|
266
|
+
|
267
|
+
@cli.command(
|
268
|
+
context_settings=CONTEXT, help="Run a wandb service", name="service", hidden=True
|
269
|
+
)
|
270
|
+
@click.option(
|
271
|
+
"--sock-port", default=None, type=int, help="The host port to bind socket service."
|
272
|
+
)
|
273
|
+
@click.option("--port-filename", default=None, help="Save allocated port to file.")
|
274
|
+
@click.option("--address", default=None, help="The address to bind service.")
|
275
|
+
@click.option("--pid", default=None, type=int, help="The parent process id to monitor.")
|
276
|
+
@click.option("--debug", is_flag=True, help="log debug info")
|
277
|
+
@display_error
|
278
|
+
def service(
|
279
|
+
sock_port=None,
|
280
|
+
port_filename=None,
|
281
|
+
address=None,
|
282
|
+
pid=None,
|
283
|
+
debug=False,
|
284
|
+
):
|
285
|
+
from wandb.sdk.service.server import WandbServer
|
286
|
+
|
287
|
+
server = WandbServer(
|
288
|
+
sock_port=sock_port,
|
289
|
+
port_fname=port_filename,
|
290
|
+
address=address,
|
291
|
+
pid=pid,
|
292
|
+
debug=debug,
|
293
|
+
)
|
294
|
+
server.serve()
|
295
|
+
|
296
|
+
|
297
|
+
@cli.command(
|
298
|
+
context_settings=CONTEXT, help="Configure a directory with Weights & Biases"
|
299
|
+
)
|
300
|
+
@click.option("--project", "-p", help="The project to use.")
|
301
|
+
@click.option("--entity", "-e", help="The entity to scope the project to.")
|
302
|
+
# TODO(jhr): Enable these with settings rework
|
303
|
+
# @click.option("--setting", "-s", help="enable an arbitrary setting.", multiple=True)
|
304
|
+
# @click.option('--show', is_flag=True, help="Show settings")
|
305
|
+
@click.option("--reset", is_flag=True, help="Reset settings")
|
306
|
+
@click.option(
|
307
|
+
"--mode",
|
308
|
+
"-m",
|
309
|
+
help=' Can be "online", "offline" or "disabled". Defaults to online.',
|
310
|
+
)
|
311
|
+
@click.pass_context
|
312
|
+
@display_error
|
313
|
+
def init(ctx, project, entity, reset, mode):
|
314
|
+
from wandb.old.core import __stage_dir__, _set_stage_dir, wandb_dir
|
315
|
+
|
316
|
+
if __stage_dir__ is None:
|
317
|
+
_set_stage_dir("wandb")
|
318
|
+
|
319
|
+
# non-interactive init
|
320
|
+
if reset or project or entity or mode:
|
321
|
+
api = InternalApi()
|
322
|
+
if reset:
|
323
|
+
api.clear_setting("entity", persist=True)
|
324
|
+
api.clear_setting("project", persist=True)
|
325
|
+
api.clear_setting("mode", persist=True)
|
326
|
+
# TODO(jhr): clear more settings?
|
327
|
+
if entity:
|
328
|
+
api.set_setting("entity", entity, persist=True)
|
329
|
+
if project:
|
330
|
+
api.set_setting("project", project, persist=True)
|
331
|
+
if mode:
|
332
|
+
api.set_setting("mode", mode, persist=True)
|
333
|
+
return
|
334
|
+
|
335
|
+
if os.path.isdir(wandb_dir()) and os.path.exists(
|
336
|
+
os.path.join(wandb_dir(), "settings")
|
337
|
+
):
|
338
|
+
click.confirm(
|
339
|
+
click.style(
|
340
|
+
"This directory has been configured previously, should we re-configure it?",
|
341
|
+
bold=True,
|
342
|
+
),
|
343
|
+
abort=True,
|
344
|
+
)
|
345
|
+
else:
|
346
|
+
click.echo(
|
347
|
+
click.style("Let's setup this directory for W&B!", fg="green", bold=True)
|
348
|
+
)
|
349
|
+
api = _get_cling_api()
|
350
|
+
if api.api_key is None:
|
351
|
+
ctx.invoke(login)
|
352
|
+
api = _get_cling_api(reset=True)
|
353
|
+
|
354
|
+
viewer = api.viewer()
|
355
|
+
|
356
|
+
# Viewer can be `None` in case your API information became invalid, or
|
357
|
+
# in testing if you switch hosts.
|
358
|
+
if not viewer:
|
359
|
+
click.echo(
|
360
|
+
click.style(
|
361
|
+
"Your login information seems to be invalid: can you log in again please?",
|
362
|
+
fg="red",
|
363
|
+
bold=True,
|
364
|
+
)
|
365
|
+
)
|
366
|
+
ctx.invoke(login)
|
367
|
+
api = _get_cling_api(reset=True)
|
368
|
+
|
369
|
+
# This shouldn't happen.
|
370
|
+
viewer = api.viewer()
|
371
|
+
if not viewer:
|
372
|
+
click.echo(
|
373
|
+
click.style(
|
374
|
+
"We're sorry, there was a problem logging you in. "
|
375
|
+
"Please send us a note at support@wandb.com and tell us how this happened.",
|
376
|
+
fg="red",
|
377
|
+
bold=True,
|
378
|
+
)
|
379
|
+
)
|
380
|
+
sys.exit(1)
|
381
|
+
|
382
|
+
# At this point we should be logged in successfully.
|
383
|
+
if len(viewer["teams"]["edges"]) > 1:
|
384
|
+
team_names = [e["node"]["name"] for e in viewer["teams"]["edges"]] + [
|
385
|
+
"Manual entry"
|
386
|
+
]
|
387
|
+
wandb.termlog(
|
388
|
+
"Which team should we use?",
|
389
|
+
)
|
390
|
+
result = util.prompt_choices(team_names)
|
391
|
+
# result can be empty on click
|
392
|
+
if result:
|
393
|
+
entity = result
|
394
|
+
else:
|
395
|
+
entity = "Manual Entry"
|
396
|
+
if entity == "Manual Entry":
|
397
|
+
entity = click.prompt("Enter the name of the team you want to use")
|
398
|
+
else:
|
399
|
+
entity = viewer.get("entity") or click.prompt(
|
400
|
+
"What username or team should we use?"
|
401
|
+
)
|
402
|
+
|
403
|
+
# TODO: this error handling sucks and the output isn't pretty
|
404
|
+
try:
|
405
|
+
project = prompt_for_project(ctx, entity)
|
406
|
+
except ClickWandbException:
|
407
|
+
raise ClickException(f"Could not find team: {entity}")
|
408
|
+
|
409
|
+
api.set_setting("entity", entity, persist=True)
|
410
|
+
api.set_setting("project", project, persist=True)
|
411
|
+
api.set_setting("base_url", api.settings().get("base_url"), persist=True)
|
412
|
+
|
413
|
+
filesystem.mkdir_exists_ok(wandb_dir())
|
414
|
+
with open(os.path.join(wandb_dir(), ".gitignore"), "w") as file:
|
415
|
+
file.write("*\n!settings")
|
416
|
+
|
417
|
+
click.echo(
|
418
|
+
click.style("This directory is configured! Next, track a run:\n", fg="green")
|
419
|
+
+ textwrap.dedent(
|
420
|
+
"""\
|
421
|
+
* In your training script:
|
422
|
+
{code1}
|
423
|
+
{code2}
|
424
|
+
* then `{run}`.
|
425
|
+
"""
|
426
|
+
).format(
|
427
|
+
code1=click.style("import wandb", bold=True),
|
428
|
+
code2=click.style('wandb.init(project="{}")'.format(project), bold=True),
|
429
|
+
run=click.style("python <train.py>", bold=True),
|
430
|
+
)
|
431
|
+
)
|
432
|
+
|
433
|
+
|
434
|
+
@cli.command(
|
435
|
+
context_settings=CONTEXT, help="Upload an offline training directory to W&B"
|
436
|
+
)
|
437
|
+
@click.pass_context
|
438
|
+
@click.argument("path", nargs=-1, type=click.Path(exists=True))
|
439
|
+
@click.option("--view", is_flag=True, default=False, help="View runs", hidden=True)
|
440
|
+
@click.option("--verbose", is_flag=True, default=False, help="Verbose", hidden=True)
|
441
|
+
@click.option("--id", "run_id", help="The run you want to upload to.")
|
442
|
+
@click.option("--project", "-p", help="The project you want to upload to.")
|
443
|
+
@click.option("--entity", "-e", help="The entity to scope to.")
|
444
|
+
@click.option(
|
445
|
+
"--job_type",
|
446
|
+
"job_type",
|
447
|
+
help="Specifies the type of run for grouping related runs together.",
|
448
|
+
)
|
449
|
+
@click.option(
|
450
|
+
"--sync-tensorboard/--no-sync-tensorboard",
|
451
|
+
is_flag=True,
|
452
|
+
default=None,
|
453
|
+
help="Stream tfevent files to wandb.",
|
454
|
+
)
|
455
|
+
@click.option("--include-globs", help="Comma separated list of globs to include.")
|
456
|
+
@click.option("--exclude-globs", help="Comma separated list of globs to exclude.")
|
457
|
+
@click.option(
|
458
|
+
"--include-online/--no-include-online",
|
459
|
+
is_flag=True,
|
460
|
+
default=None,
|
461
|
+
help="Include online runs",
|
462
|
+
)
|
463
|
+
@click.option(
|
464
|
+
"--include-offline/--no-include-offline",
|
465
|
+
is_flag=True,
|
466
|
+
default=None,
|
467
|
+
help="Include offline runs",
|
468
|
+
)
|
469
|
+
@click.option(
|
470
|
+
"--include-synced/--no-include-synced",
|
471
|
+
is_flag=True,
|
472
|
+
default=None,
|
473
|
+
help="Include synced runs",
|
474
|
+
)
|
475
|
+
@click.option(
|
476
|
+
"--mark-synced/--no-mark-synced",
|
477
|
+
is_flag=True,
|
478
|
+
default=True,
|
479
|
+
help="Mark runs as synced",
|
480
|
+
)
|
481
|
+
@click.option("--sync-all", is_flag=True, default=False, help="Sync all runs")
|
482
|
+
@click.option("--clean", is_flag=True, default=False, help="Delete synced runs")
|
483
|
+
@click.option(
|
484
|
+
"--clean-old-hours",
|
485
|
+
default=24,
|
486
|
+
help="Delete runs created before this many hours. To be used alongside --clean flag.",
|
487
|
+
type=int,
|
488
|
+
)
|
489
|
+
@click.option(
|
490
|
+
"--clean-force",
|
491
|
+
is_flag=True,
|
492
|
+
default=False,
|
493
|
+
help="Clean without confirmation prompt.",
|
494
|
+
)
|
495
|
+
@click.option("--ignore", hidden=True)
|
496
|
+
@click.option("--show", default=5, help="Number of runs to show")
|
497
|
+
@click.option("--append", is_flag=True, default=False, help="Append run")
|
498
|
+
@click.option("--skip-console", is_flag=True, default=False, help="Skip console logs")
|
499
|
+
@display_error
|
500
|
+
def sync(
|
501
|
+
ctx,
|
502
|
+
path=None,
|
503
|
+
view=None,
|
504
|
+
verbose=None,
|
505
|
+
run_id=None,
|
506
|
+
project=None,
|
507
|
+
entity=None,
|
508
|
+
job_type=None, # trace this back to SyncManager
|
509
|
+
sync_tensorboard=None,
|
510
|
+
include_globs=None,
|
511
|
+
exclude_globs=None,
|
512
|
+
include_online=None,
|
513
|
+
include_offline=None,
|
514
|
+
include_synced=None,
|
515
|
+
mark_synced=None,
|
516
|
+
sync_all=None,
|
517
|
+
ignore=None,
|
518
|
+
show=None,
|
519
|
+
clean=None,
|
520
|
+
clean_old_hours=24,
|
521
|
+
clean_force=None,
|
522
|
+
append=None,
|
523
|
+
skip_console=None,
|
524
|
+
):
|
525
|
+
api = _get_cling_api()
|
526
|
+
if not api.is_authenticated:
|
527
|
+
wandb.termlog("Login to W&B to sync offline runs")
|
528
|
+
ctx.invoke(login, no_offline=True)
|
529
|
+
api = _get_cling_api(reset=True)
|
530
|
+
|
531
|
+
if ignore:
|
532
|
+
exclude_globs = ignore
|
533
|
+
if include_globs:
|
534
|
+
include_globs = include_globs.split(",")
|
535
|
+
if exclude_globs:
|
536
|
+
exclude_globs = exclude_globs.split(",")
|
537
|
+
|
538
|
+
def _summary():
|
539
|
+
all_items = get_runs(
|
540
|
+
include_online=True,
|
541
|
+
include_offline=True,
|
542
|
+
include_synced=True,
|
543
|
+
include_unsynced=True,
|
544
|
+
)
|
545
|
+
sync_items = get_runs(
|
546
|
+
include_online=include_online if include_online is not None else True,
|
547
|
+
include_offline=include_offline if include_offline is not None else True,
|
548
|
+
include_synced=include_synced if include_synced is not None else False,
|
549
|
+
include_unsynced=True,
|
550
|
+
exclude_globs=exclude_globs,
|
551
|
+
include_globs=include_globs,
|
552
|
+
)
|
553
|
+
synced = []
|
554
|
+
unsynced = []
|
555
|
+
for item in all_items:
|
556
|
+
(synced if item.synced else unsynced).append(item)
|
557
|
+
if sync_items:
|
558
|
+
wandb.termlog(f"Number of runs to be synced: {len(sync_items)}")
|
559
|
+
if show and show < len(sync_items):
|
560
|
+
wandb.termlog(f"Showing {show} runs to be synced:")
|
561
|
+
for item in sync_items[: (show or len(sync_items))]:
|
562
|
+
wandb.termlog(f" {item}")
|
563
|
+
else:
|
564
|
+
wandb.termlog("No runs to be synced.")
|
565
|
+
if synced:
|
566
|
+
clean_cmd = click.style("wandb sync --clean", fg="yellow")
|
567
|
+
wandb.termlog(
|
568
|
+
f"NOTE: use {clean_cmd} to delete {len(synced)} synced runs from local directory."
|
569
|
+
)
|
570
|
+
if unsynced:
|
571
|
+
sync_cmd = click.style("wandb sync --sync-all", fg="yellow")
|
572
|
+
wandb.termlog(
|
573
|
+
f"NOTE: use {sync_cmd} to sync {len(unsynced)} unsynced runs from local directory."
|
574
|
+
)
|
575
|
+
|
576
|
+
def _sync_path(_path, _sync_tensorboard):
|
577
|
+
if run_id and len(_path) > 1:
|
578
|
+
wandb.termerror("id can only be set for a single run.")
|
579
|
+
sys.exit(1)
|
580
|
+
sm = SyncManager(
|
581
|
+
project=project,
|
582
|
+
entity=entity,
|
583
|
+
run_id=run_id,
|
584
|
+
job_type=job_type,
|
585
|
+
mark_synced=mark_synced,
|
586
|
+
app_url=api.app_url,
|
587
|
+
view=view,
|
588
|
+
verbose=verbose,
|
589
|
+
sync_tensorboard=_sync_tensorboard,
|
590
|
+
log_path=_wandb_log_path,
|
591
|
+
append=append,
|
592
|
+
skip_console=skip_console,
|
593
|
+
)
|
594
|
+
for p in _path:
|
595
|
+
sm.add(p)
|
596
|
+
sm.start()
|
597
|
+
while not sm.is_done():
|
598
|
+
_ = sm.poll()
|
599
|
+
|
600
|
+
def _sync_all():
|
601
|
+
sync_items = get_runs(
|
602
|
+
include_online=include_online if include_online is not None else True,
|
603
|
+
include_offline=include_offline if include_offline is not None else True,
|
604
|
+
include_synced=include_synced if include_synced is not None else False,
|
605
|
+
include_unsynced=True,
|
606
|
+
exclude_globs=exclude_globs,
|
607
|
+
include_globs=include_globs,
|
608
|
+
)
|
609
|
+
if not sync_items:
|
610
|
+
wandb.termerror("Nothing to sync.")
|
611
|
+
else:
|
612
|
+
# When syncing run directories, default to not syncing tensorboard
|
613
|
+
sync_tb = sync_tensorboard if sync_tensorboard is not None else False
|
614
|
+
_sync_path(sync_items, sync_tb)
|
615
|
+
|
616
|
+
def _clean():
|
617
|
+
if path:
|
618
|
+
runs = list(map(get_run_from_path, path))
|
619
|
+
if not clean_force:
|
620
|
+
click.confirm(
|
621
|
+
click.style(
|
622
|
+
f"Are you sure you want to remove {len(runs)} runs?",
|
623
|
+
bold=True,
|
624
|
+
),
|
625
|
+
abort=True,
|
626
|
+
)
|
627
|
+
for run in runs:
|
628
|
+
shutil.rmtree(run.path)
|
629
|
+
click.echo(click.style("Success!", fg="green"))
|
630
|
+
return
|
631
|
+
runs = get_runs(
|
632
|
+
include_online=include_online if include_online is not None else True,
|
633
|
+
include_offline=include_offline if include_offline is not None else True,
|
634
|
+
include_synced=include_synced if include_synced is not None else True,
|
635
|
+
include_unsynced=False,
|
636
|
+
exclude_globs=exclude_globs,
|
637
|
+
include_globs=include_globs,
|
638
|
+
)
|
639
|
+
since = datetime.datetime.now() - datetime.timedelta(hours=clean_old_hours)
|
640
|
+
old_runs = [run for run in runs if run.datetime < since]
|
641
|
+
old_runs.sort(key=lambda _run: _run.datetime)
|
642
|
+
if old_runs:
|
643
|
+
click.echo(
|
644
|
+
f"Found {len(runs)} runs, {len(old_runs)} are older than {clean_old_hours} hours"
|
645
|
+
)
|
646
|
+
for run in old_runs:
|
647
|
+
click.echo(run.path)
|
648
|
+
if not clean_force:
|
649
|
+
click.confirm(
|
650
|
+
click.style(
|
651
|
+
f"Are you sure you want to remove {len(old_runs)} runs?",
|
652
|
+
bold=True,
|
653
|
+
),
|
654
|
+
abort=True,
|
655
|
+
)
|
656
|
+
for run in old_runs:
|
657
|
+
shutil.rmtree(run.path)
|
658
|
+
click.echo(click.style("Success!", fg="green"))
|
659
|
+
else:
|
660
|
+
click.echo(
|
661
|
+
click.style(
|
662
|
+
f"No runs older than {clean_old_hours} hours found", fg="red"
|
663
|
+
)
|
664
|
+
)
|
665
|
+
|
666
|
+
if sync_all:
|
667
|
+
_sync_all()
|
668
|
+
elif clean:
|
669
|
+
_clean()
|
670
|
+
elif path:
|
671
|
+
# When syncing a specific path, default to syncing tensorboard
|
672
|
+
sync_tb = sync_tensorboard if sync_tensorboard is not None else True
|
673
|
+
_sync_path(path, sync_tb)
|
674
|
+
else:
|
675
|
+
_summary()
|
676
|
+
|
677
|
+
|
678
|
+
@cli.command(
|
679
|
+
context_settings=CONTEXT,
|
680
|
+
help="Initialize a hyperparameter sweep. Search for hyperparameters that optimizes a cost function of a machine learning model by testing various combinations.",
|
681
|
+
)
|
682
|
+
@click.option(
|
683
|
+
"--project",
|
684
|
+
"-p",
|
685
|
+
default=None,
|
686
|
+
help="""The name of the project where W&B runs created from the sweep are sent to. If the project is not specified, the run is sent to a project labeled Uncategorized.""",
|
687
|
+
)
|
688
|
+
@click.option(
|
689
|
+
"--entity",
|
690
|
+
"-e",
|
691
|
+
default=None,
|
692
|
+
help="""The username or team name where you want to send W&B runs created by the sweep to. Ensure that the entity you specify already exists. If you don't specify an entity, the run will be sent to your default entity, which is usually your username.""",
|
693
|
+
)
|
694
|
+
@click.option("--controller", is_flag=True, default=False, help="Run local controller")
|
695
|
+
@click.option("--verbose", is_flag=True, default=False, help="Display verbose output")
|
696
|
+
@click.option(
|
697
|
+
"--name",
|
698
|
+
default=None,
|
699
|
+
help="The name of the sweep. The sweep ID is used if no name is specified.",
|
700
|
+
)
|
701
|
+
@click.option("--program", default=None, help="Set sweep program")
|
702
|
+
@click.option("--settings", default=None, help="Set sweep settings", hidden=True)
|
703
|
+
@click.option("--update", default=None, help="Update pending sweep")
|
704
|
+
@click.option(
|
705
|
+
"--stop",
|
706
|
+
is_flag=True,
|
707
|
+
default=False,
|
708
|
+
help="Finish a sweep to stop running new runs and let currently running runs finish.",
|
709
|
+
)
|
710
|
+
@click.option(
|
711
|
+
"--cancel",
|
712
|
+
is_flag=True,
|
713
|
+
default=False,
|
714
|
+
help="Cancel a sweep to kill all running runs and stop running new runs.",
|
715
|
+
)
|
716
|
+
@click.option(
|
717
|
+
"--pause",
|
718
|
+
is_flag=True,
|
719
|
+
default=False,
|
720
|
+
help="Pause a sweep to temporarily stop running new runs.",
|
721
|
+
)
|
722
|
+
@click.option(
|
723
|
+
"--resume",
|
724
|
+
is_flag=True,
|
725
|
+
default=False,
|
726
|
+
help="Resume a sweep to continue running new runs.",
|
727
|
+
)
|
728
|
+
@click.option(
|
729
|
+
"--prior_run",
|
730
|
+
"-R",
|
731
|
+
"prior_runs",
|
732
|
+
multiple=True,
|
733
|
+
default=None,
|
734
|
+
help="ID of an existing run to add to this sweep",
|
735
|
+
)
|
736
|
+
@click.argument("config_yaml_or_sweep_id")
|
737
|
+
@click.pass_context
|
738
|
+
@display_error
|
739
|
+
def sweep(
|
740
|
+
ctx,
|
741
|
+
project,
|
742
|
+
entity,
|
743
|
+
controller,
|
744
|
+
verbose,
|
745
|
+
name,
|
746
|
+
program,
|
747
|
+
settings,
|
748
|
+
update,
|
749
|
+
stop,
|
750
|
+
cancel,
|
751
|
+
pause,
|
752
|
+
resume,
|
753
|
+
prior_runs,
|
754
|
+
config_yaml_or_sweep_id,
|
755
|
+
):
|
756
|
+
state_args = "stop", "cancel", "pause", "resume"
|
757
|
+
lcls = locals()
|
758
|
+
is_state_change_command = sum(lcls[k] for k in state_args)
|
759
|
+
if is_state_change_command > 1:
|
760
|
+
raise Exception("Only one state flag (stop/cancel/pause/resume) is allowed.")
|
761
|
+
elif is_state_change_command == 1:
|
762
|
+
sweep_id = config_yaml_or_sweep_id
|
763
|
+
api = _get_cling_api()
|
764
|
+
if not api.is_authenticated:
|
765
|
+
wandb.termlog("Login to W&B to use the sweep feature")
|
766
|
+
ctx.invoke(login, no_offline=True)
|
767
|
+
api = _get_cling_api(reset=True)
|
768
|
+
parts = dict(entity=entity, project=project, name=sweep_id)
|
769
|
+
err = sweep_utils.parse_sweep_id(parts)
|
770
|
+
if err:
|
771
|
+
wandb.termerror(err)
|
772
|
+
return
|
773
|
+
entity = parts.get("entity") or entity
|
774
|
+
project = parts.get("project") or project
|
775
|
+
sweep_id = parts.get("name") or sweep_id
|
776
|
+
state = [s for s in state_args if lcls[s]][0]
|
777
|
+
ings = {
|
778
|
+
"stop": "Stopping",
|
779
|
+
"cancel": "Cancelling",
|
780
|
+
"pause": "Pausing",
|
781
|
+
"resume": "Resuming",
|
782
|
+
}
|
783
|
+
wandb.termlog(f"{ings[state]} sweep {entity}/{project}/{sweep_id}")
|
784
|
+
getattr(api, "{}_sweep".format(state))(sweep_id, entity=entity, project=project)
|
785
|
+
wandb.termlog("Done.")
|
786
|
+
return
|
787
|
+
else:
|
788
|
+
config_yaml = config_yaml_or_sweep_id
|
789
|
+
|
790
|
+
def _parse_settings(settings):
|
791
|
+
"""Parse settings from json or comma separated assignments."""
|
792
|
+
ret = {}
|
793
|
+
# TODO(jhr): merge with magic:_parse_magic
|
794
|
+
if settings.find("=") > 0:
|
795
|
+
for item in settings.split(","):
|
796
|
+
kv = item.split("=")
|
797
|
+
if len(kv) != 2:
|
798
|
+
wandb.termwarn(
|
799
|
+
"Unable to parse sweep settings key value pair", repeat=False
|
800
|
+
)
|
801
|
+
ret.update(dict([kv]))
|
802
|
+
return ret
|
803
|
+
wandb.termwarn("Unable to parse settings parameter", repeat=False)
|
804
|
+
return ret
|
805
|
+
|
806
|
+
api = _get_cling_api()
|
807
|
+
if not api.is_authenticated:
|
808
|
+
wandb.termlog("Login to W&B to use the sweep feature")
|
809
|
+
ctx.invoke(login, no_offline=True)
|
810
|
+
api = _get_cling_api(reset=True)
|
811
|
+
|
812
|
+
sweep_obj_id = None
|
813
|
+
if update:
|
814
|
+
parts = dict(entity=entity, project=project, name=update)
|
815
|
+
err = sweep_utils.parse_sweep_id(parts)
|
816
|
+
if err:
|
817
|
+
wandb.termerror(err)
|
818
|
+
return
|
819
|
+
entity = parts.get("entity") or entity
|
820
|
+
project = parts.get("project") or project
|
821
|
+
sweep_id = parts.get("name") or update
|
822
|
+
|
823
|
+
has_project = (project or api.settings("project")) is not None
|
824
|
+
has_entity = (entity or api.settings("entity")) is not None
|
825
|
+
|
826
|
+
termerror_msg = (
|
827
|
+
"Sweep lookup requires a valid %s, and none was specified. \n"
|
828
|
+
"Either set a default %s in wandb/settings, or, if invoking \n`wandb sweep` "
|
829
|
+
"from the command line, specify the full sweep path via: \n\n"
|
830
|
+
" wandb sweep {username}/{projectname}/{sweepid}\n\n"
|
831
|
+
)
|
832
|
+
|
833
|
+
if not has_entity:
|
834
|
+
wandb.termerror(termerror_msg % (("entity",) * 2))
|
835
|
+
return
|
836
|
+
|
837
|
+
if not has_project:
|
838
|
+
wandb.termerror(termerror_msg % (("project",) * 2))
|
839
|
+
return
|
840
|
+
|
841
|
+
found = api.sweep(sweep_id, "{}", entity=entity, project=project)
|
842
|
+
if not found:
|
843
|
+
wandb.termerror(f"Could not find sweep {entity}/{project}/{sweep_id}")
|
844
|
+
return
|
845
|
+
sweep_obj_id = found["id"]
|
846
|
+
|
847
|
+
action = "Updating" if sweep_obj_id else "Creating"
|
848
|
+
wandb.termlog(f"{action} sweep from: {config_yaml}")
|
849
|
+
config = sweep_utils.load_sweep_config(config_yaml)
|
850
|
+
|
851
|
+
# Set or override parameters
|
852
|
+
if name:
|
853
|
+
config["name"] = name
|
854
|
+
if program:
|
855
|
+
config["program"] = program
|
856
|
+
if settings:
|
857
|
+
settings = _parse_settings(settings)
|
858
|
+
if settings:
|
859
|
+
config.setdefault("settings", {})
|
860
|
+
config["settings"].update(settings)
|
861
|
+
if controller:
|
862
|
+
config.setdefault("controller", {})
|
863
|
+
config["controller"]["type"] = "local"
|
864
|
+
|
865
|
+
is_local = config.get("controller", {}).get("type") == "local"
|
866
|
+
if is_local:
|
867
|
+
from wandb import controller as wandb_controller
|
868
|
+
|
869
|
+
tuner = wandb_controller()
|
870
|
+
err = tuner._validate(config)
|
871
|
+
if err:
|
872
|
+
wandb.termerror(f"Error in sweep file: {err}")
|
873
|
+
return
|
874
|
+
|
875
|
+
env = os.environ
|
876
|
+
entity = (
|
877
|
+
entity
|
878
|
+
or env.get("WANDB_ENTITY")
|
879
|
+
or config.get("entity")
|
880
|
+
or api.settings("entity")
|
881
|
+
)
|
882
|
+
project = (
|
883
|
+
project
|
884
|
+
or env.get("WANDB_PROJECT")
|
885
|
+
or config.get("project")
|
886
|
+
or api.settings("project")
|
887
|
+
or util.auto_project_name(config.get("program"))
|
888
|
+
)
|
889
|
+
|
890
|
+
sweep_id, warnings = api.upsert_sweep(
|
891
|
+
config,
|
892
|
+
project=project,
|
893
|
+
entity=entity,
|
894
|
+
obj_id=sweep_obj_id,
|
895
|
+
prior_runs=prior_runs,
|
896
|
+
)
|
897
|
+
sweep_utils.handle_sweep_config_violations(warnings)
|
898
|
+
|
899
|
+
# Log nicely formatted sweep information
|
900
|
+
styled_id = click.style(sweep_id, fg="yellow")
|
901
|
+
wandb.termlog(f"{action} sweep with ID: {styled_id}")
|
902
|
+
|
903
|
+
sweep_url = wandb_sdk.wandb_sweep._get_sweep_url(api, sweep_id)
|
904
|
+
if sweep_url:
|
905
|
+
styled_url = click.style(sweep_url, underline=True, fg="blue")
|
906
|
+
wandb.termlog(f"View sweep at: {styled_url}")
|
907
|
+
|
908
|
+
# re-probe entity and project if it was auto-detected by upsert_sweep
|
909
|
+
entity = entity or env.get("WANDB_ENTITY")
|
910
|
+
project = project or env.get("WANDB_PROJECT")
|
911
|
+
|
912
|
+
if entity and project:
|
913
|
+
sweep_path = f"{entity}/{project}/{sweep_id}"
|
914
|
+
elif project:
|
915
|
+
sweep_path = f"{project}/{sweep_id}"
|
916
|
+
else:
|
917
|
+
sweep_path = sweep_id
|
918
|
+
|
919
|
+
if sweep_path.find(" ") >= 0:
|
920
|
+
sweep_path = f"{sweep_path!r}"
|
921
|
+
|
922
|
+
styled_path = click.style(f"wandb agent {sweep_path}", fg="yellow")
|
923
|
+
wandb.termlog(f"Run sweep agent with: {styled_path}")
|
924
|
+
if controller:
|
925
|
+
wandb.termlog("Starting wandb controller...")
|
926
|
+
from wandb import controller as wandb_controller
|
927
|
+
|
928
|
+
tuner = wandb_controller(sweep_id)
|
929
|
+
tuner.run(verbose=verbose)
|
930
|
+
|
931
|
+
|
932
|
+
@cli.command(
|
933
|
+
context_settings=CONTEXT,
|
934
|
+
no_args_is_help=True,
|
935
|
+
help="Run a W&B launch sweep (Experimental).",
|
936
|
+
)
|
937
|
+
@click.option(
|
938
|
+
"--queue",
|
939
|
+
"-q",
|
940
|
+
default=None,
|
941
|
+
help="The name of a queue to push the sweep to",
|
942
|
+
)
|
943
|
+
@click.option(
|
944
|
+
"--project",
|
945
|
+
"-p",
|
946
|
+
default=None,
|
947
|
+
help="Name of the project which the agent will watch. "
|
948
|
+
"If passed in, will override the project value passed in using a config file",
|
949
|
+
)
|
950
|
+
@click.option(
|
951
|
+
"--entity",
|
952
|
+
"-e",
|
953
|
+
default=None,
|
954
|
+
help="The entity to use. Defaults to current logged-in user",
|
955
|
+
)
|
956
|
+
@click.option(
|
957
|
+
"--resume_id",
|
958
|
+
"-r",
|
959
|
+
default=None,
|
960
|
+
help="Resume a launch sweep by passing an 8-char sweep id. Queue required",
|
961
|
+
)
|
962
|
+
@click.option(
|
963
|
+
"--prior_run",
|
964
|
+
"-R",
|
965
|
+
"prior_runs",
|
966
|
+
multiple=True,
|
967
|
+
default=None,
|
968
|
+
help="ID of an existing run to add to this sweep",
|
969
|
+
)
|
970
|
+
@click.argument("config", required=False, type=click.Path(exists=True))
|
971
|
+
@click.pass_context
|
972
|
+
@display_error
|
973
|
+
def launch_sweep(
|
974
|
+
ctx,
|
975
|
+
project,
|
976
|
+
entity,
|
977
|
+
queue,
|
978
|
+
config,
|
979
|
+
resume_id,
|
980
|
+
prior_runs,
|
981
|
+
):
|
982
|
+
api = _get_cling_api()
|
983
|
+
env = os.environ
|
984
|
+
if not api.is_authenticated:
|
985
|
+
wandb.termlog("Login to W&B to use the sweep feature")
|
986
|
+
ctx.invoke(login, no_offline=True)
|
987
|
+
api = _get_cling_api(reset=True)
|
988
|
+
|
989
|
+
entity = entity or env.get("WANDB_ENTITY") or api.settings("entity")
|
990
|
+
if entity is None:
|
991
|
+
wandb.termerror("Must specify entity when using launch")
|
992
|
+
return
|
993
|
+
|
994
|
+
project = project or env.get("WANDB_PROJECT") or api.settings("project")
|
995
|
+
if project is None:
|
996
|
+
wandb.termerror("A project must be configured when using launch")
|
997
|
+
return
|
998
|
+
|
999
|
+
# get personal username, not team name or service account, default to entity
|
1000
|
+
author = api.viewer().get("username") or entity
|
1001
|
+
|
1002
|
+
# if not sweep_config XOR resume_id
|
1003
|
+
if not (config or resume_id):
|
1004
|
+
wandb.termerror("'config' and/or 'resume_id' required")
|
1005
|
+
return
|
1006
|
+
|
1007
|
+
parsed_user_config = sweep_utils.load_launch_sweep_config(config)
|
1008
|
+
# Rip special keys out of config, store in scheduler run_config
|
1009
|
+
launch_args: Dict[str, Any] = parsed_user_config.pop("launch", {})
|
1010
|
+
scheduler_args: Dict[str, Any] = parsed_user_config.pop("scheduler", {})
|
1011
|
+
settings: Dict[str, Any] = scheduler_args.pop("settings", {})
|
1012
|
+
|
1013
|
+
scheduler_job: Optional[str] = scheduler_args.get("job")
|
1014
|
+
if scheduler_job:
|
1015
|
+
wandb.termwarn(
|
1016
|
+
"Using a scheduler job for launch sweeps is *experimental* and may change without warning"
|
1017
|
+
)
|
1018
|
+
queue: Optional[str] = queue or launch_args.get("queue")
|
1019
|
+
|
1020
|
+
sweep_config, sweep_obj_id = None, None
|
1021
|
+
if not resume_id:
|
1022
|
+
sweep_config = parsed_user_config
|
1023
|
+
|
1024
|
+
# check method
|
1025
|
+
method = sweep_config.get("method")
|
1026
|
+
if scheduler_job and not method:
|
1027
|
+
sweep_config["method"] = "custom"
|
1028
|
+
elif scheduler_job and method != "custom":
|
1029
|
+
# TODO(gst): Check if using Anaconda2
|
1030
|
+
wandb.termwarn(
|
1031
|
+
"Use 'method': 'custom' in the sweep config when using scheduler jobs, "
|
1032
|
+
"or omit it entirely. For jobs using the wandb optimization engine (WandbScheduler), "
|
1033
|
+
"set the method in the sweep config under scheduler.settings.method "
|
1034
|
+
)
|
1035
|
+
settings["method"] = method
|
1036
|
+
|
1037
|
+
if settings.get("method"):
|
1038
|
+
# assume WandbScheduler, and user is using this right
|
1039
|
+
sweep_config["method"] = settings["method"]
|
1040
|
+
|
1041
|
+
else: # Resuming an existing sweep
|
1042
|
+
found = api.sweep(resume_id, "{}", entity=entity, project=project)
|
1043
|
+
if not found:
|
1044
|
+
wandb.termerror(f"Could not find sweep {entity}/{project}/{resume_id}")
|
1045
|
+
return
|
1046
|
+
|
1047
|
+
if found.get("state") == "RUNNING":
|
1048
|
+
wandb.termerror(
|
1049
|
+
f"Cannot resume sweep {entity}/{project}/{resume_id}, it is already running"
|
1050
|
+
)
|
1051
|
+
return
|
1052
|
+
|
1053
|
+
sweep_obj_id = found["id"]
|
1054
|
+
sweep_config = yaml.safe_load(found["config"])
|
1055
|
+
wandb.termlog(f"Resuming from existing sweep {entity}/{project}/{resume_id}")
|
1056
|
+
if len(parsed_user_config.keys()) > 0:
|
1057
|
+
wandb.termwarn(
|
1058
|
+
"Sweep parameters loaded from resumed sweep, ignoring provided config"
|
1059
|
+
)
|
1060
|
+
|
1061
|
+
prev_scheduler = json.loads(found.get("scheduler") or "{}")
|
1062
|
+
run_spec = json.loads(prev_scheduler.get("run_spec", "{}"))
|
1063
|
+
if (
|
1064
|
+
scheduler_job
|
1065
|
+
and run_spec.get("job")
|
1066
|
+
and run_spec.get("job") != scheduler_job
|
1067
|
+
):
|
1068
|
+
wandb.termerror(
|
1069
|
+
f"Resuming a launch sweep with a different scheduler job is not supported. Job loaded from sweep: {run_spec.get('job')}, job in config: {scheduler_job}"
|
1070
|
+
)
|
1071
|
+
return
|
1072
|
+
|
1073
|
+
prev_scheduler_args, prev_settings = sweep_utils.get_previous_args(run_spec)
|
1074
|
+
# Passed in scheduler_args and settings override previous
|
1075
|
+
scheduler_args.update(prev_scheduler_args)
|
1076
|
+
settings.update(prev_settings)
|
1077
|
+
if not queue:
|
1078
|
+
wandb.termerror(
|
1079
|
+
"Launch-sweeps require setting a 'queue', use --queue option or a 'queue' key in the 'launch' section in the config"
|
1080
|
+
)
|
1081
|
+
return
|
1082
|
+
|
1083
|
+
entrypoint = Scheduler.ENTRYPOINT if not scheduler_job else None
|
1084
|
+
args = sweep_utils.construct_scheduler_args(
|
1085
|
+
return_job=scheduler_job is not None,
|
1086
|
+
sweep_config=sweep_config,
|
1087
|
+
queue=queue,
|
1088
|
+
project=project,
|
1089
|
+
author=author,
|
1090
|
+
)
|
1091
|
+
if not args:
|
1092
|
+
return
|
1093
|
+
|
1094
|
+
# validate training job existence
|
1095
|
+
if not sweep_utils.check_job_exists(PublicApi(), sweep_config.get("job")):
|
1096
|
+
return False
|
1097
|
+
|
1098
|
+
# validate scheduler job existence, if present
|
1099
|
+
if not sweep_utils.check_job_exists(PublicApi(), scheduler_job):
|
1100
|
+
return False
|
1101
|
+
|
1102
|
+
# Set run overrides for the Scheduler
|
1103
|
+
overrides = {"run_config": {}}
|
1104
|
+
if launch_args:
|
1105
|
+
overrides["run_config"]["launch"] = launch_args
|
1106
|
+
if scheduler_args:
|
1107
|
+
overrides["run_config"]["scheduler"] = scheduler_args
|
1108
|
+
if settings:
|
1109
|
+
overrides["run_config"]["settings"] = settings
|
1110
|
+
|
1111
|
+
if scheduler_job:
|
1112
|
+
overrides["run_config"]["sweep_args"] = args
|
1113
|
+
else:
|
1114
|
+
overrides["args"] = args
|
1115
|
+
|
1116
|
+
# configure scheduler job resource
|
1117
|
+
resource = scheduler_args.get("resource")
|
1118
|
+
if resource:
|
1119
|
+
if resource == "local-process" and scheduler_job:
|
1120
|
+
wandb.termerror(
|
1121
|
+
"Scheduler jobs cannot be run with the 'local-process' resource"
|
1122
|
+
)
|
1123
|
+
return
|
1124
|
+
if resource == "local-process" and scheduler_args.get("docker_image"):
|
1125
|
+
wandb.termerror(
|
1126
|
+
"Scheduler jobs cannot be run with the 'local-process' resource and a docker image"
|
1127
|
+
)
|
1128
|
+
return
|
1129
|
+
else: # no resource set, default local-process if not scheduler job, else container
|
1130
|
+
resource = "local-process" if not scheduler_job else "local-container"
|
1131
|
+
|
1132
|
+
# Launch job spec for the Scheduler
|
1133
|
+
launch_scheduler_spec = launch_utils.construct_launch_spec(
|
1134
|
+
uri=Scheduler.PLACEHOLDER_URI,
|
1135
|
+
api=api,
|
1136
|
+
name="Scheduler.WANDB_SWEEP_ID",
|
1137
|
+
project=project,
|
1138
|
+
entity=entity,
|
1139
|
+
docker_image=scheduler_args.get("docker_image"),
|
1140
|
+
resource=resource,
|
1141
|
+
entry_point=entrypoint,
|
1142
|
+
resource_args=scheduler_args.get("resource_args", {}),
|
1143
|
+
repository=launch_args.get("registry", {}).get("url", None),
|
1144
|
+
job=scheduler_job,
|
1145
|
+
version=None,
|
1146
|
+
launch_config={"overrides": overrides},
|
1147
|
+
run_id="WANDB_SWEEP_ID", # scheduler inits run with sweep_id=run_id
|
1148
|
+
author=None, # author gets passed into scheduler override args
|
1149
|
+
)
|
1150
|
+
launch_scheduler_with_queue = json.dumps(
|
1151
|
+
{
|
1152
|
+
"queue": queue,
|
1153
|
+
"run_queue_project": launch_utils.LAUNCH_DEFAULT_PROJECT,
|
1154
|
+
"run_spec": json.dumps(launch_scheduler_spec),
|
1155
|
+
}
|
1156
|
+
)
|
1157
|
+
|
1158
|
+
sweep_id, warnings = api.upsert_sweep(
|
1159
|
+
sweep_config,
|
1160
|
+
project=project,
|
1161
|
+
entity=entity,
|
1162
|
+
obj_id=sweep_obj_id, # if resuming
|
1163
|
+
launch_scheduler=launch_scheduler_with_queue,
|
1164
|
+
state="PENDING",
|
1165
|
+
prior_runs=prior_runs,
|
1166
|
+
template_variable_values=scheduler_args.get("template_variables", None),
|
1167
|
+
)
|
1168
|
+
sweep_utils.handle_sweep_config_violations(warnings)
|
1169
|
+
# Log nicely formatted sweep information
|
1170
|
+
styled_id = click.style(sweep_id, fg="yellow")
|
1171
|
+
wandb.termlog(f"{'Resumed' if resume_id else 'Created'} sweep with ID: {styled_id}")
|
1172
|
+
sweep_url = wandb_sdk.wandb_sweep._get_sweep_url(api, sweep_id)
|
1173
|
+
if sweep_url:
|
1174
|
+
styled_url = click.style(sweep_url, underline=True, fg="blue")
|
1175
|
+
wandb.termlog(f"View sweep at: {styled_url}")
|
1176
|
+
wandb.termlog(f"Scheduler added to launch queue ({queue})")
|
1177
|
+
|
1178
|
+
|
1179
|
+
@cli.command(help=f"Launch or queue a W&B Job. See {url_registry.url('wandb-launch')}")
|
1180
|
+
@click.option(
|
1181
|
+
"--uri",
|
1182
|
+
"-u",
|
1183
|
+
metavar="(str)",
|
1184
|
+
default=None,
|
1185
|
+
help="Local path or git repo uri to launch. If provided this command will "
|
1186
|
+
"create a job from the specified uri.",
|
1187
|
+
)
|
1188
|
+
@click.option(
|
1189
|
+
"--job",
|
1190
|
+
"-j",
|
1191
|
+
metavar="(str)",
|
1192
|
+
default=None,
|
1193
|
+
help="Name of the job to launch. If passed in, launch does not require a uri.",
|
1194
|
+
)
|
1195
|
+
@click.option(
|
1196
|
+
"--entry-point",
|
1197
|
+
"-E",
|
1198
|
+
metavar="NAME",
|
1199
|
+
default=None,
|
1200
|
+
help="""Entry point within project. [default: main]. If the entry point is not found,
|
1201
|
+
attempts to run the project file with the specified name as a script,
|
1202
|
+
using 'python' to run .py files and the default shell (specified by
|
1203
|
+
environment variable $SHELL) to run .sh files. If passed in, will override the entrypoint value passed in using a config file.""",
|
1204
|
+
)
|
1205
|
+
@click.option(
|
1206
|
+
"--git-version",
|
1207
|
+
"-g",
|
1208
|
+
metavar="GIT-VERSION",
|
1209
|
+
hidden=True,
|
1210
|
+
help="Version of the project to run, as a Git commit reference for Git projects.",
|
1211
|
+
)
|
1212
|
+
@click.option(
|
1213
|
+
"--build-context",
|
1214
|
+
metavar="(str)",
|
1215
|
+
help="Path to the build context within the source code. Defaults to the "
|
1216
|
+
"root of the source code. Compatible only with -u.",
|
1217
|
+
)
|
1218
|
+
@click.option(
|
1219
|
+
"--job-name",
|
1220
|
+
"-J",
|
1221
|
+
metavar="(str)",
|
1222
|
+
default=None,
|
1223
|
+
hidden=True,
|
1224
|
+
help="Name for the job created if the -u,--uri flag is passed in.",
|
1225
|
+
)
|
1226
|
+
@click.option(
|
1227
|
+
"--name",
|
1228
|
+
envvar="WANDB_NAME",
|
1229
|
+
help="""Name of the run under which to launch the run. If not
|
1230
|
+
specified, a random run name will be used to launch run. If passed in, will override the name passed in using a config file.""",
|
1231
|
+
)
|
1232
|
+
@click.option(
|
1233
|
+
"--entity",
|
1234
|
+
"-e",
|
1235
|
+
metavar="(str)",
|
1236
|
+
default=None,
|
1237
|
+
help="""Name of the target entity which the new run will be sent to. Defaults to using the entity set by local wandb/settings folder.
|
1238
|
+
If passed in, will override the entity value passed in using a config file.""",
|
1239
|
+
)
|
1240
|
+
@click.option(
|
1241
|
+
"--project",
|
1242
|
+
"-p",
|
1243
|
+
metavar="(str)",
|
1244
|
+
default=None,
|
1245
|
+
help="""Name of the target project which the new run will be sent to. Defaults to using the project name given by the source uri
|
1246
|
+
or for github runs, the git repo name. If passed in, will override the project value passed in using a config file.""",
|
1247
|
+
)
|
1248
|
+
@click.option(
|
1249
|
+
"--resource",
|
1250
|
+
"-r",
|
1251
|
+
metavar="BACKEND",
|
1252
|
+
default=None,
|
1253
|
+
help="""Execution resource to use for run. Supported values: 'local-process', 'local-container', 'kubernetes', 'sagemaker', 'gcp-vertex'.
|
1254
|
+
This is now a required parameter if pushing to a queue with no resource configuration.
|
1255
|
+
If passed in, will override the resource value passed in using a config file.""",
|
1256
|
+
)
|
1257
|
+
@click.option(
|
1258
|
+
"--docker-image",
|
1259
|
+
"-d",
|
1260
|
+
default=None,
|
1261
|
+
metavar="DOCKER IMAGE",
|
1262
|
+
help="""Specific docker image you'd like to use. In the form name:tag.
|
1263
|
+
If passed in, will override the docker image value passed in using a config file.""",
|
1264
|
+
)
|
1265
|
+
@click.option(
|
1266
|
+
"--base-image",
|
1267
|
+
"-B",
|
1268
|
+
default=None,
|
1269
|
+
metavar="BASE IMAGE",
|
1270
|
+
help="""Docker image to run job code in. Incompatible with --docker-image.""",
|
1271
|
+
)
|
1272
|
+
@click.option(
|
1273
|
+
"--config",
|
1274
|
+
"-c",
|
1275
|
+
metavar="FILE",
|
1276
|
+
help="""Path to JSON file (must end in '.json') or JSON string which will be passed
|
1277
|
+
as a launch config. Dictation how the launched run will be configured.""",
|
1278
|
+
)
|
1279
|
+
@click.option(
|
1280
|
+
"--set-var",
|
1281
|
+
"-v",
|
1282
|
+
"cli_template_vars",
|
1283
|
+
default=None,
|
1284
|
+
multiple=True,
|
1285
|
+
help="""Set template variable values for queues with allow listing enabled,
|
1286
|
+
as key-value pairs e.g. `--set-var key1=value1 --set-var key2=value2`""",
|
1287
|
+
)
|
1288
|
+
@click.option(
|
1289
|
+
"--queue",
|
1290
|
+
"-q",
|
1291
|
+
is_flag=False,
|
1292
|
+
flag_value="default",
|
1293
|
+
default=None,
|
1294
|
+
help="""Name of run queue to push to. If none, launches single run directly. If supplied without
|
1295
|
+
an argument (`--queue`), defaults to queue 'default'. Else, if name supplied, specified run queue must exist under the
|
1296
|
+
project and entity supplied.""",
|
1297
|
+
)
|
1298
|
+
@click.option(
|
1299
|
+
"--async",
|
1300
|
+
"run_async",
|
1301
|
+
is_flag=True,
|
1302
|
+
help="""Flag to run the job asynchronously. Defaults to false, i.e. unless --async is set, wandb launch will wait for
|
1303
|
+
the job to finish. This option is incompatible with --queue; asynchronous options when running with an agent should be
|
1304
|
+
set on wandb launch-agent.""",
|
1305
|
+
)
|
1306
|
+
@click.option(
|
1307
|
+
"--resource-args",
|
1308
|
+
"-R",
|
1309
|
+
metavar="FILE",
|
1310
|
+
help="""Path to JSON file (must end in '.json') or JSON string which will be passed
|
1311
|
+
as resource args to the compute resource. The exact content which should be
|
1312
|
+
provided is different for each execution backend. See documentation for layout of this file.""",
|
1313
|
+
)
|
1314
|
+
@click.option(
|
1315
|
+
"--build",
|
1316
|
+
"-b",
|
1317
|
+
is_flag=True,
|
1318
|
+
hidden=True,
|
1319
|
+
help="Flag to build an associated job and push to queue as an image job.",
|
1320
|
+
)
|
1321
|
+
@click.option(
|
1322
|
+
"--repository",
|
1323
|
+
"-rg",
|
1324
|
+
is_flag=False,
|
1325
|
+
default=None,
|
1326
|
+
hidden=True,
|
1327
|
+
help="Name of a remote repository. Will be used to push a built image to.",
|
1328
|
+
)
|
1329
|
+
# TODO: this is only included for back compat. But we should remove this in the future
|
1330
|
+
@click.option(
|
1331
|
+
"--project-queue",
|
1332
|
+
"-pq",
|
1333
|
+
default=None,
|
1334
|
+
hidden=True,
|
1335
|
+
help="Name of the project containing the queue to push to. If none, defaults to entity level queues.",
|
1336
|
+
)
|
1337
|
+
@click.option(
|
1338
|
+
"--dockerfile",
|
1339
|
+
"-D",
|
1340
|
+
default=None,
|
1341
|
+
help="Path to the Dockerfile used to build the job, relative to the job's root",
|
1342
|
+
)
|
1343
|
+
@click.option(
|
1344
|
+
"--priority",
|
1345
|
+
"-P",
|
1346
|
+
default=None,
|
1347
|
+
type=click.Choice(["critical", "high", "medium", "low"]),
|
1348
|
+
help="""When --queue is passed, set the priority of the job. Launch jobs with higher priority
|
1349
|
+
are served first. The order, from highest to lowest priority, is: critical, high, medium, low""",
|
1350
|
+
)
|
1351
|
+
@display_error
|
1352
|
+
def launch(
|
1353
|
+
uri,
|
1354
|
+
job,
|
1355
|
+
entry_point,
|
1356
|
+
git_version,
|
1357
|
+
build_context,
|
1358
|
+
name,
|
1359
|
+
resource,
|
1360
|
+
entity,
|
1361
|
+
project,
|
1362
|
+
docker_image,
|
1363
|
+
base_image,
|
1364
|
+
config,
|
1365
|
+
cli_template_vars,
|
1366
|
+
queue,
|
1367
|
+
run_async,
|
1368
|
+
resource_args,
|
1369
|
+
build,
|
1370
|
+
repository,
|
1371
|
+
project_queue,
|
1372
|
+
dockerfile,
|
1373
|
+
priority,
|
1374
|
+
job_name,
|
1375
|
+
):
|
1376
|
+
"""Start a W&B run from the given URI.
|
1377
|
+
|
1378
|
+
The URI can bea wandb URI, a GitHub repo uri, or a local path). In the case of a
|
1379
|
+
wandb URI the arguments used in the original run will be used by default. These
|
1380
|
+
arguments can be overridden using the args option, or specifying those arguments in
|
1381
|
+
the config's 'overrides' key, 'args' field as a list of strings.
|
1382
|
+
|
1383
|
+
Running `wandb launch [URI]` will launch the run directly. To add the run to a
|
1384
|
+
queue, run `wandb launch [URI] --queue [optional queuename]`.
|
1385
|
+
"""
|
1386
|
+
logger.info(
|
1387
|
+
f"=== Launch called with kwargs {locals()} CLI Version: {wandb.__version__}==="
|
1388
|
+
)
|
1389
|
+
from wandb.sdk.launch._launch import _launch
|
1390
|
+
from wandb.sdk.launch.create_job import _create_job
|
1391
|
+
from wandb.sdk.launch.utils import _is_git_uri
|
1392
|
+
|
1393
|
+
api = _get_cling_api()
|
1394
|
+
wandb._sentry.configure_scope(process_context="launch_cli")
|
1395
|
+
|
1396
|
+
if run_async and queue is not None:
|
1397
|
+
raise LaunchError(
|
1398
|
+
"Cannot use both --async and --queue with wandb launch, see help for details."
|
1399
|
+
)
|
1400
|
+
|
1401
|
+
if queue and docker_image and not project:
|
1402
|
+
raise LaunchError(
|
1403
|
+
"Cannot use --queue and --docker together without a project. Please specify a project with --project or -p."
|
1404
|
+
)
|
1405
|
+
|
1406
|
+
if priority is not None and queue is None:
|
1407
|
+
raise LaunchError("--priority flag requires --queue to be set")
|
1408
|
+
|
1409
|
+
if resource_args is not None:
|
1410
|
+
resource_args = util.load_json_yaml_dict(resource_args)
|
1411
|
+
if resource_args is None:
|
1412
|
+
raise LaunchError("Invalid format for resource-args")
|
1413
|
+
else:
|
1414
|
+
resource_args = {}
|
1415
|
+
|
1416
|
+
if entry_point is not None:
|
1417
|
+
entry_point = shlex.split(entry_point)
|
1418
|
+
|
1419
|
+
if config is not None:
|
1420
|
+
config = util.load_json_yaml_dict(config)
|
1421
|
+
if config is None:
|
1422
|
+
raise LaunchError("Invalid format for config")
|
1423
|
+
else:
|
1424
|
+
config = {}
|
1425
|
+
|
1426
|
+
resource = resource or config.get("resource")
|
1427
|
+
|
1428
|
+
if build and queue is None:
|
1429
|
+
raise LaunchError("Build flag requires a queue to be set")
|
1430
|
+
|
1431
|
+
try:
|
1432
|
+
launch_utils.check_logged_in(api)
|
1433
|
+
except Exception:
|
1434
|
+
wandb.termerror(f"Error running job: {traceback.format_exc()}")
|
1435
|
+
|
1436
|
+
run_id = config.get("run_id")
|
1437
|
+
|
1438
|
+
# If URI was provided, we need to create a job from it.
|
1439
|
+
if uri:
|
1440
|
+
if entry_point is None:
|
1441
|
+
raise LaunchError(
|
1442
|
+
"Cannot provide a uri without an entry point. Please provide an "
|
1443
|
+
"entry point with --entry-point or -E."
|
1444
|
+
)
|
1445
|
+
if job is not None:
|
1446
|
+
raise LaunchError("Cannot provide both a uri and a job name.")
|
1447
|
+
job_type = (
|
1448
|
+
"git" if _is_git_uri(uri) else "code"
|
1449
|
+
) # TODO: Add support for local URIs with git.
|
1450
|
+
if entity is None:
|
1451
|
+
entity = launch_utils.get_default_entity(api, config)
|
1452
|
+
artifact, _, _ = _create_job(
|
1453
|
+
api,
|
1454
|
+
job_type,
|
1455
|
+
uri,
|
1456
|
+
entrypoint=" ".join(entry_point),
|
1457
|
+
git_hash=git_version,
|
1458
|
+
name=job_name,
|
1459
|
+
project=project,
|
1460
|
+
base_image=base_image,
|
1461
|
+
build_context=build_context,
|
1462
|
+
dockerfile=dockerfile,
|
1463
|
+
entity=entity,
|
1464
|
+
)
|
1465
|
+
if artifact is None:
|
1466
|
+
raise LaunchError(f"Failed to create job from uri: {uri}")
|
1467
|
+
job = f"{entity}/{project}/{artifact.name}"
|
1468
|
+
|
1469
|
+
if dockerfile:
|
1470
|
+
if "overrides" in config:
|
1471
|
+
config["overrides"]["dockerfile"] = dockerfile
|
1472
|
+
else:
|
1473
|
+
config["overrides"] = {"dockerfile": dockerfile}
|
1474
|
+
|
1475
|
+
if priority is not None:
|
1476
|
+
priority_map = {
|
1477
|
+
"critical": 0,
|
1478
|
+
"high": 1,
|
1479
|
+
"medium": 2,
|
1480
|
+
"low": 3,
|
1481
|
+
}
|
1482
|
+
priority = priority_map[priority.lower()]
|
1483
|
+
|
1484
|
+
template_variables = None
|
1485
|
+
if cli_template_vars:
|
1486
|
+
if queue is None:
|
1487
|
+
raise LaunchError("'--set-var' flag requires queue to be set")
|
1488
|
+
if entity is None:
|
1489
|
+
entity = launch_utils.get_default_entity(api, config)
|
1490
|
+
public_api = PublicApi()
|
1491
|
+
runqueue = RunQueue(client=public_api.client, name=queue, entity=entity)
|
1492
|
+
template_variables = launch_utils.fetch_and_validate_template_variables(
|
1493
|
+
runqueue, cli_template_vars
|
1494
|
+
)
|
1495
|
+
|
1496
|
+
if queue is None:
|
1497
|
+
# direct launch
|
1498
|
+
try:
|
1499
|
+
run = asyncio.run(
|
1500
|
+
_launch(
|
1501
|
+
api,
|
1502
|
+
job,
|
1503
|
+
project=project,
|
1504
|
+
entity=entity,
|
1505
|
+
docker_image=docker_image,
|
1506
|
+
name=name,
|
1507
|
+
entry_point=entry_point,
|
1508
|
+
version=git_version,
|
1509
|
+
resource=resource,
|
1510
|
+
resource_args=resource_args,
|
1511
|
+
launch_config=config,
|
1512
|
+
synchronous=(not run_async),
|
1513
|
+
run_id=run_id,
|
1514
|
+
repository=repository,
|
1515
|
+
)
|
1516
|
+
)
|
1517
|
+
if asyncio.run(run.get_status()).state in [
|
1518
|
+
"failed",
|
1519
|
+
"stopped",
|
1520
|
+
"preempted",
|
1521
|
+
]:
|
1522
|
+
wandb.termerror("Launched run exited with non-zero status")
|
1523
|
+
sys.exit(1)
|
1524
|
+
except LaunchError as e:
|
1525
|
+
logger.error("=== %s ===", e)
|
1526
|
+
wandb._sentry.exception(e)
|
1527
|
+
sys.exit(e)
|
1528
|
+
except ExecutionError as e:
|
1529
|
+
logger.error("=== %s ===", e)
|
1530
|
+
wandb._sentry.exception(e)
|
1531
|
+
sys.exit(e)
|
1532
|
+
except asyncio.CancelledError:
|
1533
|
+
sys.exit(0)
|
1534
|
+
else:
|
1535
|
+
try:
|
1536
|
+
_launch_add(
|
1537
|
+
api,
|
1538
|
+
job,
|
1539
|
+
config,
|
1540
|
+
template_variables,
|
1541
|
+
project,
|
1542
|
+
entity,
|
1543
|
+
queue,
|
1544
|
+
resource,
|
1545
|
+
entry_point,
|
1546
|
+
name,
|
1547
|
+
git_version,
|
1548
|
+
docker_image,
|
1549
|
+
project_queue,
|
1550
|
+
resource_args,
|
1551
|
+
build=build,
|
1552
|
+
run_id=run_id,
|
1553
|
+
repository=repository,
|
1554
|
+
priority=priority,
|
1555
|
+
)
|
1556
|
+
|
1557
|
+
except Exception as e:
|
1558
|
+
wandb._sentry.exception(e)
|
1559
|
+
raise e
|
1560
|
+
|
1561
|
+
|
1562
|
+
@cli.command(
|
1563
|
+
context_settings=CONTEXT,
|
1564
|
+
help="Run a W&B launch agent.",
|
1565
|
+
)
|
1566
|
+
@click.pass_context
|
1567
|
+
@click.option(
|
1568
|
+
"--queue",
|
1569
|
+
"-q",
|
1570
|
+
"queues",
|
1571
|
+
default=None,
|
1572
|
+
multiple=True,
|
1573
|
+
help="The name of a queue for the agent to watch. Multiple -q flags supported.",
|
1574
|
+
)
|
1575
|
+
@click.option(
|
1576
|
+
"--entity",
|
1577
|
+
"-e",
|
1578
|
+
default=None,
|
1579
|
+
help="The entity to use. Defaults to current logged-in user",
|
1580
|
+
)
|
1581
|
+
@click.option(
|
1582
|
+
"--log-file",
|
1583
|
+
"-l",
|
1584
|
+
default=None,
|
1585
|
+
help=(
|
1586
|
+
"Destination for internal agent logs. Use - for stdout. "
|
1587
|
+
"By default all agents logs will go to debug.log in your wandb/ "
|
1588
|
+
"subdirectory or WANDB_DIR if set."
|
1589
|
+
),
|
1590
|
+
)
|
1591
|
+
@click.option(
|
1592
|
+
"--max-jobs",
|
1593
|
+
"-j",
|
1594
|
+
default=None,
|
1595
|
+
help="The maximum number of launch jobs this agent can run in parallel. Defaults to 1. Set to -1 for no upper limit",
|
1596
|
+
)
|
1597
|
+
@click.option(
|
1598
|
+
"--config", "-c", default=None, help="path to the agent config yaml to use"
|
1599
|
+
)
|
1600
|
+
@click.option(
|
1601
|
+
"--url",
|
1602
|
+
"-u",
|
1603
|
+
default=None,
|
1604
|
+
hidden=True,
|
1605
|
+
help="a wandb client registration URL, this is generated in the UI",
|
1606
|
+
)
|
1607
|
+
@click.option("--verbose", "-v", count=True, help="Display verbose output")
|
1608
|
+
@display_error
|
1609
|
+
def launch_agent(
|
1610
|
+
ctx,
|
1611
|
+
entity=None,
|
1612
|
+
queues=None,
|
1613
|
+
max_jobs=None,
|
1614
|
+
config=None,
|
1615
|
+
url=None,
|
1616
|
+
log_file=None,
|
1617
|
+
verbose=0,
|
1618
|
+
):
|
1619
|
+
logger.info(
|
1620
|
+
f"=== Launch-agent called with kwargs {locals()} CLI Version: {wandb.__version__} ==="
|
1621
|
+
)
|
1622
|
+
if url is not None:
|
1623
|
+
raise LaunchError(
|
1624
|
+
"--url is not supported in this version, upgrade with: pip install -u wandb"
|
1625
|
+
)
|
1626
|
+
|
1627
|
+
import wandb.sdk.launch._launch as _launch
|
1628
|
+
|
1629
|
+
if log_file is not None:
|
1630
|
+
_launch.set_launch_logfile(log_file)
|
1631
|
+
|
1632
|
+
api = _get_cling_api()
|
1633
|
+
wandb._sentry.configure_scope(process_context="launch_agent")
|
1634
|
+
agent_config, api = _launch.resolve_agent_config(
|
1635
|
+
entity, max_jobs, queues, config, verbose
|
1636
|
+
)
|
1637
|
+
|
1638
|
+
if len(agent_config.get("queues")) == 0:
|
1639
|
+
raise LaunchError(
|
1640
|
+
"To launch an agent please specify a queue or a list of queues in the configuration file or cli."
|
1641
|
+
)
|
1642
|
+
|
1643
|
+
launch_utils.check_logged_in(api)
|
1644
|
+
|
1645
|
+
wandb.termlog("Starting launch agent ✨")
|
1646
|
+
try:
|
1647
|
+
_launch.create_and_run_agent(api, agent_config)
|
1648
|
+
except Exception as e:
|
1649
|
+
wandb._sentry.exception(e)
|
1650
|
+
raise e
|
1651
|
+
|
1652
|
+
|
1653
|
+
@cli.command(context_settings=CONTEXT, help="Run the W&B agent")
|
1654
|
+
@click.pass_context
|
1655
|
+
@click.option(
|
1656
|
+
"--project",
|
1657
|
+
"-p",
|
1658
|
+
default=None,
|
1659
|
+
help="""The name of the project where W&B runs created from the sweep are sent to. If the project is not specified, the run is sent to a project labeled 'Uncategorized'.""",
|
1660
|
+
)
|
1661
|
+
@click.option(
|
1662
|
+
"--entity",
|
1663
|
+
"-e",
|
1664
|
+
default=None,
|
1665
|
+
help="""The username or team name where you want to send W&B runs created by the sweep to. Ensure that the entity you specify already exists. If you don't specify an entity, the run will be sent to your default entity, which is usually your username.""",
|
1666
|
+
)
|
1667
|
+
@click.option(
|
1668
|
+
"--count", default=None, type=int, help="The max number of runs for this agent."
|
1669
|
+
)
|
1670
|
+
@click.argument("sweep_id")
|
1671
|
+
@display_error
|
1672
|
+
def agent(ctx, project, entity, count, sweep_id):
|
1673
|
+
api = _get_cling_api()
|
1674
|
+
if not api.is_authenticated:
|
1675
|
+
wandb.termlog("Login to W&B to use the sweep agent feature")
|
1676
|
+
ctx.invoke(login, no_offline=True)
|
1677
|
+
api = _get_cling_api(reset=True)
|
1678
|
+
|
1679
|
+
wandb.termlog("Starting wandb agent 🕵️")
|
1680
|
+
wandb_agent.agent(sweep_id, entity=entity, project=project, count=count)
|
1681
|
+
|
1682
|
+
# you can send local commands like so:
|
1683
|
+
# agent_api.command({'type': 'run', 'program': 'train.py',
|
1684
|
+
# 'args': ['--max_epochs=10']})
|
1685
|
+
|
1686
|
+
|
1687
|
+
@cli.command(
|
1688
|
+
context_settings=RUN_CONTEXT, help="Run a W&B launch sweep scheduler (Experimental)"
|
1689
|
+
)
|
1690
|
+
@click.pass_context
|
1691
|
+
@click.argument("sweep_id")
|
1692
|
+
@display_error
|
1693
|
+
def scheduler(
|
1694
|
+
ctx,
|
1695
|
+
sweep_id,
|
1696
|
+
):
|
1697
|
+
api = InternalApi()
|
1698
|
+
if not api.is_authenticated:
|
1699
|
+
wandb.termlog("Login to W&B to use the sweep scheduler feature")
|
1700
|
+
ctx.invoke(login, no_offline=True)
|
1701
|
+
api = InternalApi(reset=True)
|
1702
|
+
|
1703
|
+
wandb._sentry.configure_scope(process_context="sweep_scheduler")
|
1704
|
+
wandb.termlog("Starting a Launch Scheduler 🚀")
|
1705
|
+
from wandb.sdk.launch.sweeps import load_scheduler
|
1706
|
+
|
1707
|
+
# TODO(gst): remove this monstrosity
|
1708
|
+
# Future-proofing hack to pull any kwargs that get passed in through the CLI
|
1709
|
+
kwargs = {}
|
1710
|
+
for i, _arg in enumerate(ctx.args):
|
1711
|
+
if isinstance(_arg, str) and _arg.startswith("--"):
|
1712
|
+
# convert input kwargs from hyphens to underscores
|
1713
|
+
_key = _arg[2:].replace("-", "_")
|
1714
|
+
_args = ctx.args[i + 1]
|
1715
|
+
if str.isdigit(_args):
|
1716
|
+
_args = int(_args)
|
1717
|
+
kwargs[_key] = _args
|
1718
|
+
try:
|
1719
|
+
sweep_type = kwargs.get("sweep_type", "wandb")
|
1720
|
+
_scheduler = load_scheduler(scheduler_type=sweep_type)(
|
1721
|
+
api,
|
1722
|
+
sweep_id=sweep_id,
|
1723
|
+
**kwargs,
|
1724
|
+
)
|
1725
|
+
_scheduler.start()
|
1726
|
+
except Exception as e:
|
1727
|
+
wandb._sentry.exception(e)
|
1728
|
+
raise e
|
1729
|
+
|
1730
|
+
|
1731
|
+
@cli.group(help="Commands for managing and viewing W&B jobs")
|
1732
|
+
def job() -> None:
|
1733
|
+
pass
|
1734
|
+
|
1735
|
+
|
1736
|
+
@job.command("list", help="List jobs in a project")
|
1737
|
+
@click.option(
|
1738
|
+
"--project",
|
1739
|
+
"-p",
|
1740
|
+
envvar=env.PROJECT,
|
1741
|
+
help="The project you want to list jobs from.",
|
1742
|
+
)
|
1743
|
+
@click.option(
|
1744
|
+
"--entity",
|
1745
|
+
"-e",
|
1746
|
+
default="models",
|
1747
|
+
envvar=env.ENTITY,
|
1748
|
+
help="The entity the jobs belong to",
|
1749
|
+
)
|
1750
|
+
def _list(project, entity):
|
1751
|
+
wandb.termlog(f"Listing jobs in {entity}/{project}")
|
1752
|
+
public_api = PublicApi()
|
1753
|
+
try:
|
1754
|
+
jobs = public_api.list_jobs(entity=entity, project=project)
|
1755
|
+
except wandb.errors.CommError as e:
|
1756
|
+
wandb.termerror(f"{e}")
|
1757
|
+
return
|
1758
|
+
|
1759
|
+
if len(jobs) == 0:
|
1760
|
+
wandb.termlog("No jobs found")
|
1761
|
+
return
|
1762
|
+
|
1763
|
+
for job in jobs:
|
1764
|
+
aliases = []
|
1765
|
+
if len(job["edges"]) == 0:
|
1766
|
+
# deleted?
|
1767
|
+
continue
|
1768
|
+
|
1769
|
+
name = job["edges"][0]["node"]["artifactSequence"]["name"]
|
1770
|
+
for version in job["edges"]:
|
1771
|
+
aliases += [x["alias"] for x in version["node"]["aliases"]]
|
1772
|
+
|
1773
|
+
# only list the most recent 10 job versions
|
1774
|
+
aliases_str = ",".join(aliases[::-1])
|
1775
|
+
wandb.termlog(f"{name} -- versions ({len(aliases)}): {aliases_str}")
|
1776
|
+
|
1777
|
+
|
1778
|
+
@job.command(
|
1779
|
+
help="Describe a launch job. Provide the launch job in the form of: entity/project/job-name:alias-or-version"
|
1780
|
+
)
|
1781
|
+
@click.argument("job")
|
1782
|
+
def describe(job):
|
1783
|
+
public_api = PublicApi()
|
1784
|
+
try:
|
1785
|
+
job = public_api.job(name=job)
|
1786
|
+
except wandb.errors.CommError as e:
|
1787
|
+
wandb.termerror(f"{e}")
|
1788
|
+
return
|
1789
|
+
|
1790
|
+
for key in job._job_info:
|
1791
|
+
if key.startswith("_"):
|
1792
|
+
continue
|
1793
|
+
wandb.termlog(f"{key}: {job._job_info[key]}")
|
1794
|
+
|
1795
|
+
|
1796
|
+
@job.command(
|
1797
|
+
no_args_is_help=True,
|
1798
|
+
)
|
1799
|
+
@click.option(
|
1800
|
+
"--project",
|
1801
|
+
"-p",
|
1802
|
+
envvar=env.PROJECT,
|
1803
|
+
help="The project you want to list jobs from.",
|
1804
|
+
)
|
1805
|
+
@click.option(
|
1806
|
+
"--entity",
|
1807
|
+
"-e",
|
1808
|
+
envvar=env.ENTITY,
|
1809
|
+
help="The entity the jobs belong to",
|
1810
|
+
)
|
1811
|
+
@click.option(
|
1812
|
+
"--name",
|
1813
|
+
"-n",
|
1814
|
+
help="Name for the job",
|
1815
|
+
)
|
1816
|
+
@click.option(
|
1817
|
+
"--description",
|
1818
|
+
"-d",
|
1819
|
+
help="Description for the job",
|
1820
|
+
)
|
1821
|
+
@click.option(
|
1822
|
+
"--alias",
|
1823
|
+
"-a",
|
1824
|
+
"aliases",
|
1825
|
+
help="Alias for the job",
|
1826
|
+
multiple=True,
|
1827
|
+
default=tuple(),
|
1828
|
+
)
|
1829
|
+
@click.option(
|
1830
|
+
"--entry-point",
|
1831
|
+
"-E",
|
1832
|
+
"entrypoint",
|
1833
|
+
help="Entrypoint to the script, including an executable and an entrypoint "
|
1834
|
+
"file. Required for code or repo jobs. If --build-context is provided, "
|
1835
|
+
"paths in the entrypoint command will be relative to the build context.",
|
1836
|
+
)
|
1837
|
+
@click.option(
|
1838
|
+
"--git-hash",
|
1839
|
+
"-g",
|
1840
|
+
"git_hash",
|
1841
|
+
type=str,
|
1842
|
+
help="Commit reference to use as the source for git jobs",
|
1843
|
+
)
|
1844
|
+
@click.option(
|
1845
|
+
"--runtime",
|
1846
|
+
"-r",
|
1847
|
+
type=str,
|
1848
|
+
help="Python runtime to execute the job",
|
1849
|
+
)
|
1850
|
+
@click.option(
|
1851
|
+
"--build-context",
|
1852
|
+
"-b",
|
1853
|
+
type=str,
|
1854
|
+
help="Path to the build context from the root of the job source code. If "
|
1855
|
+
"provided, this is used as the base path for the Dockerfile and entrypoint.",
|
1856
|
+
)
|
1857
|
+
@click.option(
|
1858
|
+
"--base-image",
|
1859
|
+
"-B",
|
1860
|
+
type=str,
|
1861
|
+
help="Base image to use for the job. Incompatible with image jobs.",
|
1862
|
+
)
|
1863
|
+
@click.option(
|
1864
|
+
"--dockerfile",
|
1865
|
+
"-D",
|
1866
|
+
type=str,
|
1867
|
+
help="Path to the Dockerfile for the job. If --build-context is provided, "
|
1868
|
+
"the Dockerfile path will be relative to the build context.",
|
1869
|
+
)
|
1870
|
+
@click.argument(
|
1871
|
+
"job_type",
|
1872
|
+
type=click.Choice(("git", "code", "image")),
|
1873
|
+
)
|
1874
|
+
@click.argument("path")
|
1875
|
+
def create(
|
1876
|
+
path,
|
1877
|
+
project,
|
1878
|
+
entity,
|
1879
|
+
name,
|
1880
|
+
job_type,
|
1881
|
+
description,
|
1882
|
+
aliases,
|
1883
|
+
entrypoint,
|
1884
|
+
git_hash,
|
1885
|
+
runtime,
|
1886
|
+
build_context,
|
1887
|
+
base_image,
|
1888
|
+
dockerfile,
|
1889
|
+
):
|
1890
|
+
"""Create a job from a source, without a wandb run.
|
1891
|
+
|
1892
|
+
Jobs can be of three types, git, code, or image.
|
1893
|
+
|
1894
|
+
git: A git source, with an entrypoint either in the path or provided explicitly pointing to the main python executable.
|
1895
|
+
code: A code path, containing a requirements.txt file.
|
1896
|
+
image: A docker image.
|
1897
|
+
"""
|
1898
|
+
from wandb.sdk.launch.create_job import _create_job
|
1899
|
+
|
1900
|
+
api = _get_cling_api()
|
1901
|
+
wandb._sentry.configure_scope(process_context="job_create")
|
1902
|
+
|
1903
|
+
entity = entity or os.getenv("WANDB_ENTITY") or api.default_entity
|
1904
|
+
if not entity:
|
1905
|
+
wandb.termerror("No entity provided, use --entity or set WANDB_ENTITY")
|
1906
|
+
return
|
1907
|
+
|
1908
|
+
project = project or os.getenv("WANDB_PROJECT")
|
1909
|
+
if not project:
|
1910
|
+
wandb.termerror("No project provided, use --project or set WANDB_PROJECT")
|
1911
|
+
return
|
1912
|
+
|
1913
|
+
if entrypoint is None and job_type in ["git", "code"]:
|
1914
|
+
wandb.termwarn(
|
1915
|
+
f"No entrypoint provided for {job_type} job, defaulting to main.py"
|
1916
|
+
)
|
1917
|
+
entrypoint = "main.py"
|
1918
|
+
|
1919
|
+
if job_type == "image" and base_image:
|
1920
|
+
wandb.termerror("Cannot provide --base-image/-B for an `image` job")
|
1921
|
+
return
|
1922
|
+
|
1923
|
+
artifact, action, aliases = _create_job(
|
1924
|
+
api=api,
|
1925
|
+
path=path,
|
1926
|
+
entity=entity,
|
1927
|
+
project=project,
|
1928
|
+
name=name,
|
1929
|
+
job_type=job_type,
|
1930
|
+
description=description,
|
1931
|
+
aliases=list(aliases),
|
1932
|
+
entrypoint=entrypoint,
|
1933
|
+
git_hash=git_hash,
|
1934
|
+
runtime=runtime,
|
1935
|
+
build_context=build_context,
|
1936
|
+
base_image=base_image,
|
1937
|
+
dockerfile=dockerfile,
|
1938
|
+
)
|
1939
|
+
if not artifact:
|
1940
|
+
wandb.termerror("Job creation failed")
|
1941
|
+
return
|
1942
|
+
|
1943
|
+
artifact_path = f"{entity}/{project}/{artifact.name}"
|
1944
|
+
msg = f"{action} job: {click.style(artifact_path, fg='yellow')}"
|
1945
|
+
if len(aliases) == 1:
|
1946
|
+
alias_str = click.style(aliases[0], fg="yellow")
|
1947
|
+
msg += f", with alias: {alias_str}"
|
1948
|
+
elif len(aliases) > 1:
|
1949
|
+
alias_str = click.style(", ".join(aliases), fg="yellow")
|
1950
|
+
msg += f", with aliases: {alias_str}"
|
1951
|
+
|
1952
|
+
wandb.termlog(msg)
|
1953
|
+
web_url = util.app_url(api.settings().get("base_url"))
|
1954
|
+
url = click.style(f"{web_url}/{entity}/{project}/jobs", underline=True)
|
1955
|
+
wandb.termlog(f"View all jobs in project '{project}' here: {url}\n")
|
1956
|
+
|
1957
|
+
|
1958
|
+
@cli.command(context_settings=CONTEXT, help="Run the W&B local sweep controller")
|
1959
|
+
@click.option("--verbose", is_flag=True, default=False, help="Display verbose output")
|
1960
|
+
@click.argument("sweep_id")
|
1961
|
+
@display_error
|
1962
|
+
def controller(verbose, sweep_id):
|
1963
|
+
click.echo("Starting wandb controller...")
|
1964
|
+
from wandb import controller as wandb_controller
|
1965
|
+
|
1966
|
+
tuner = wandb_controller(sweep_id)
|
1967
|
+
tuner.run(verbose=verbose)
|
1968
|
+
|
1969
|
+
|
1970
|
+
@cli.command(context_settings=RUN_CONTEXT, name="docker-run")
|
1971
|
+
@click.pass_context
|
1972
|
+
@click.argument("docker_run_args", nargs=-1)
|
1973
|
+
def docker_run(ctx, docker_run_args):
|
1974
|
+
"""Wrap `docker run` and adds WANDB_API_KEY and WANDB_DOCKER environment variables.
|
1975
|
+
|
1976
|
+
This will also set the runtime to nvidia if the nvidia-docker executable is present
|
1977
|
+
on the system and --runtime wasn't set.
|
1978
|
+
|
1979
|
+
See `docker run --help` for more details.
|
1980
|
+
"""
|
1981
|
+
api = InternalApi()
|
1982
|
+
args = list(docker_run_args)
|
1983
|
+
if len(args) > 0 and args[0] == "run":
|
1984
|
+
args.pop(0)
|
1985
|
+
if len([a for a in args if a.startswith("--runtime")]) == 0 and find_executable(
|
1986
|
+
"nvidia-docker"
|
1987
|
+
):
|
1988
|
+
args = ["--runtime", "nvidia"] + args
|
1989
|
+
# TODO: image_from_docker_args uses heuristics to find the docker image arg, there are likely cases
|
1990
|
+
# where this won't work
|
1991
|
+
image = util.image_from_docker_args(args)
|
1992
|
+
resolved_image = None
|
1993
|
+
if image:
|
1994
|
+
resolved_image = wandb.docker.image_id(image)
|
1995
|
+
if resolved_image:
|
1996
|
+
args = ["-e", "WANDB_DOCKER={}".format(resolved_image)] + args
|
1997
|
+
else:
|
1998
|
+
wandb.termlog(
|
1999
|
+
"Couldn't detect image argument, running command without the WANDB_DOCKER env variable"
|
2000
|
+
)
|
2001
|
+
if api.api_key:
|
2002
|
+
args = ["-e", "WANDB_API_KEY={}".format(api.api_key)] + args
|
2003
|
+
else:
|
2004
|
+
wandb.termlog(
|
2005
|
+
"Not logged in, run `wandb login` from the host machine to enable result logging"
|
2006
|
+
)
|
2007
|
+
subprocess.call(["docker", "run"] + args)
|
2008
|
+
|
2009
|
+
|
2010
|
+
@cli.command(context_settings=RUN_CONTEXT)
|
2011
|
+
@click.pass_context
|
2012
|
+
@click.argument("docker_run_args", nargs=-1)
|
2013
|
+
@click.argument("docker_image", required=False)
|
2014
|
+
@click.option(
|
2015
|
+
"--nvidia/--no-nvidia",
|
2016
|
+
default=find_executable("nvidia-docker") is not None,
|
2017
|
+
help="Use the nvidia runtime, defaults to nvidia if nvidia-docker is present",
|
2018
|
+
)
|
2019
|
+
@click.option(
|
2020
|
+
"--digest", is_flag=True, default=False, help="Output the image digest and exit"
|
2021
|
+
)
|
2022
|
+
@click.option(
|
2023
|
+
"--jupyter/--no-jupyter", default=False, help="Run jupyter lab in the container"
|
2024
|
+
)
|
2025
|
+
@click.option(
|
2026
|
+
"--dir", default="/app", help="Which directory to mount the code in the container"
|
2027
|
+
)
|
2028
|
+
@click.option("--no-dir", is_flag=True, help="Don't mount the current directory")
|
2029
|
+
@click.option(
|
2030
|
+
"--shell", default="/bin/bash", help="The shell to start the container with"
|
2031
|
+
)
|
2032
|
+
@click.option("--port", default="8888", help="The host port to bind jupyter on")
|
2033
|
+
@click.option("--cmd", help="The command to run in the container")
|
2034
|
+
@click.option(
|
2035
|
+
"--no-tty", is_flag=True, default=False, help="Run the command without a tty"
|
2036
|
+
)
|
2037
|
+
@display_error
|
2038
|
+
def docker(
|
2039
|
+
ctx,
|
2040
|
+
docker_run_args,
|
2041
|
+
docker_image,
|
2042
|
+
nvidia,
|
2043
|
+
digest,
|
2044
|
+
jupyter,
|
2045
|
+
dir,
|
2046
|
+
no_dir,
|
2047
|
+
shell,
|
2048
|
+
port,
|
2049
|
+
cmd,
|
2050
|
+
no_tty,
|
2051
|
+
):
|
2052
|
+
"""Run your code in a docker container.
|
2053
|
+
|
2054
|
+
W&B docker lets you run your code in a docker image ensuring wandb is configured. It
|
2055
|
+
adds the WANDB_DOCKER and WANDB_API_KEY environment variables to your container and
|
2056
|
+
mounts the current directory in /app by default. You can pass additional args which
|
2057
|
+
will be added to `docker run` before the image name is declared, we'll choose a
|
2058
|
+
default image for you if one isn't passed:
|
2059
|
+
|
2060
|
+
```sh
|
2061
|
+
wandb docker -v /mnt/dataset:/app/data
|
2062
|
+
wandb docker gcr.io/kubeflow-images-public/tensorflow-1.12.0-notebook-cpu:v0.4.0 --jupyter
|
2063
|
+
wandb docker wandb/deepo:keras-gpu --no-tty --cmd "python train.py --epochs=5"
|
2064
|
+
```
|
2065
|
+
|
2066
|
+
By default, we override the entrypoint to check for the existence of wandb and
|
2067
|
+
install it if not present. If you pass the --jupyter flag we will ensure jupyter is
|
2068
|
+
installed and start jupyter lab on port 8888. If we detect nvidia-docker on your
|
2069
|
+
system we will use the nvidia runtime. If you just want wandb to set environment
|
2070
|
+
variable to an existing docker run command, see the wandb docker-run command.
|
2071
|
+
"""
|
2072
|
+
api = InternalApi()
|
2073
|
+
if not find_executable("docker"):
|
2074
|
+
raise ClickException("Docker not installed, install it from https://docker.com")
|
2075
|
+
args = list(docker_run_args)
|
2076
|
+
image = docker_image or ""
|
2077
|
+
# remove run for users used to nvidia-docker
|
2078
|
+
if len(args) > 0 and args[0] == "run":
|
2079
|
+
args.pop(0)
|
2080
|
+
if image == "" and len(args) > 0:
|
2081
|
+
image = args.pop(0)
|
2082
|
+
# If the user adds docker args without specifying an image (should be rare)
|
2083
|
+
if not util.docker_image_regex(image.split("@")[0]):
|
2084
|
+
if image:
|
2085
|
+
args = args + [image]
|
2086
|
+
image = wandb.docker.default_image(gpu=nvidia)
|
2087
|
+
subprocess.call(["docker", "pull", image])
|
2088
|
+
_, repo_name, tag = wandb.docker.parse(image)
|
2089
|
+
|
2090
|
+
resolved_image = wandb.docker.image_id(image)
|
2091
|
+
if resolved_image is None:
|
2092
|
+
raise ClickException(
|
2093
|
+
"Couldn't find image locally or in a registry, try running `docker pull {}`".format(
|
2094
|
+
image
|
2095
|
+
)
|
2096
|
+
)
|
2097
|
+
if digest:
|
2098
|
+
sys.stdout.write(resolved_image)
|
2099
|
+
exit(0)
|
2100
|
+
|
2101
|
+
existing = wandb.docker.shell(
|
2102
|
+
["ps", "-f", "ancestor={}".format(resolved_image), "-q"]
|
2103
|
+
)
|
2104
|
+
if existing:
|
2105
|
+
if click.confirm(
|
2106
|
+
"Found running container with the same image, do you want to attach?"
|
2107
|
+
):
|
2108
|
+
subprocess.call(["docker", "attach", existing.split("\n")[0]])
|
2109
|
+
exit(0)
|
2110
|
+
cwd = os.getcwd()
|
2111
|
+
command = [
|
2112
|
+
"docker",
|
2113
|
+
"run",
|
2114
|
+
"-e",
|
2115
|
+
"LANG=C.UTF-8",
|
2116
|
+
"-e",
|
2117
|
+
"WANDB_DOCKER={}".format(resolved_image),
|
2118
|
+
"--ipc=host",
|
2119
|
+
"-v",
|
2120
|
+
wandb.docker.entrypoint + ":/wandb-entrypoint.sh",
|
2121
|
+
"--entrypoint",
|
2122
|
+
"/wandb-entrypoint.sh",
|
2123
|
+
]
|
2124
|
+
if nvidia:
|
2125
|
+
command.extend(["--runtime", "nvidia"])
|
2126
|
+
if not no_dir:
|
2127
|
+
# TODO: We should default to the working directory if defined
|
2128
|
+
command.extend(["-v", cwd + ":" + dir, "-w", dir])
|
2129
|
+
if api.api_key:
|
2130
|
+
command.extend(["-e", "WANDB_API_KEY={}".format(api.api_key)])
|
2131
|
+
else:
|
2132
|
+
wandb.termlog(
|
2133
|
+
"Couldn't find WANDB_API_KEY, run `wandb login` to enable streaming metrics"
|
2134
|
+
)
|
2135
|
+
if jupyter:
|
2136
|
+
command.extend(["-e", "WANDB_ENSURE_JUPYTER=1", "-p", port + ":8888"])
|
2137
|
+
no_tty = True
|
2138
|
+
cmd = "jupyter lab --no-browser --ip=0.0.0.0 --allow-root --NotebookApp.token= --notebook-dir {}".format(
|
2139
|
+
dir
|
2140
|
+
)
|
2141
|
+
command.extend(args)
|
2142
|
+
if no_tty:
|
2143
|
+
command.extend([image, shell, "-c", cmd])
|
2144
|
+
else:
|
2145
|
+
if cmd:
|
2146
|
+
command.extend(["-e", "WANDB_COMMAND={}".format(cmd)])
|
2147
|
+
command.extend(["-it", image, shell])
|
2148
|
+
wandb.termlog("Launching docker container \U0001f6a2")
|
2149
|
+
subprocess.call(command)
|
2150
|
+
|
2151
|
+
|
2152
|
+
@cli.command(
|
2153
|
+
context_settings=RUN_CONTEXT,
|
2154
|
+
help="Start a local W&B container (deprecated, see wandb server --help)",
|
2155
|
+
hidden=True,
|
2156
|
+
)
|
2157
|
+
@click.pass_context
|
2158
|
+
@click.option("--port", "-p", default="8080", help="The host port to bind W&B local on")
|
2159
|
+
@click.option(
|
2160
|
+
"--env", "-e", default=[], multiple=True, help="Env vars to pass to wandb/local"
|
2161
|
+
)
|
2162
|
+
@click.option(
|
2163
|
+
"--daemon/--no-daemon", default=True, help="Run or don't run in daemon mode"
|
2164
|
+
)
|
2165
|
+
@click.option(
|
2166
|
+
"--upgrade", is_flag=True, default=False, help="Upgrade to the most recent version"
|
2167
|
+
)
|
2168
|
+
@click.option(
|
2169
|
+
"--edge", is_flag=True, default=False, help="Run the bleeding edge", hidden=True
|
2170
|
+
)
|
2171
|
+
@display_error
|
2172
|
+
def local(ctx, *args, **kwargs):
|
2173
|
+
wandb.termwarn("`wandb local` has been replaced with `wandb server start`.")
|
2174
|
+
ctx.invoke(start, *args, **kwargs)
|
2175
|
+
|
2176
|
+
|
2177
|
+
@cli.group(help="Commands for operating a local W&B server")
|
2178
|
+
def server():
|
2179
|
+
pass
|
2180
|
+
|
2181
|
+
|
2182
|
+
@server.command(context_settings=RUN_CONTEXT, help="Start a local W&B server")
|
2183
|
+
@click.pass_context
|
2184
|
+
@click.option(
|
2185
|
+
"--port", "-p", default="8080", help="The host port to bind W&B server on"
|
2186
|
+
)
|
2187
|
+
@click.option(
|
2188
|
+
"--env", "-e", default=[], multiple=True, help="Env vars to pass to wandb/local"
|
2189
|
+
)
|
2190
|
+
@click.option(
|
2191
|
+
"--daemon/--no-daemon", default=True, help="Run or don't run in daemon mode"
|
2192
|
+
)
|
2193
|
+
@click.option(
|
2194
|
+
"--upgrade",
|
2195
|
+
is_flag=True,
|
2196
|
+
default=False,
|
2197
|
+
help="Upgrade to the most recent version",
|
2198
|
+
hidden=True,
|
2199
|
+
)
|
2200
|
+
@click.option(
|
2201
|
+
"--edge", is_flag=True, default=False, help="Run the bleeding edge", hidden=True
|
2202
|
+
)
|
2203
|
+
@display_error
|
2204
|
+
def start(ctx, port, env, daemon, upgrade, edge):
|
2205
|
+
api = InternalApi()
|
2206
|
+
if not find_executable("docker"):
|
2207
|
+
raise ClickException("Docker not installed, install it from https://docker.com")
|
2208
|
+
local_image_sha = wandb.docker.image_id("wandb/local").split("wandb/local")[-1]
|
2209
|
+
registry_image_sha = wandb.docker.image_id_from_registry("wandb/local").split(
|
2210
|
+
"wandb/local"
|
2211
|
+
)[-1]
|
2212
|
+
if local_image_sha != registry_image_sha:
|
2213
|
+
if upgrade:
|
2214
|
+
subprocess.call(["docker", "pull", "wandb/local"])
|
2215
|
+
else:
|
2216
|
+
wandb.termlog(
|
2217
|
+
"A new version of the W&B server is available, upgrade by calling `wandb server start --upgrade`"
|
2218
|
+
)
|
2219
|
+
running = subprocess.check_output(
|
2220
|
+
["docker", "ps", "--filter", "name=wandb-local", "--format", "{{.ID}}"]
|
2221
|
+
)
|
2222
|
+
if running != b"":
|
2223
|
+
if upgrade:
|
2224
|
+
subprocess.call(["docker", "stop", "wandb-local"])
|
2225
|
+
else:
|
2226
|
+
wandb.termerror(
|
2227
|
+
"A container named wandb-local is already running, run `docker stop wandb-local` if you want to start a new instance"
|
2228
|
+
)
|
2229
|
+
exit(1)
|
2230
|
+
image = "docker.pkg.github.com/wandb/core/local" if edge else "wandb/local"
|
2231
|
+
username = getpass.getuser()
|
2232
|
+
env_vars = ["-e", "LOCAL_USERNAME={}".format(username)]
|
2233
|
+
for e in env:
|
2234
|
+
env_vars.append("-e")
|
2235
|
+
env_vars.append(e)
|
2236
|
+
command = [
|
2237
|
+
"docker",
|
2238
|
+
"run",
|
2239
|
+
"--rm",
|
2240
|
+
"-v",
|
2241
|
+
"wandb:/vol",
|
2242
|
+
"-p",
|
2243
|
+
port + ":8080",
|
2244
|
+
"--name",
|
2245
|
+
"wandb-local",
|
2246
|
+
] + env_vars
|
2247
|
+
host = f"http://localhost:{port}"
|
2248
|
+
api.set_setting("base_url", host, globally=True, persist=True)
|
2249
|
+
if daemon:
|
2250
|
+
command += ["-d"]
|
2251
|
+
command += [image]
|
2252
|
+
|
2253
|
+
# DEVNULL is only in py3
|
2254
|
+
try:
|
2255
|
+
from subprocess import DEVNULL
|
2256
|
+
except ImportError:
|
2257
|
+
DEVNULL = open(os.devnull, "wb") # noqa: N806
|
2258
|
+
code = subprocess.call(command, stdout=DEVNULL)
|
2259
|
+
if daemon:
|
2260
|
+
if code != 0:
|
2261
|
+
wandb.termerror(
|
2262
|
+
"Failed to launch the W&B server container, see the above error."
|
2263
|
+
)
|
2264
|
+
exit(1)
|
2265
|
+
else:
|
2266
|
+
wandb.termlog(
|
2267
|
+
"W&B server started at http://localhost:{} \U0001f680".format(port)
|
2268
|
+
)
|
2269
|
+
wandb.termlog("You can stop the server by running `wandb server stop`")
|
2270
|
+
if not api.api_key:
|
2271
|
+
# Let the server start before potentially launching a browser
|
2272
|
+
time.sleep(2)
|
2273
|
+
ctx.invoke(login, host=host)
|
2274
|
+
|
2275
|
+
|
2276
|
+
@server.command(context_settings=RUN_CONTEXT, help="Stop a local W&B server")
|
2277
|
+
def stop():
|
2278
|
+
if not find_executable("docker"):
|
2279
|
+
raise ClickException("Docker not installed, install it from https://docker.com")
|
2280
|
+
subprocess.call(["docker", "stop", "wandb-local"])
|
2281
|
+
|
2282
|
+
|
2283
|
+
@cli.group(help="Commands for interacting with artifacts")
|
2284
|
+
def artifact():
|
2285
|
+
pass
|
2286
|
+
|
2287
|
+
|
2288
|
+
@artifact.command(context_settings=CONTEXT, help="Upload an artifact to wandb")
|
2289
|
+
@click.argument("path")
|
2290
|
+
@click.option(
|
2291
|
+
"--name", "-n", help="The name of the artifact to push: project/artifact_name"
|
2292
|
+
)
|
2293
|
+
@click.option("--description", "-d", help="A description of this artifact")
|
2294
|
+
@click.option("--type", "-t", default="dataset", help="The type of the artifact")
|
2295
|
+
@click.option(
|
2296
|
+
"--alias",
|
2297
|
+
"-a",
|
2298
|
+
default=["latest"],
|
2299
|
+
multiple=True,
|
2300
|
+
help="An alias to apply to this artifact",
|
2301
|
+
)
|
2302
|
+
@click.option("--id", "run_id", help="The run you want to upload to.")
|
2303
|
+
@click.option(
|
2304
|
+
"--resume",
|
2305
|
+
is_flag=True,
|
2306
|
+
default=None,
|
2307
|
+
help="Resume the last run from your current directory.",
|
2308
|
+
)
|
2309
|
+
@click.option(
|
2310
|
+
"--skip_cache",
|
2311
|
+
is_flag=True,
|
2312
|
+
default=False,
|
2313
|
+
help="Skip caching while uploading artifact files.",
|
2314
|
+
)
|
2315
|
+
@click.option(
|
2316
|
+
"--policy",
|
2317
|
+
default="mutable",
|
2318
|
+
type=click.Choice(["mutable", "immutable"]),
|
2319
|
+
help="Set the storage policy while uploading artifact files.",
|
2320
|
+
)
|
2321
|
+
@display_error
|
2322
|
+
def put(
|
2323
|
+
path,
|
2324
|
+
name,
|
2325
|
+
description,
|
2326
|
+
type,
|
2327
|
+
alias,
|
2328
|
+
run_id,
|
2329
|
+
resume,
|
2330
|
+
skip_cache,
|
2331
|
+
policy,
|
2332
|
+
):
|
2333
|
+
if name is None:
|
2334
|
+
name = os.path.basename(path)
|
2335
|
+
public_api = PublicApi()
|
2336
|
+
entity, project, artifact_name = public_api._parse_artifact_path(name)
|
2337
|
+
if project is None:
|
2338
|
+
project = click.prompt("Enter the name of the project you want to use")
|
2339
|
+
# TODO: settings nightmare...
|
2340
|
+
api = InternalApi()
|
2341
|
+
api.set_setting("entity", entity)
|
2342
|
+
api.set_setting("project", project)
|
2343
|
+
artifact = wandb.Artifact(name=artifact_name, type=type, description=description)
|
2344
|
+
artifact_path = f"{entity}/{project}/{artifact_name}:{alias[0]}"
|
2345
|
+
if os.path.isdir(path):
|
2346
|
+
wandb.termlog(f'Uploading directory {path} to: "{artifact_path}" ({type})')
|
2347
|
+
artifact.add_dir(path, skip_cache=skip_cache, policy=policy)
|
2348
|
+
elif os.path.isfile(path):
|
2349
|
+
wandb.termlog(f'Uploading file {path} to: "{artifact_path}" ({type})')
|
2350
|
+
artifact.add_file(path, skip_cache=skip_cache, policy=policy)
|
2351
|
+
elif "://" in path:
|
2352
|
+
wandb.termlog(
|
2353
|
+
f'Logging reference artifact from {path} to: "{artifact_path}" ({type})'
|
2354
|
+
)
|
2355
|
+
artifact.add_reference(path)
|
2356
|
+
else:
|
2357
|
+
raise ClickException("Path argument must be a file or directory")
|
2358
|
+
|
2359
|
+
with wandb.init(
|
2360
|
+
entity=entity,
|
2361
|
+
project=project,
|
2362
|
+
config={"path": path},
|
2363
|
+
job_type="cli_put",
|
2364
|
+
id=run_id,
|
2365
|
+
resume=resume,
|
2366
|
+
) as run:
|
2367
|
+
run.log_artifact(artifact, aliases=alias)
|
2368
|
+
artifact.wait()
|
2369
|
+
|
2370
|
+
wandb.termlog(
|
2371
|
+
"Artifact uploaded, use this artifact in a run by adding:\n", prefix=False
|
2372
|
+
)
|
2373
|
+
wandb.termlog(
|
2374
|
+
f' artifact = run.use_artifact("{artifact.source_qualified_name}")\n',
|
2375
|
+
prefix=False,
|
2376
|
+
)
|
2377
|
+
|
2378
|
+
|
2379
|
+
@artifact.command(context_settings=CONTEXT, help="Download an artifact from wandb")
|
2380
|
+
@click.argument("path")
|
2381
|
+
@click.option("--root", help="The directory you want to download the artifact to")
|
2382
|
+
@click.option("--type", help="The type of artifact you are downloading")
|
2383
|
+
@display_error
|
2384
|
+
def get(path, root, type):
|
2385
|
+
public_api = PublicApi()
|
2386
|
+
entity, project, artifact_name = public_api._parse_artifact_path(path)
|
2387
|
+
if project is None:
|
2388
|
+
project = click.prompt("Enter the name of the project you want to use")
|
2389
|
+
|
2390
|
+
try:
|
2391
|
+
artifact_parts = artifact_name.split(":")
|
2392
|
+
if len(artifact_parts) > 1:
|
2393
|
+
version = artifact_parts[1]
|
2394
|
+
artifact_name = artifact_parts[0]
|
2395
|
+
else:
|
2396
|
+
version = "latest"
|
2397
|
+
if is_artifact_registry_project(project):
|
2398
|
+
organization = path.split("/")[0] if path.count("/") == 2 else ""
|
2399
|
+
# set entity to match the settings since in above code it was potentially set to an org
|
2400
|
+
settings_entity = public_api.settings["entity"] or public_api.default_entity
|
2401
|
+
# Registry artifacts are under the org entity. Because we offer a shorthand and alias for this path,
|
2402
|
+
# we need to fetch the org entity to for the user behind the scenes.
|
2403
|
+
entity = SDKInternalApi()._resolve_org_entity_name(
|
2404
|
+
entity=settings_entity, organization=organization
|
2405
|
+
)
|
2406
|
+
full_path = f"{entity}/{project}/{artifact_name}:{version}"
|
2407
|
+
wandb.termlog(
|
2408
|
+
"Downloading {type} artifact {full_path}".format(
|
2409
|
+
type=type or "dataset", full_path=full_path
|
2410
|
+
)
|
2411
|
+
)
|
2412
|
+
artifact = public_api.artifact(full_path, type=type)
|
2413
|
+
path = artifact.download(root=root)
|
2414
|
+
wandb.termlog("Artifact downloaded to {}".format(path))
|
2415
|
+
except ValueError:
|
2416
|
+
raise ClickException("Unable to download artifact")
|
2417
|
+
|
2418
|
+
|
2419
|
+
@artifact.command(
|
2420
|
+
context_settings=CONTEXT, help="List all artifacts in a wandb project"
|
2421
|
+
)
|
2422
|
+
@click.argument("path")
|
2423
|
+
@click.option("--type", "-t", help="The type of artifacts to list")
|
2424
|
+
@display_error
|
2425
|
+
def ls(path, type):
|
2426
|
+
public_api = PublicApi()
|
2427
|
+
if type is not None:
|
2428
|
+
types = [public_api.artifact_type(type, path)]
|
2429
|
+
else:
|
2430
|
+
types = public_api.artifact_types(path)
|
2431
|
+
|
2432
|
+
for kind in types:
|
2433
|
+
for collection in kind.collections():
|
2434
|
+
versions = public_api.artifact_versions(
|
2435
|
+
kind.type,
|
2436
|
+
"/".join([kind.entity, kind.project, collection.name]),
|
2437
|
+
per_page=1,
|
2438
|
+
)
|
2439
|
+
latest = next(versions)
|
2440
|
+
print(
|
2441
|
+
"{:<15s}{:<15s}{:>15s} {:<20s}".format(
|
2442
|
+
kind.type,
|
2443
|
+
latest.updated_at,
|
2444
|
+
util.to_human_size(latest.size),
|
2445
|
+
latest.name,
|
2446
|
+
)
|
2447
|
+
)
|
2448
|
+
|
2449
|
+
|
2450
|
+
@artifact.group(help="Commands for interacting with the artifact cache")
|
2451
|
+
def cache():
|
2452
|
+
pass
|
2453
|
+
|
2454
|
+
|
2455
|
+
@cache.command(
|
2456
|
+
context_settings=CONTEXT,
|
2457
|
+
help="Clean up less frequently used files from the artifacts cache",
|
2458
|
+
)
|
2459
|
+
@click.argument("target_size")
|
2460
|
+
@click.option("--remove-temp/--no-remove-temp", default=False, help="Remove temp files")
|
2461
|
+
@display_error
|
2462
|
+
def cleanup(target_size, remove_temp):
|
2463
|
+
target_size = util.from_human_size(target_size)
|
2464
|
+
cache = get_artifact_file_cache()
|
2465
|
+
reclaimed_bytes = cache.cleanup(target_size, remove_temp)
|
2466
|
+
print(f"Reclaimed {util.to_human_size(reclaimed_bytes)} of space")
|
2467
|
+
|
2468
|
+
|
2469
|
+
@cli.command(context_settings=CONTEXT, help="Pull files from Weights & Biases")
|
2470
|
+
@click.argument("run", envvar=env.RUN_ID)
|
2471
|
+
@click.option(
|
2472
|
+
"--project", "-p", envvar=env.PROJECT, help="The project you want to download."
|
2473
|
+
)
|
2474
|
+
@click.option(
|
2475
|
+
"--entity",
|
2476
|
+
"-e",
|
2477
|
+
default="models",
|
2478
|
+
envvar=env.ENTITY,
|
2479
|
+
help="The entity to scope the listing to.",
|
2480
|
+
)
|
2481
|
+
@display_error
|
2482
|
+
def pull(run, project, entity):
|
2483
|
+
api = InternalApi()
|
2484
|
+
project, run = api.parse_slug(run, project=project)
|
2485
|
+
urls = api.download_urls(project, run=run, entity=entity)
|
2486
|
+
if len(urls) == 0:
|
2487
|
+
raise ClickException("Run has no files")
|
2488
|
+
click.echo(f"Downloading: {click.style(project, bold=True)}/{run}")
|
2489
|
+
|
2490
|
+
for name in urls:
|
2491
|
+
if api.file_current(name, urls[name]["md5"]):
|
2492
|
+
click.echo("File {} is up to date".format(name))
|
2493
|
+
else:
|
2494
|
+
length, response = api.download_file(urls[name]["url"])
|
2495
|
+
# TODO: I had to add this because some versions in CI broke click.progressbar
|
2496
|
+
sys.stdout.write("File {}\r".format(name))
|
2497
|
+
dirname = os.path.dirname(name)
|
2498
|
+
if dirname != "":
|
2499
|
+
filesystem.mkdir_exists_ok(dirname)
|
2500
|
+
with click.progressbar(
|
2501
|
+
length=length,
|
2502
|
+
label="File {}".format(name),
|
2503
|
+
fill_char=click.style("&", fg="green"),
|
2504
|
+
) as bar:
|
2505
|
+
with open(name, "wb") as f:
|
2506
|
+
for data in response.iter_content(chunk_size=4096):
|
2507
|
+
f.write(data)
|
2508
|
+
bar.update(len(data))
|
2509
|
+
|
2510
|
+
|
2511
|
+
@cli.command(
|
2512
|
+
context_settings=CONTEXT, help="Restore code, config and docker state for a run"
|
2513
|
+
)
|
2514
|
+
@click.pass_context
|
2515
|
+
@click.argument("run", envvar=env.RUN_ID)
|
2516
|
+
@click.option("--no-git", is_flag=True, default=False, help="Don't restore git state")
|
2517
|
+
@click.option(
|
2518
|
+
"--branch/--no-branch",
|
2519
|
+
default=True,
|
2520
|
+
help="Whether to create a branch or checkout detached",
|
2521
|
+
)
|
2522
|
+
@click.option(
|
2523
|
+
"--project", "-p", envvar=env.PROJECT, help="The project you wish to upload to."
|
2524
|
+
)
|
2525
|
+
@click.option(
|
2526
|
+
"--entity", "-e", envvar=env.ENTITY, help="The entity to scope the listing to."
|
2527
|
+
)
|
2528
|
+
@display_error
|
2529
|
+
def restore(ctx, run, no_git, branch, project, entity):
|
2530
|
+
from wandb.old.core import wandb_dir
|
2531
|
+
|
2532
|
+
api = _get_cling_api()
|
2533
|
+
if ":" in run:
|
2534
|
+
if "/" in run:
|
2535
|
+
entity, rest = run.split("/", 1)
|
2536
|
+
else:
|
2537
|
+
rest = run
|
2538
|
+
project, run = rest.split(":", 1)
|
2539
|
+
elif run.count("/") > 1:
|
2540
|
+
entity, run = run.split("/", 1)
|
2541
|
+
|
2542
|
+
project, run = api.parse_slug(run, project=project)
|
2543
|
+
commit, json_config, patch_content, metadata = api.run_config(
|
2544
|
+
project, run=run, entity=entity
|
2545
|
+
)
|
2546
|
+
repo = metadata.get("git", {}).get("repo")
|
2547
|
+
image = metadata.get("docker")
|
2548
|
+
restore_message = """`wandb restore` needs to be run from the same git repository as the original run.
|
2549
|
+
Run `git clone {}` and restore from there or pass the --no-git flag.""".format(repo)
|
2550
|
+
if no_git:
|
2551
|
+
commit = None
|
2552
|
+
elif not api.git.enabled:
|
2553
|
+
if repo:
|
2554
|
+
raise ClickException(restore_message)
|
2555
|
+
elif image:
|
2556
|
+
wandb.termlog(
|
2557
|
+
"Original run has no git history. Just restoring config and docker"
|
2558
|
+
)
|
2559
|
+
|
2560
|
+
if commit and api.git.enabled:
|
2561
|
+
wandb.termlog(f"Fetching origin and finding commit: {commit}")
|
2562
|
+
subprocess.check_call(["git", "fetch", "--all"])
|
2563
|
+
try:
|
2564
|
+
api.git.repo.commit(commit)
|
2565
|
+
except ValueError:
|
2566
|
+
wandb.termlog(f"Couldn't find original commit: {commit}")
|
2567
|
+
commit = None
|
2568
|
+
files = api.download_urls(project, run=run, entity=entity)
|
2569
|
+
for filename in files:
|
2570
|
+
if filename.startswith("upstream_diff_") and filename.endswith(
|
2571
|
+
".patch"
|
2572
|
+
):
|
2573
|
+
commit = filename[len("upstream_diff_") : -len(".patch")]
|
2574
|
+
try:
|
2575
|
+
api.git.repo.commit(commit)
|
2576
|
+
except ValueError:
|
2577
|
+
commit = None
|
2578
|
+
else:
|
2579
|
+
break
|
2580
|
+
|
2581
|
+
if commit:
|
2582
|
+
wandb.termlog(f"Falling back to upstream commit: {commit}")
|
2583
|
+
patch_path, _ = api.download_write_file(files[filename])
|
2584
|
+
else:
|
2585
|
+
raise ClickException(restore_message)
|
2586
|
+
else:
|
2587
|
+
if patch_content:
|
2588
|
+
patch_path = os.path.join(wandb_dir(), "diff.patch")
|
2589
|
+
with open(patch_path, "w") as f:
|
2590
|
+
f.write(patch_content)
|
2591
|
+
else:
|
2592
|
+
patch_path = None
|
2593
|
+
|
2594
|
+
branch_name = "wandb/{}".format(run)
|
2595
|
+
if branch and branch_name not in api.git.repo.branches:
|
2596
|
+
api.git.repo.git.checkout(commit, b=branch_name)
|
2597
|
+
wandb.termlog(
|
2598
|
+
"Created branch {}".format(click.style(branch_name, bold=True))
|
2599
|
+
)
|
2600
|
+
elif branch:
|
2601
|
+
wandb.termlog(
|
2602
|
+
"Using existing branch, run `git branch -D {}` from master for a clean checkout".format(
|
2603
|
+
branch_name
|
2604
|
+
)
|
2605
|
+
)
|
2606
|
+
api.git.repo.git.checkout(branch_name)
|
2607
|
+
else:
|
2608
|
+
wandb.termlog("Checking out {} in detached mode".format(commit))
|
2609
|
+
api.git.repo.git.checkout(commit)
|
2610
|
+
|
2611
|
+
if patch_path:
|
2612
|
+
# we apply the patch from the repository root so git doesn't exclude
|
2613
|
+
# things outside the current directory
|
2614
|
+
root = api.git.root
|
2615
|
+
patch_rel_path = os.path.relpath(patch_path, start=root)
|
2616
|
+
# --reject is necessary or else this fails any time a binary file
|
2617
|
+
# occurs in the diff
|
2618
|
+
exit_code = subprocess.call(
|
2619
|
+
["git", "apply", "--reject", patch_rel_path], cwd=root
|
2620
|
+
)
|
2621
|
+
if exit_code == 0:
|
2622
|
+
wandb.termlog("Applied patch")
|
2623
|
+
else:
|
2624
|
+
wandb.termerror(
|
2625
|
+
"Failed to apply patch, try un-staging any un-committed changes"
|
2626
|
+
)
|
2627
|
+
|
2628
|
+
filesystem.mkdir_exists_ok(wandb_dir())
|
2629
|
+
config_path = os.path.join(wandb_dir(), "config.yaml")
|
2630
|
+
config = Config()
|
2631
|
+
for k, v in json_config.items():
|
2632
|
+
if k not in ("_wandb", "wandb_version"):
|
2633
|
+
config[k] = v
|
2634
|
+
s = b"wandb_version: 1"
|
2635
|
+
s += b"\n\n" + yaml.dump(
|
2636
|
+
config._as_dict(),
|
2637
|
+
Dumper=yaml.SafeDumper,
|
2638
|
+
default_flow_style=False,
|
2639
|
+
allow_unicode=True,
|
2640
|
+
encoding="utf-8",
|
2641
|
+
)
|
2642
|
+
s = s.decode("utf-8")
|
2643
|
+
with open(config_path, "w") as f:
|
2644
|
+
f.write(s)
|
2645
|
+
|
2646
|
+
wandb.termlog("Restored config variables to {}".format(config_path))
|
2647
|
+
if image:
|
2648
|
+
if not metadata["program"].startswith("<") and metadata.get("args") is not None:
|
2649
|
+
# TODO: we may not want to default to python here.
|
2650
|
+
runner = util.find_runner(metadata["program"]) or ["python"]
|
2651
|
+
command = runner + [metadata["program"]] + metadata["args"]
|
2652
|
+
cmd = " ".join(command)
|
2653
|
+
else:
|
2654
|
+
wandb.termlog("Couldn't find original command, just restoring environment")
|
2655
|
+
cmd = None
|
2656
|
+
wandb.termlog("Docker image found, attempting to start")
|
2657
|
+
ctx.invoke(docker, docker_run_args=[image], cmd=cmd)
|
2658
|
+
|
2659
|
+
return commit, json_config, patch_content, repo, metadata
|
2660
|
+
|
2661
|
+
|
2662
|
+
@cli.command("online", help="Enable W&B sync")
|
2663
|
+
@display_error
|
2664
|
+
def online():
|
2665
|
+
api = InternalApi()
|
2666
|
+
try:
|
2667
|
+
api.clear_setting("disabled", persist=True)
|
2668
|
+
api.clear_setting("mode", persist=True)
|
2669
|
+
except configparser.Error:
|
2670
|
+
pass
|
2671
|
+
click.echo(
|
2672
|
+
"W&B online. Running your script from this directory will now sync to the cloud."
|
2673
|
+
)
|
2674
|
+
|
2675
|
+
|
2676
|
+
@cli.command("offline", help="Disable W&B sync")
|
2677
|
+
@display_error
|
2678
|
+
def offline():
|
2679
|
+
api = InternalApi()
|
2680
|
+
try:
|
2681
|
+
api.set_setting("disabled", "true", persist=True)
|
2682
|
+
api.set_setting("mode", "offline", persist=True)
|
2683
|
+
click.echo(
|
2684
|
+
"W&B offline. Running your script from this directory will only write metadata locally. Use wandb disabled to completely turn off W&B."
|
2685
|
+
)
|
2686
|
+
except configparser.Error:
|
2687
|
+
click.echo(
|
2688
|
+
"Unable to write config, copy and paste the following in your terminal to turn off W&B:\nexport WANDB_MODE=offline"
|
2689
|
+
)
|
2690
|
+
|
2691
|
+
|
2692
|
+
@cli.command("on", hidden=True)
|
2693
|
+
@click.pass_context
|
2694
|
+
@display_error
|
2695
|
+
def on(ctx):
|
2696
|
+
ctx.invoke(online)
|
2697
|
+
|
2698
|
+
|
2699
|
+
@cli.command("off", hidden=True)
|
2700
|
+
@click.pass_context
|
2701
|
+
@display_error
|
2702
|
+
def off(ctx):
|
2703
|
+
ctx.invoke(offline)
|
2704
|
+
|
2705
|
+
|
2706
|
+
@cli.command("status", help="Show configuration settings")
|
2707
|
+
@click.option(
|
2708
|
+
"--settings/--no-settings", help="Show the current settings", default=True
|
2709
|
+
)
|
2710
|
+
def status(settings):
|
2711
|
+
api = _get_cling_api()
|
2712
|
+
if settings:
|
2713
|
+
click.echo(click.style("Current Settings", bold=True))
|
2714
|
+
settings = api.settings()
|
2715
|
+
click.echo(
|
2716
|
+
json.dumps(settings, sort_keys=True, indent=2, separators=(",", ": "))
|
2717
|
+
)
|
2718
|
+
|
2719
|
+
|
2720
|
+
@cli.command("disabled", help="Disable W&B.")
|
2721
|
+
@click.option(
|
2722
|
+
"--service",
|
2723
|
+
is_flag=True,
|
2724
|
+
show_default=True,
|
2725
|
+
default=True,
|
2726
|
+
help="Disable W&B service",
|
2727
|
+
)
|
2728
|
+
def disabled(service):
|
2729
|
+
api = InternalApi()
|
2730
|
+
try:
|
2731
|
+
api.set_setting("mode", "disabled", persist=True)
|
2732
|
+
click.echo("W&B disabled.")
|
2733
|
+
except configparser.Error:
|
2734
|
+
click.echo(
|
2735
|
+
"Unable to write config, copy and paste the following in your terminal to turn off W&B:\nexport WANDB_MODE=disabled"
|
2736
|
+
)
|
2737
|
+
|
2738
|
+
|
2739
|
+
@cli.command("enabled", help="Enable W&B.")
|
2740
|
+
@click.option(
|
2741
|
+
"--service",
|
2742
|
+
is_flag=True,
|
2743
|
+
show_default=True,
|
2744
|
+
default=True,
|
2745
|
+
help="Enable W&B service",
|
2746
|
+
)
|
2747
|
+
def enabled(service):
|
2748
|
+
api = InternalApi()
|
2749
|
+
try:
|
2750
|
+
api.set_setting("mode", "online", persist=True)
|
2751
|
+
click.echo("W&B enabled.")
|
2752
|
+
except configparser.Error:
|
2753
|
+
click.echo(
|
2754
|
+
"Unable to write config, copy and paste the following in your terminal to turn on W&B:\nexport WANDB_MODE=online"
|
2755
|
+
)
|
2756
|
+
|
2757
|
+
|
2758
|
+
@cli.command(context_settings=CONTEXT, help="Verify your local instance")
|
2759
|
+
@click.option("--host", default=None, help="Test a specific instance of W&B")
|
2760
|
+
def verify(host):
|
2761
|
+
# TODO: (kdg) Build this all into a WandbVerify object, and clean this up.
|
2762
|
+
os.environ["WANDB_SILENT"] = "true"
|
2763
|
+
os.environ["WANDB_PROJECT"] = "verify"
|
2764
|
+
api = _get_cling_api()
|
2765
|
+
reinit = False
|
2766
|
+
if host is None:
|
2767
|
+
host = api.settings("base_url")
|
2768
|
+
print(f"Default host selected: {host}")
|
2769
|
+
# if the given host does not match the default host, re-run init
|
2770
|
+
elif host != api.settings("base_url"):
|
2771
|
+
reinit = True
|
2772
|
+
|
2773
|
+
tmp_dir = tempfile.mkdtemp()
|
2774
|
+
print(
|
2775
|
+
"Find detailed logs for this test at: {}".format(os.path.join(tmp_dir, "wandb"))
|
2776
|
+
)
|
2777
|
+
os.chdir(tmp_dir)
|
2778
|
+
os.environ["WANDB_BASE_URL"] = host
|
2779
|
+
wandb.login(host=host)
|
2780
|
+
if reinit:
|
2781
|
+
api = _get_cling_api(reset=True)
|
2782
|
+
if not wandb_verify.check_host(host):
|
2783
|
+
sys.exit(1)
|
2784
|
+
if not wandb_verify.check_logged_in(api, host):
|
2785
|
+
sys.exit(1)
|
2786
|
+
url_success, url = wandb_verify.check_graphql_put(api, host)
|
2787
|
+
large_post_success = wandb_verify.check_large_post()
|
2788
|
+
wandb_verify.check_secure_requests(
|
2789
|
+
api.settings("base_url"),
|
2790
|
+
"Checking requests to base url",
|
2791
|
+
"Connections are not made over https. SSL required for secure communications.",
|
2792
|
+
)
|
2793
|
+
if url:
|
2794
|
+
wandb_verify.check_secure_requests(
|
2795
|
+
url,
|
2796
|
+
"Checking requests made over signed URLs",
|
2797
|
+
"Signed URL requests not made over https. SSL is required for secure communications.",
|
2798
|
+
)
|
2799
|
+
wandb_verify.check_cors_configuration(url, host)
|
2800
|
+
wandb_verify.check_wandb_version(api)
|
2801
|
+
check_run_success = wandb_verify.check_run(api)
|
2802
|
+
check_artifacts_success = wandb_verify.check_artifacts()
|
2803
|
+
if not (
|
2804
|
+
check_artifacts_success
|
2805
|
+
and check_run_success
|
2806
|
+
and large_post_success
|
2807
|
+
and url_success
|
2808
|
+
):
|
2809
|
+
sys.exit(1)
|
2810
|
+
|
2811
|
+
|
2812
|
+
cli.add_command(beta)
|