dstack 0.0.9__py3-none-any.whl → 0.20.7__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- dstack/_internal/cli/commands/__init__.py +80 -0
- dstack/_internal/cli/commands/apply.py +100 -0
- dstack/_internal/cli/commands/attach.py +161 -0
- dstack/_internal/cli/commands/completion.py +22 -0
- dstack/_internal/cli/commands/delete.py +44 -0
- dstack/_internal/cli/commands/event.py +168 -0
- dstack/_internal/cli/commands/fleet.py +161 -0
- dstack/_internal/cli/commands/gateway.py +159 -0
- dstack/_internal/cli/commands/init.py +64 -0
- dstack/_internal/cli/commands/login.py +352 -0
- dstack/_internal/cli/commands/logs.py +62 -0
- dstack/_internal/cli/commands/metrics.py +153 -0
- dstack/_internal/cli/commands/offer.py +146 -0
- dstack/_internal/cli/commands/project.py +259 -0
- dstack/_internal/cli/commands/ps.py +81 -0
- dstack/_internal/cli/commands/run.py +69 -0
- dstack/_internal/cli/commands/secrets.py +92 -0
- dstack/_internal/cli/commands/server.py +96 -0
- dstack/_internal/cli/commands/stop.py +26 -0
- dstack/_internal/cli/commands/volume.py +117 -0
- dstack/_internal/cli/main.py +101 -0
- dstack/_internal/cli/models/gateways.py +16 -0
- dstack/_internal/cli/models/offers.py +47 -0
- dstack/_internal/cli/models/runs.py +16 -0
- dstack/_internal/cli/services/args.py +31 -0
- dstack/_internal/cli/services/completion.py +91 -0
- dstack/_internal/cli/services/configurators/__init__.py +86 -0
- dstack/_internal/cli/services/configurators/base.py +103 -0
- dstack/_internal/cli/services/configurators/fleet.py +475 -0
- dstack/_internal/cli/services/configurators/gateway.py +231 -0
- dstack/_internal/cli/services/configurators/run.py +882 -0
- dstack/_internal/cli/services/configurators/volume.py +222 -0
- dstack/_internal/cli/services/events.py +68 -0
- dstack/_internal/cli/services/profile.py +182 -0
- dstack/_internal/cli/services/repos.py +71 -0
- dstack/_internal/cli/services/resources.py +54 -0
- dstack/_internal/cli/utils/common.py +159 -0
- dstack/_internal/cli/utils/fleet.py +106 -0
- dstack/_internal/cli/utils/gateway.py +56 -0
- dstack/_internal/cli/utils/gpu.py +178 -0
- dstack/_internal/cli/utils/rich.py +156 -0
- dstack/_internal/cli/utils/run.py +517 -0
- dstack/_internal/cli/utils/secrets.py +25 -0
- dstack/_internal/cli/utils/updates.py +98 -0
- dstack/_internal/cli/utils/volume.py +58 -0
- dstack/_internal/compat.py +3 -0
- dstack/_internal/core/backends/amddevcloud/__init__.py +1 -0
- dstack/_internal/core/backends/amddevcloud/backend.py +16 -0
- dstack/_internal/core/backends/amddevcloud/compute.py +5 -0
- dstack/_internal/core/backends/amddevcloud/configurator.py +29 -0
- dstack/_internal/core/backends/aws/auth.py +30 -0
- dstack/_internal/core/backends/aws/backend.py +31 -0
- dstack/_internal/core/backends/aws/compute.py +1153 -0
- dstack/_internal/core/backends/aws/configurator.py +191 -0
- dstack/_internal/core/backends/aws/models.py +135 -0
- dstack/_internal/core/backends/aws/resources.py +700 -0
- dstack/_internal/core/backends/azure/auth.py +39 -0
- dstack/_internal/core/backends/azure/backend.py +21 -0
- dstack/_internal/core/backends/azure/compute.py +676 -0
- dstack/_internal/core/backends/azure/configurator.py +472 -0
- dstack/_internal/core/backends/azure/models.py +98 -0
- dstack/_internal/core/backends/azure/resources.py +116 -0
- dstack/_internal/core/backends/azure/utils.py +42 -0
- dstack/_internal/core/backends/base/backend.py +18 -0
- dstack/_internal/core/backends/base/compute.py +1101 -0
- dstack/_internal/core/backends/base/configurator.py +117 -0
- dstack/_internal/core/backends/base/models.py +24 -0
- dstack/_internal/core/backends/base/offers.py +232 -0
- dstack/_internal/core/backends/cloudrift/api_client.py +220 -0
- dstack/_internal/core/backends/cloudrift/backend.py +16 -0
- dstack/_internal/core/backends/cloudrift/compute.py +138 -0
- dstack/_internal/core/backends/cloudrift/configurator.py +72 -0
- dstack/_internal/core/backends/cloudrift/models.py +40 -0
- dstack/_internal/core/backends/configurators.py +181 -0
- dstack/_internal/core/backends/cudo/__init__.py +0 -0
- dstack/_internal/core/backends/cudo/api_client.py +111 -0
- dstack/_internal/core/backends/cudo/backend.py +16 -0
- dstack/_internal/core/backends/cudo/compute.py +174 -0
- dstack/_internal/core/backends/cudo/configurator.py +63 -0
- dstack/_internal/core/backends/cudo/models.py +37 -0
- dstack/_internal/core/backends/datacrunch/__init__.py +1 -0
- dstack/_internal/core/backends/datacrunch/backend.py +18 -0
- dstack/_internal/core/backends/datacrunch/compute.py +8 -0
- dstack/_internal/core/backends/datacrunch/configurator.py +17 -0
- dstack/_internal/core/backends/digitalocean/__init__.py +1 -0
- dstack/_internal/core/backends/digitalocean/backend.py +16 -0
- dstack/_internal/core/backends/digitalocean/compute.py +5 -0
- dstack/_internal/core/backends/digitalocean/configurator.py +31 -0
- dstack/_internal/core/backends/digitalocean_base/__init__.py +1 -0
- dstack/_internal/core/backends/digitalocean_base/api_client.py +104 -0
- dstack/_internal/core/backends/digitalocean_base/backend.py +5 -0
- dstack/_internal/core/backends/digitalocean_base/compute.py +174 -0
- dstack/_internal/core/backends/digitalocean_base/configurator.py +57 -0
- dstack/_internal/core/backends/digitalocean_base/models.py +43 -0
- dstack/_internal/core/backends/dstack/__init__.py +0 -0
- dstack/_internal/core/backends/dstack/models.py +26 -0
- dstack/_internal/core/backends/features.py +74 -0
- dstack/_internal/core/backends/gcp/__init__.py +0 -0
- dstack/_internal/core/backends/gcp/auth.py +57 -0
- dstack/_internal/core/backends/gcp/backend.py +17 -0
- dstack/_internal/core/backends/gcp/compute.py +1257 -0
- dstack/_internal/core/backends/gcp/configurator.py +206 -0
- dstack/_internal/core/backends/gcp/features/__init__.py +0 -0
- dstack/_internal/core/backends/gcp/features/tcpx.py +65 -0
- dstack/_internal/core/backends/gcp/models.py +160 -0
- dstack/_internal/core/backends/gcp/resources.py +585 -0
- dstack/_internal/core/backends/hotaisle/__init__.py +1 -0
- dstack/_internal/core/backends/hotaisle/api_client.py +101 -0
- dstack/_internal/core/backends/hotaisle/backend.py +16 -0
- dstack/_internal/core/backends/hotaisle/compute.py +188 -0
- dstack/_internal/core/backends/hotaisle/configurator.py +66 -0
- dstack/_internal/core/backends/hotaisle/models.py +45 -0
- dstack/_internal/core/backends/kubernetes/__init__.py +0 -0
- dstack/_internal/core/backends/kubernetes/backend.py +16 -0
- dstack/_internal/core/backends/kubernetes/compute.py +1077 -0
- dstack/_internal/core/backends/kubernetes/configurator.py +61 -0
- dstack/_internal/core/backends/kubernetes/models.py +71 -0
- dstack/_internal/core/backends/kubernetes/utils.py +81 -0
- dstack/_internal/core/backends/lambdalabs/__init__.py +0 -0
- dstack/_internal/core/backends/lambdalabs/api_client.py +87 -0
- dstack/_internal/core/backends/lambdalabs/backend.py +17 -0
- dstack/_internal/core/backends/lambdalabs/compute.py +233 -0
- dstack/_internal/core/backends/lambdalabs/configurator.py +65 -0
- dstack/_internal/core/backends/lambdalabs/models.py +37 -0
- dstack/_internal/core/backends/local/__init__.py +0 -0
- dstack/_internal/core/backends/local/backend.py +14 -0
- dstack/_internal/core/backends/local/compute.py +130 -0
- dstack/_internal/core/backends/models.py +158 -0
- dstack/_internal/core/backends/nebius/__init__.py +0 -0
- dstack/_internal/core/backends/nebius/backend.py +16 -0
- dstack/_internal/core/backends/nebius/compute.py +401 -0
- dstack/_internal/core/backends/nebius/configurator.py +98 -0
- dstack/_internal/core/backends/nebius/models.py +185 -0
- dstack/_internal/core/backends/nebius/resources.py +433 -0
- dstack/_internal/core/backends/oci/__init__.py +0 -0
- dstack/_internal/core/backends/oci/auth.py +21 -0
- dstack/_internal/core/backends/oci/backend.py +16 -0
- dstack/_internal/core/backends/oci/compute.py +209 -0
- dstack/_internal/core/backends/oci/configurator.py +156 -0
- dstack/_internal/core/backends/oci/exceptions.py +15 -0
- dstack/_internal/core/backends/oci/models.py +87 -0
- dstack/_internal/core/backends/oci/region.py +86 -0
- dstack/_internal/core/backends/oci/resources.py +836 -0
- dstack/_internal/core/backends/runpod/__init__.py +0 -0
- dstack/_internal/core/backends/runpod/api_client.py +627 -0
- dstack/_internal/core/backends/runpod/backend.py +16 -0
- dstack/_internal/core/backends/runpod/compute.py +444 -0
- dstack/_internal/core/backends/runpod/configurator.py +63 -0
- dstack/_internal/core/backends/runpod/models.py +54 -0
- dstack/_internal/core/backends/template/__init__.py +0 -0
- dstack/_internal/core/backends/template/backend.py.jinja +16 -0
- dstack/_internal/core/backends/template/compute.py.jinja +95 -0
- dstack/_internal/core/backends/template/configurator.py.jinja +69 -0
- dstack/_internal/core/backends/template/models.py.jinja +62 -0
- dstack/_internal/core/backends/tensordock/models.py +40 -0
- dstack/_internal/core/backends/vastai/__init__.py +0 -0
- dstack/_internal/core/backends/vastai/api_client.py +143 -0
- dstack/_internal/core/backends/vastai/backend.py +16 -0
- dstack/_internal/core/backends/vastai/compute.py +141 -0
- dstack/_internal/core/backends/vastai/configurator.py +69 -0
- dstack/_internal/core/backends/vastai/models.py +37 -0
- dstack/_internal/core/backends/verda/__init__.py +0 -0
- dstack/_internal/core/backends/verda/backend.py +16 -0
- dstack/_internal/core/backends/verda/compute.py +266 -0
- dstack/_internal/core/backends/verda/configurator.py +73 -0
- dstack/_internal/core/backends/verda/models.py +38 -0
- dstack/_internal/core/backends/vultr/__init__.py +0 -0
- dstack/_internal/core/backends/vultr/api_client.py +116 -0
- dstack/_internal/core/backends/vultr/backend.py +16 -0
- dstack/_internal/core/backends/vultr/compute.py +167 -0
- dstack/_internal/core/backends/vultr/configurator.py +71 -0
- dstack/_internal/core/backends/vultr/models.py +34 -0
- dstack/_internal/core/compatibility/__init__.py +0 -0
- dstack/_internal/core/compatibility/events.py +13 -0
- dstack/_internal/core/compatibility/fleets.py +58 -0
- dstack/_internal/core/compatibility/gateways.py +39 -0
- dstack/_internal/core/compatibility/gpus.py +13 -0
- dstack/_internal/core/compatibility/logs.py +14 -0
- dstack/_internal/core/compatibility/runs.py +86 -0
- dstack/_internal/core/compatibility/volumes.py +37 -0
- dstack/_internal/core/consts.py +8 -0
- dstack/_internal/core/errors.py +160 -0
- dstack/_internal/core/models/__init__.py +0 -0
- dstack/_internal/core/models/auth.py +28 -0
- dstack/_internal/core/models/backends/__init__.py +0 -0
- dstack/_internal/core/models/backends/base.py +48 -0
- dstack/_internal/core/models/common.py +143 -0
- dstack/_internal/core/models/compute_groups.py +39 -0
- dstack/_internal/core/models/config.py +28 -0
- dstack/_internal/core/models/configurations.py +1123 -0
- dstack/_internal/core/models/envs.py +149 -0
- dstack/_internal/core/models/events.py +98 -0
- dstack/_internal/core/models/files.py +67 -0
- dstack/_internal/core/models/fleets.py +437 -0
- dstack/_internal/core/models/gateways.py +146 -0
- dstack/_internal/core/models/gpus.py +45 -0
- dstack/_internal/core/models/health.py +28 -0
- dstack/_internal/core/models/instances.py +346 -0
- dstack/_internal/core/models/logs.py +27 -0
- dstack/_internal/core/models/metrics.py +14 -0
- dstack/_internal/core/models/placement.py +27 -0
- dstack/_internal/core/models/profiles.py +431 -0
- dstack/_internal/core/models/projects.py +46 -0
- dstack/_internal/core/models/repos/__init__.py +34 -0
- dstack/_internal/core/models/repos/base.py +36 -0
- dstack/_internal/core/models/repos/local.py +96 -0
- dstack/_internal/core/models/repos/remote.py +341 -0
- dstack/_internal/core/models/repos/virtual.py +85 -0
- dstack/_internal/core/models/resources.py +424 -0
- dstack/_internal/core/models/routers.py +24 -0
- dstack/_internal/core/models/runs.py +618 -0
- dstack/_internal/core/models/secrets.py +16 -0
- dstack/_internal/core/models/server.py +7 -0
- dstack/_internal/core/models/services.py +76 -0
- dstack/_internal/core/models/unix.py +53 -0
- dstack/_internal/core/models/users.py +60 -0
- dstack/_internal/core/models/volumes.py +221 -0
- dstack/_internal/core/services/__init__.py +16 -0
- dstack/_internal/core/services/api_client.py +15 -0
- dstack/_internal/core/services/configs/__init__.py +116 -0
- dstack/_internal/core/services/diff.py +71 -0
- dstack/_internal/core/services/logs.py +58 -0
- dstack/_internal/core/services/profiles.py +46 -0
- dstack/_internal/core/services/repos.py +236 -0
- dstack/_internal/core/services/ssh/__init__.py +27 -0
- dstack/_internal/core/services/ssh/attach.py +241 -0
- dstack/_internal/core/services/ssh/client.py +113 -0
- dstack/_internal/core/services/ssh/key_manager.py +53 -0
- dstack/_internal/core/services/ssh/ports.py +89 -0
- dstack/_internal/core/services/ssh/tunnel.py +337 -0
- dstack/_internal/proxy/__init__.py +8 -0
- dstack/_internal/proxy/gateway/__init__.py +0 -0
- dstack/_internal/proxy/gateway/app.py +89 -0
- dstack/_internal/proxy/gateway/auth.py +26 -0
- dstack/_internal/proxy/gateway/const.py +7 -0
- dstack/_internal/proxy/gateway/deps.py +73 -0
- dstack/_internal/proxy/gateway/main.py +17 -0
- dstack/_internal/proxy/gateway/models.py +23 -0
- dstack/_internal/proxy/gateway/repo/__init__.py +0 -0
- dstack/_internal/proxy/gateway/repo/repo.py +121 -0
- dstack/_internal/proxy/gateway/repo/state_v1.py +164 -0
- dstack/_internal/proxy/gateway/resources/nginx/00-log-format.conf +11 -0
- dstack/_internal/proxy/gateway/resources/nginx/entrypoint.jinja2 +27 -0
- dstack/_internal/proxy/gateway/resources/nginx/router_workers.jinja2 +23 -0
- dstack/_internal/proxy/gateway/resources/nginx/service.jinja2 +105 -0
- dstack/_internal/proxy/gateway/routers/__init__.py +0 -0
- dstack/_internal/proxy/gateway/routers/auth.py +10 -0
- dstack/_internal/proxy/gateway/routers/config.py +28 -0
- dstack/_internal/proxy/gateway/routers/registry.py +124 -0
- dstack/_internal/proxy/gateway/routers/stats.py +18 -0
- dstack/_internal/proxy/gateway/schemas/__init__.py +0 -0
- dstack/_internal/proxy/gateway/schemas/common.py +5 -0
- dstack/_internal/proxy/gateway/schemas/config.py +9 -0
- dstack/_internal/proxy/gateway/schemas/registry.py +63 -0
- dstack/_internal/proxy/gateway/schemas/stats.py +15 -0
- dstack/_internal/proxy/gateway/services/__init__.py +0 -0
- dstack/_internal/proxy/gateway/services/model_routers/__init__.py +18 -0
- dstack/_internal/proxy/gateway/services/model_routers/base.py +91 -0
- dstack/_internal/proxy/gateway/services/model_routers/sglang.py +269 -0
- dstack/_internal/proxy/gateway/services/nginx.py +455 -0
- dstack/_internal/proxy/gateway/services/registry.py +426 -0
- dstack/_internal/proxy/gateway/services/server_client.py +95 -0
- dstack/_internal/proxy/gateway/services/stats.py +170 -0
- dstack/_internal/proxy/gateway/testing/__init__.py +0 -0
- dstack/_internal/proxy/gateway/testing/common.py +13 -0
- dstack/_internal/proxy/lib/__init__.py +0 -0
- dstack/_internal/proxy/lib/auth.py +7 -0
- dstack/_internal/proxy/lib/deps.py +106 -0
- dstack/_internal/proxy/lib/errors.py +14 -0
- dstack/_internal/proxy/lib/models.py +112 -0
- dstack/_internal/proxy/lib/repo.py +27 -0
- dstack/_internal/proxy/lib/routers/__init__.py +0 -0
- dstack/_internal/proxy/lib/routers/model_proxy.py +102 -0
- dstack/_internal/proxy/lib/schemas/__init__.py +0 -0
- dstack/_internal/proxy/lib/schemas/model_proxy.py +77 -0
- dstack/_internal/proxy/lib/services/__init__.py +0 -0
- dstack/_internal/proxy/lib/services/model_proxy/__init__.py +0 -0
- dstack/_internal/proxy/lib/services/model_proxy/clients/__init__.py +0 -0
- dstack/_internal/proxy/lib/services/model_proxy/clients/base.py +18 -0
- dstack/_internal/proxy/lib/services/model_proxy/clients/openai.py +67 -0
- dstack/_internal/proxy/lib/services/model_proxy/clients/tgi.py +208 -0
- dstack/_internal/proxy/lib/services/model_proxy/model_proxy.py +23 -0
- dstack/_internal/proxy/lib/services/service_connection.py +160 -0
- dstack/_internal/proxy/lib/testing/__init__.py +0 -0
- dstack/_internal/proxy/lib/testing/auth.py +11 -0
- dstack/_internal/proxy/lib/testing/common.py +51 -0
- dstack/_internal/server/__init__.py +0 -0
- dstack/_internal/server/alembic.ini +100 -0
- dstack/_internal/server/app.py +432 -0
- dstack/_internal/server/background/__init__.py +142 -0
- dstack/_internal/server/background/tasks/__init__.py +0 -0
- dstack/_internal/server/background/tasks/common.py +24 -0
- dstack/_internal/server/background/tasks/process_compute_groups.py +167 -0
- dstack/_internal/server/background/tasks/process_events.py +17 -0
- dstack/_internal/server/background/tasks/process_fleets.py +289 -0
- dstack/_internal/server/background/tasks/process_gateways.py +188 -0
- dstack/_internal/server/background/tasks/process_idle_volumes.py +145 -0
- dstack/_internal/server/background/tasks/process_instances.py +1186 -0
- dstack/_internal/server/background/tasks/process_metrics.py +172 -0
- dstack/_internal/server/background/tasks/process_placement_groups.py +104 -0
- dstack/_internal/server/background/tasks/process_probes.py +164 -0
- dstack/_internal/server/background/tasks/process_prometheus_metrics.py +150 -0
- dstack/_internal/server/background/tasks/process_running_jobs.py +1238 -0
- dstack/_internal/server/background/tasks/process_runs.py +842 -0
- dstack/_internal/server/background/tasks/process_submitted_jobs.py +1106 -0
- dstack/_internal/server/background/tasks/process_terminating_jobs.py +108 -0
- dstack/_internal/server/background/tasks/process_volumes.py +129 -0
- dstack/_internal/server/compatibility/__init__.py +0 -0
- dstack/_internal/server/compatibility/common.py +20 -0
- dstack/_internal/server/compatibility/gpus.py +22 -0
- dstack/_internal/server/db.py +127 -0
- dstack/_internal/server/deps.py +19 -0
- dstack/_internal/server/main.py +4 -0
- dstack/_internal/server/migrations/__init__.py +0 -0
- dstack/_internal/server/migrations/env.py +112 -0
- dstack/_internal/server/migrations/script.py.mako +28 -0
- dstack/_internal/server/migrations/versions/006512f572b4_add_projects_original_name.py +38 -0
- dstack/_internal/server/migrations/versions/065588ec72b8_add_vultr_to_backendtype_enum.py +81 -0
- dstack/_internal/server/migrations/versions/06e977bc61c7_add_usermodel_deleted_and_original_name.py +45 -0
- dstack/_internal/server/migrations/versions/0e33559e16ed_update_instancestatus.py +64 -0
- dstack/_internal/server/migrations/versions/112753bc17dd_remove_nullable_fields.py +50 -0
- dstack/_internal/server/migrations/versions/1338b788b612_reverse_job_instance_relationship.py +71 -0
- dstack/_internal/server/migrations/versions/14f2cb002fc2_add_jobmodel_removed_flag.py +44 -0
- dstack/_internal/server/migrations/versions/1a48dfe44a40_rework_termination_handling.py +42 -0
- dstack/_internal/server/migrations/versions/1aa9638ad963_added_email_index.py +31 -0
- dstack/_internal/server/migrations/versions/1e3fb39ef74b_add_remote_connection_details.py +26 -0
- dstack/_internal/server/migrations/versions/1e76fb0dde87_add_jobmodel_inactivity_secs.py +32 -0
- dstack/_internal/server/migrations/versions/20166748b60c_add_jobmodel_disconnected_at.py +100 -0
- dstack/_internal/server/migrations/versions/22d74df9897e_add_events_and_event_targets.py +99 -0
- dstack/_internal/server/migrations/versions/23e01c56279a_make_blob_nullable.py +32 -0
- dstack/_internal/server/migrations/versions/2498ab323443_add_fleetmodel_consolidation_attempt_.py +44 -0
- dstack/_internal/server/migrations/versions/252d3743b641_.py +40 -0
- dstack/_internal/server/migrations/versions/25479f540245_add_probes.py +43 -0
- dstack/_internal/server/migrations/versions/27d3e55759fa_add_pools.py +152 -0
- dstack/_internal/server/migrations/versions/29826f417010_remove_instancemodel_retry_policy.py +34 -0
- dstack/_internal/server/migrations/versions/29c08c6a8cb3_.py +36 -0
- dstack/_internal/server/migrations/versions/35e90e1b0d3e_add_rolling_deployment_fields.py +42 -0
- dstack/_internal/server/migrations/versions/35f732ee4cf5_add_projectmodel_is_public.py +39 -0
- dstack/_internal/server/migrations/versions/3cf77fb8bcf1_store_repo_clone_url.py +85 -0
- dstack/_internal/server/migrations/versions/3d7f6c2ec000_add_jobmodel_registered.py +28 -0
- dstack/_internal/server/migrations/versions/3dbdce90d0e0_fix_code_uq_constraint.py +33 -0
- dstack/_internal/server/migrations/versions/48ad3ecbaea2_do_not_delete_projects_and_runs.py +46 -0
- dstack/_internal/server/migrations/versions/4ae1a5b0e7f1_add_run_list_index.py +34 -0
- dstack/_internal/server/migrations/versions/4b4319398164_introduce_runs_processing.py +144 -0
- dstack/_internal/server/migrations/versions/50dd7ea98639_index_status_columns.py +55 -0
- dstack/_internal/server/migrations/versions/51d45659d574_add_instancemodel_blocks_fields.py +43 -0
- dstack/_internal/server/migrations/versions/54a77e19c64c_add_manager_project_role.py +67 -0
- dstack/_internal/server/migrations/versions/555138b1f77f_change_instancemodel_for_asynchronous_.py +61 -0
- dstack/_internal/server/migrations/versions/58aa5162dcc3_add_gatewaymodel_configuration.py +32 -0
- dstack/_internal/server/migrations/versions/5ad8debc8fe6_fixes_for_psql.py +329 -0
- dstack/_internal/server/migrations/versions/5ec538b70e71_replace_instansestatus.py +31 -0
- dstack/_internal/server/migrations/versions/5f1707c525d2_add_filearchivemodel.py +39 -0
- dstack/_internal/server/migrations/versions/5fd659afca82_add_ix_instances_fleet_id.py +31 -0
- dstack/_internal/server/migrations/versions/60e444118b6d_add_jobprometheusmetrics.py +40 -0
- dstack/_internal/server/migrations/versions/63c3f19cb184_add_jobterminationreason_inactivity_.py +83 -0
- dstack/_internal/server/migrations/versions/644b8a114187_add_secretmodel.py +49 -0
- dstack/_internal/server/migrations/versions/686fb8341ea5_add_user_emails.py +32 -0
- dstack/_internal/server/migrations/versions/6c1a9d6530ee_add_jobmodel_exit_status.py +26 -0
- dstack/_internal/server/migrations/versions/706e0acc3a7d_add_runmodel_desired_replica_counts.py +26 -0
- dstack/_internal/server/migrations/versions/710e5b3fac8f_add_encryption.py +54 -0
- dstack/_internal/server/migrations/versions/728b1488b1b4_add_instance_health.py +50 -0
- dstack/_internal/server/migrations/versions/74a1f55209bd_store_enums_as_strings.py +484 -0
- dstack/_internal/server/migrations/versions/7b24b1c8eba7_add_instancemodel_last_processed_at.py +68 -0
- dstack/_internal/server/migrations/versions/7ba3b59d7ca6_add_runmodel_resubmission_attempt.py +35 -0
- dstack/_internal/server/migrations/versions/7bc2586e8b9e_make_instancemodel_pool_id_optional.py +36 -0
- dstack/_internal/server/migrations/versions/7d1ec2b920ac_add_computegroupmodel.py +91 -0
- dstack/_internal/server/migrations/versions/803c7e9ed85d_add_jobmodel_job_runtime_data.py +32 -0
- dstack/_internal/server/migrations/versions/82b32a135ea2_.py +58 -0
- dstack/_internal/server/migrations/versions/866ec1d67184_replace_retrypolicy_limit_with_.py +93 -0
- dstack/_internal/server/migrations/versions/903c91e24634_add_instances_termination_reason_message.py +34 -0
- dstack/_internal/server/migrations/versions/91a12fff6c76_add_repocredsmodel.py +43 -0
- dstack/_internal/server/migrations/versions/91ac5e543037_extend_repos_creds_column.py +36 -0
- dstack/_internal/server/migrations/versions/98cd9c8b5927_add_volumemodel.py +73 -0
- dstack/_internal/server/migrations/versions/98d1b92988bc_add_jobterminationreason_terminated_due_.py +140 -0
- dstack/_internal/server/migrations/versions/99b4c8c954ea_add_termination_reason_message.py +71 -0
- dstack/_internal/server/migrations/versions/9eea6af28e10_added_fail_reason_for_instancemodel.py +36 -0
- dstack/_internal/server/migrations/versions/__init__.py +0 -0
- dstack/_internal/server/migrations/versions/a060e2440936_.py +206 -0
- dstack/_internal/server/migrations/versions/a751ef183f27_move_attachment_data_to_volumes_.py +34 -0
- dstack/_internal/server/migrations/versions/a7b46c073fa1_add_placementgroupmodel.py +58 -0
- dstack/_internal/server/migrations/versions/afbc600ff2b2_add_created_at_to_usermodel_and_.py +102 -0
- dstack/_internal/server/migrations/versions/b4d6ad60db08_add_instancemodel_unreachable.py +37 -0
- dstack/_internal/server/migrations/versions/b88d55c2a07d_replace_instancestatus_ready.py +21 -0
- dstack/_internal/server/migrations/versions/bc8ca4a505c6_store_backendtype_as_string.py +171 -0
- dstack/_internal/server/migrations/versions/bca2fdf130bf_add_runmodel_priority.py +34 -0
- dstack/_internal/server/migrations/versions/bfba43f6def2_.py +32 -0
- dstack/_internal/server/migrations/versions/c00090eaef21_support_fleets.py +108 -0
- dstack/_internal/server/migrations/versions/c154eece89da_add_fields_for_async_gateway_creation.py +74 -0
- dstack/_internal/server/migrations/versions/c20626d03cfb_add_jobmetricspoint.py +43 -0
- dstack/_internal/server/migrations/versions/c48df7985d57_add_instance_termination_retries.py +38 -0
- dstack/_internal/server/migrations/versions/c83d45f9a971_replace_string_with_text.py +150 -0
- dstack/_internal/server/migrations/versions/d0bb68e48b9f_add_project_owners_and_quotas.py +106 -0
- dstack/_internal/server/migrations/versions/d3e8af4786fa_gateway_compute_flag_deleted.py +34 -0
- dstack/_internal/server/migrations/versions/d4d9dc26cf58_add_ix_jobs_run_id.py +31 -0
- dstack/_internal/server/migrations/versions/d5863798bf41_add_volumemodel_last_job_processed_at.py +40 -0
- dstack/_internal/server/migrations/versions/d6b11105f659_add_usermodel_active.py +36 -0
- dstack/_internal/server/migrations/versions/da574e93fee0_add_jobmodel_volumes_detached_at.py +40 -0
- dstack/_internal/server/migrations/versions/dfffd6a1165c_add_fields_for_gateways_behind_alb.py +36 -0
- dstack/_internal/server/migrations/versions/e2d08cd1b8d9_add_jobmodel_fleet.py +41 -0
- dstack/_internal/server/migrations/versions/e3b7db07727f_add_gatewaycomputemodel_app_updated_at.py +61 -0
- dstack/_internal/server/migrations/versions/e6391ca6a264_separate_gateways_from_compute.py +72 -0
- dstack/_internal/server/migrations/versions/ea60480f82bb_add_membermodel_member_num.py +32 -0
- dstack/_internal/server/migrations/versions/ec02a26a256c_add_runmodel_next_triggered_at.py +38 -0
- dstack/_internal/server/migrations/versions/ed0ca30e13bb_migrate_instancestatus_provisioning.py +29 -0
- dstack/_internal/server/migrations/versions/fe72c4de8376_add_gateways.py +81 -0
- dstack/_internal/server/migrations/versions/ff1d94f65b08_user_ssh_key.py +34 -0
- dstack/_internal/server/migrations/versions/ffa99edd1988_add_jobterminationreason_max_duration_.py +81 -0
- dstack/_internal/server/models.py +930 -0
- dstack/_internal/server/routers/__init__.py +0 -0
- dstack/_internal/server/routers/auth.py +34 -0
- dstack/_internal/server/routers/backends.py +142 -0
- dstack/_internal/server/routers/events.py +60 -0
- dstack/_internal/server/routers/files.py +68 -0
- dstack/_internal/server/routers/fleets.py +202 -0
- dstack/_internal/server/routers/gateways.py +109 -0
- dstack/_internal/server/routers/gpus.py +32 -0
- dstack/_internal/server/routers/instances.py +77 -0
- dstack/_internal/server/routers/logs.py +34 -0
- dstack/_internal/server/routers/metrics.py +82 -0
- dstack/_internal/server/routers/projects.py +205 -0
- dstack/_internal/server/routers/prometheus.py +35 -0
- dstack/_internal/server/routers/repos.py +118 -0
- dstack/_internal/server/routers/runs.py +216 -0
- dstack/_internal/server/routers/secrets.py +86 -0
- dstack/_internal/server/routers/server.py +19 -0
- dstack/_internal/server/routers/users.py +158 -0
- dstack/_internal/server/routers/volumes.py +122 -0
- dstack/_internal/server/schemas/__init__.py +0 -0
- dstack/_internal/server/schemas/auth.py +83 -0
- dstack/_internal/server/schemas/backends.py +16 -0
- dstack/_internal/server/schemas/common.py +9 -0
- dstack/_internal/server/schemas/events.py +211 -0
- dstack/_internal/server/schemas/files.py +5 -0
- dstack/_internal/server/schemas/fleets.py +49 -0
- dstack/_internal/server/schemas/gateways.py +31 -0
- dstack/_internal/server/schemas/gpus.py +26 -0
- dstack/_internal/server/schemas/health/__init__.py +0 -0
- dstack/_internal/server/schemas/health/dcgm.py +56 -0
- dstack/_internal/server/schemas/instances.py +47 -0
- dstack/_internal/server/schemas/logs.py +17 -0
- dstack/_internal/server/schemas/projects.py +81 -0
- dstack/_internal/server/schemas/repos.py +24 -0
- dstack/_internal/server/schemas/runner.py +269 -0
- dstack/_internal/server/schemas/runs.py +66 -0
- dstack/_internal/server/schemas/secrets.py +16 -0
- dstack/_internal/server/schemas/users.py +72 -0
- dstack/_internal/server/schemas/volumes.py +29 -0
- dstack/_internal/server/security/__init__.py +0 -0
- dstack/_internal/server/security/permissions.py +251 -0
- dstack/_internal/server/services/__init__.py +0 -0
- dstack/_internal/server/services/auth.py +77 -0
- dstack/_internal/server/services/backends/__init__.py +404 -0
- dstack/_internal/server/services/backends/handlers.py +105 -0
- dstack/_internal/server/services/compute_groups.py +22 -0
- dstack/_internal/server/services/config.py +279 -0
- dstack/_internal/server/services/docker.py +162 -0
- dstack/_internal/server/services/encryption/__init__.py +102 -0
- dstack/_internal/server/services/encryption/keys/__init__.py +0 -0
- dstack/_internal/server/services/encryption/keys/aes.py +68 -0
- dstack/_internal/server/services/encryption/keys/base.py +19 -0
- dstack/_internal/server/services/encryption/keys/identity.py +28 -0
- dstack/_internal/server/services/events.py +477 -0
- dstack/_internal/server/services/files.py +91 -0
- dstack/_internal/server/services/fleets.py +1224 -0
- dstack/_internal/server/services/gateways/__init__.py +686 -0
- dstack/_internal/server/services/gateways/client.py +209 -0
- dstack/_internal/server/services/gateways/connection.py +139 -0
- dstack/_internal/server/services/gateways/pool.py +58 -0
- dstack/_internal/server/services/gpus.py +387 -0
- dstack/_internal/server/services/instances.py +731 -0
- dstack/_internal/server/services/jobs/__init__.py +840 -0
- dstack/_internal/server/services/jobs/configurators/__init__.py +0 -0
- dstack/_internal/server/services/jobs/configurators/base.py +469 -0
- dstack/_internal/server/services/jobs/configurators/dev.py +69 -0
- dstack/_internal/server/services/jobs/configurators/extensions/__init__.py +0 -0
- dstack/_internal/server/services/jobs/configurators/extensions/base.py +15 -0
- dstack/_internal/server/services/jobs/configurators/extensions/cursor.py +42 -0
- dstack/_internal/server/services/jobs/configurators/extensions/vscode.py +42 -0
- dstack/_internal/server/services/jobs/configurators/extensions/windsurf.py +43 -0
- dstack/_internal/server/services/jobs/configurators/service.py +28 -0
- dstack/_internal/server/services/jobs/configurators/task.py +39 -0
- dstack/_internal/server/services/locking.py +187 -0
- dstack/_internal/server/services/logging.py +29 -0
- dstack/_internal/server/services/logs/__init__.py +122 -0
- dstack/_internal/server/services/logs/aws.py +373 -0
- dstack/_internal/server/services/logs/base.py +47 -0
- dstack/_internal/server/services/logs/filelog.py +261 -0
- dstack/_internal/server/services/logs/fluentbit.py +329 -0
- dstack/_internal/server/services/logs/gcp.py +181 -0
- dstack/_internal/server/services/metrics.py +172 -0
- dstack/_internal/server/services/offers.py +249 -0
- dstack/_internal/server/services/permissions.py +37 -0
- dstack/_internal/server/services/placement.py +234 -0
- dstack/_internal/server/services/plugins.py +109 -0
- dstack/_internal/server/services/probes.py +10 -0
- dstack/_internal/server/services/projects.py +835 -0
- dstack/_internal/server/services/prometheus/__init__.py +0 -0
- dstack/_internal/server/services/prometheus/client_metrics.py +55 -0
- dstack/_internal/server/services/prometheus/custom_metrics.py +327 -0
- dstack/_internal/server/services/proxy/__init__.py +3 -0
- dstack/_internal/server/services/proxy/auth.py +12 -0
- dstack/_internal/server/services/proxy/deps.py +18 -0
- dstack/_internal/server/services/proxy/repo.py +189 -0
- dstack/_internal/server/services/proxy/routers/__init__.py +0 -0
- dstack/_internal/server/services/proxy/routers/service_proxy.py +49 -0
- dstack/_internal/server/services/proxy/services/__init__.py +0 -0
- dstack/_internal/server/services/proxy/services/service_proxy.py +135 -0
- dstack/_internal/server/services/repos.py +362 -0
- dstack/_internal/server/services/requirements/__init__.py +0 -0
- dstack/_internal/server/services/requirements/combine.py +260 -0
- dstack/_internal/server/services/resources.py +21 -0
- dstack/_internal/server/services/runner/__init__.py +0 -0
- dstack/_internal/server/services/runner/client.py +646 -0
- dstack/_internal/server/services/runner/ssh.py +128 -0
- dstack/_internal/server/services/runs/__init__.py +1026 -0
- dstack/_internal/server/services/runs/plan.py +703 -0
- dstack/_internal/server/services/runs/replicas.py +317 -0
- dstack/_internal/server/services/runs/spec.py +191 -0
- dstack/_internal/server/services/secrets.py +245 -0
- dstack/_internal/server/services/services/__init__.py +345 -0
- dstack/_internal/server/services/services/autoscalers.py +140 -0
- dstack/_internal/server/services/services/options.py +53 -0
- dstack/_internal/server/services/ssh.py +67 -0
- dstack/_internal/server/services/storage/__init__.py +37 -0
- dstack/_internal/server/services/storage/base.py +48 -0
- dstack/_internal/server/services/storage/gcs.py +66 -0
- dstack/_internal/server/services/storage/s3.py +69 -0
- dstack/_internal/server/services/users.py +461 -0
- dstack/_internal/server/services/volumes.py +496 -0
- dstack/_internal/server/settings.py +161 -0
- dstack/_internal/server/statics/00a6e1fb461ed2929fb9.png +0 -0
- dstack/_internal/server/statics/0cae4d9f0a36034984a7.png +0 -0
- dstack/_internal/server/statics/391de232cc0e30cae513.png +0 -0
- dstack/_internal/server/statics/4e0eead8c1a73689ef9d.svg +1 -0
- dstack/_internal/server/statics/544afa2f63428c2235b0.png +0 -0
- dstack/_internal/server/statics/54a4f50f74c6b9381530.svg +7 -0
- dstack/_internal/server/statics/68dd1360a7d2611e0132.svg +4 -0
- dstack/_internal/server/statics/69544b4c81973b54a66f.png +0 -0
- dstack/_internal/server/statics/77a8b02b17af19e39266.png +0 -0
- dstack/_internal/server/statics/83a93a8871c219104367.svg +9 -0
- dstack/_internal/server/statics/8f28bb8e9999e5e6a48b.svg +4 -0
- dstack/_internal/server/statics/9124086961ab8c366bc4.svg +9 -0
- dstack/_internal/server/statics/9a9ebaeb54b025dbac0a.svg +5 -0
- dstack/_internal/server/statics/a3428392dc534f3b15c4.svg +7 -0
- dstack/_internal/server/statics/ae22625574d69361f72c.png +0 -0
- dstack/_internal/server/statics/assets/android-chrome-144x144.png +0 -0
- dstack/_internal/server/statics/assets/android-chrome-192x192.png +0 -0
- dstack/_internal/server/statics/assets/android-chrome-256x256.png +0 -0
- dstack/_internal/server/statics/assets/android-chrome-36x36.png +0 -0
- dstack/_internal/server/statics/assets/android-chrome-384x384.png +0 -0
- dstack/_internal/server/statics/assets/android-chrome-48x48.png +0 -0
- dstack/_internal/server/statics/assets/android-chrome-512x512.png +0 -0
- dstack/_internal/server/statics/assets/android-chrome-72x72.png +0 -0
- dstack/_internal/server/statics/assets/android-chrome-96x96.png +0 -0
- dstack/_internal/server/statics/assets/apple-touch-icon-1024x1024.png +0 -0
- dstack/_internal/server/statics/assets/apple-touch-icon-114x114.png +0 -0
- dstack/_internal/server/statics/assets/apple-touch-icon-120x120.png +0 -0
- dstack/_internal/server/statics/assets/apple-touch-icon-144x144.png +0 -0
- dstack/_internal/server/statics/assets/apple-touch-icon-152x152.png +0 -0
- dstack/_internal/server/statics/assets/apple-touch-icon-167x167.png +0 -0
- dstack/_internal/server/statics/assets/apple-touch-icon-180x180.png +0 -0
- dstack/_internal/server/statics/assets/apple-touch-icon-57x57.png +0 -0
- dstack/_internal/server/statics/assets/apple-touch-icon-60x60.png +0 -0
- dstack/_internal/server/statics/assets/apple-touch-icon-72x72.png +0 -0
- dstack/_internal/server/statics/assets/apple-touch-icon-76x76.png +0 -0
- dstack/_internal/server/statics/assets/apple-touch-icon-precomposed.png +0 -0
- dstack/_internal/server/statics/assets/apple-touch-icon.png +0 -0
- dstack/_internal/server/statics/assets/apple-touch-startup-image-1125x2436.png +0 -0
- dstack/_internal/server/statics/assets/apple-touch-startup-image-1136x640.png +0 -0
- dstack/_internal/server/statics/assets/apple-touch-startup-image-1170x2532.png +0 -0
- dstack/_internal/server/statics/assets/apple-touch-startup-image-1179x2556.png +0 -0
- dstack/_internal/server/statics/assets/apple-touch-startup-image-1242x2208.png +0 -0
- dstack/_internal/server/statics/assets/apple-touch-startup-image-1242x2688.png +0 -0
- dstack/_internal/server/statics/assets/apple-touch-startup-image-1284x2778.png +0 -0
- dstack/_internal/server/statics/assets/apple-touch-startup-image-1290x2796.png +0 -0
- dstack/_internal/server/statics/assets/apple-touch-startup-image-1334x750.png +0 -0
- dstack/_internal/server/statics/assets/apple-touch-startup-image-1488x2266.png +0 -0
- dstack/_internal/server/statics/assets/apple-touch-startup-image-1536x2048.png +0 -0
- dstack/_internal/server/statics/assets/apple-touch-startup-image-1620x2160.png +0 -0
- dstack/_internal/server/statics/assets/apple-touch-startup-image-1640x2160.png +0 -0
- dstack/_internal/server/statics/assets/apple-touch-startup-image-1668x2224.png +0 -0
- dstack/_internal/server/statics/assets/apple-touch-startup-image-1668x2388.png +0 -0
- dstack/_internal/server/statics/assets/apple-touch-startup-image-1792x828.png +0 -0
- dstack/_internal/server/statics/assets/apple-touch-startup-image-2048x1536.png +0 -0
- dstack/_internal/server/statics/assets/apple-touch-startup-image-2048x2732.png +0 -0
- dstack/_internal/server/statics/assets/apple-touch-startup-image-2160x1620.png +0 -0
- dstack/_internal/server/statics/assets/apple-touch-startup-image-2160x1640.png +0 -0
- dstack/_internal/server/statics/assets/apple-touch-startup-image-2208x1242.png +0 -0
- dstack/_internal/server/statics/assets/apple-touch-startup-image-2224x1668.png +0 -0
- dstack/_internal/server/statics/assets/apple-touch-startup-image-2266x1488.png +0 -0
- dstack/_internal/server/statics/assets/apple-touch-startup-image-2388x1668.png +0 -0
- dstack/_internal/server/statics/assets/apple-touch-startup-image-2436x1125.png +0 -0
- dstack/_internal/server/statics/assets/apple-touch-startup-image-2532x1170.png +0 -0
- dstack/_internal/server/statics/assets/apple-touch-startup-image-2556x1179.png +0 -0
- dstack/_internal/server/statics/assets/apple-touch-startup-image-2688x1242.png +0 -0
- dstack/_internal/server/statics/assets/apple-touch-startup-image-2732x2048.png +0 -0
- dstack/_internal/server/statics/assets/apple-touch-startup-image-2778x1284.png +0 -0
- dstack/_internal/server/statics/assets/apple-touch-startup-image-2796x1290.png +0 -0
- dstack/_internal/server/statics/assets/apple-touch-startup-image-640x1136.png +0 -0
- dstack/_internal/server/statics/assets/apple-touch-startup-image-750x1334.png +0 -0
- dstack/_internal/server/statics/assets/apple-touch-startup-image-828x1792.png +0 -0
- dstack/_internal/server/statics/assets/browserconfig.xml +12 -0
- dstack/_internal/server/statics/assets/favicon-16x16.png +0 -0
- dstack/_internal/server/statics/assets/favicon-32x32.png +0 -0
- dstack/_internal/server/statics/assets/favicon-48x48.png +0 -0
- dstack/_internal/server/statics/assets/favicon.ico +0 -0
- dstack/{dashboard/statics/assets/manifest.json → _internal/server/statics/assets/manifest.webmanifest} +18 -9
- dstack/_internal/server/statics/assets/mstile-144x144.png +0 -0
- dstack/_internal/server/statics/assets/mstile-150x150.png +0 -0
- dstack/_internal/server/statics/assets/mstile-310x150.png +0 -0
- dstack/_internal/server/statics/assets/mstile-310x310.png +0 -0
- dstack/_internal/server/statics/assets/mstile-70x70.png +0 -0
- dstack/_internal/server/statics/assets/yandex-browser-50x50.png +0 -0
- dstack/_internal/server/statics/b7ae68f44193474fc578.png +0 -0
- dstack/_internal/server/statics/d2f008c75b2b5b191f3f.png +0 -0
- dstack/_internal/server/statics/d44c33e1b92e05c379fd.png +0 -0
- dstack/_internal/server/statics/dd43ff0552815179d7ab.png +0 -0
- dstack/_internal/server/statics/dd4e7166c0b9aac197d7.png +0 -0
- dstack/_internal/server/statics/e30b27916930d43d2271.png +0 -0
- dstack/_internal/server/statics/e467d7d60aae81ab198b.svg +6 -0
- dstack/_internal/server/statics/eb9b344b73818fe2b71a.png +0 -0
- dstack/_internal/server/statics/f517dd626eb964120de0.png +0 -0
- dstack/_internal/server/statics/f958aecddee5d8e3222c.png +0 -0
- dstack/_internal/server/statics/index.html +3 -0
- dstack/_internal/server/statics/logo-notext.svg +116 -0
- dstack/_internal/server/statics/main-2e6967bad9f29395eea6.css +3 -0
- dstack/_internal/server/statics/main-7dc0f6d20b8b41659acc.js +155547 -0
- dstack/_internal/server/statics/main-7dc0f6d20b8b41659acc.js.map +1 -0
- dstack/{dashboard → _internal/server}/statics/manifest.json +2 -2
- dstack/_internal/server/statics/static/media/entraID.d65d1f3e9486a8e56d24fc07b3230885.svg +9 -0
- dstack/_internal/server/statics/static/media/google.b194b06fafd0a52aeb566922160ea514.svg +1 -0
- dstack/{dashboard/statics/static/media/logo.f9d7170678f68f796e270698633770ec.svg → _internal/server/statics/static/media/logo.f602feeb138844eda97c8cb641461448.svg} +8 -6
- dstack/_internal/server/statics/static/media/okta.12f178e6873a1100965f2a4dbd18fcec.svg +2 -0
- dstack/_internal/server/statics/static/media/theme.3994c817bb7dda191c1c9640dee0bf42.svg +3 -0
- dstack/_internal/server/testing/__init__.py +0 -0
- dstack/_internal/server/testing/common.py +1220 -0
- dstack/_internal/server/testing/conf.py +53 -0
- dstack/_internal/server/testing/matchers.py +31 -0
- dstack/_internal/server/utils/__init__.py +0 -0
- dstack/_internal/server/utils/common.py +55 -0
- dstack/_internal/server/utils/logging.py +51 -0
- dstack/_internal/server/utils/provisioning.py +368 -0
- dstack/_internal/server/utils/routers.py +166 -0
- dstack/_internal/server/utils/sentry_utils.py +24 -0
- dstack/_internal/settings.py +49 -0
- dstack/_internal/utils/__init__.py +0 -0
- dstack/_internal/utils/common.py +318 -0
- dstack/_internal/utils/cron.py +5 -0
- dstack/_internal/utils/crypto.py +40 -0
- dstack/_internal/utils/env.py +88 -0
- dstack/_internal/utils/event_loop.py +30 -0
- dstack/_internal/utils/files.py +69 -0
- dstack/_internal/utils/gpu.py +59 -0
- dstack/_internal/utils/hash.py +31 -0
- dstack/_internal/utils/interpolator.py +91 -0
- dstack/_internal/utils/json_schema.py +11 -0
- dstack/_internal/utils/json_utils.py +54 -0
- dstack/_internal/utils/logging.py +5 -0
- dstack/_internal/utils/nested_list.py +47 -0
- dstack/_internal/utils/network.py +50 -0
- dstack/_internal/utils/path.py +57 -0
- dstack/_internal/utils/random_names.py +258 -0
- dstack/_internal/utils/ssh.py +346 -0
- dstack/_internal/utils/tags.py +42 -0
- dstack/_internal/utils/typing.py +14 -0
- dstack/_internal/utils/version.py +22 -0
- dstack/api/__init__.py +46 -0
- dstack/api/_public/__init__.py +96 -0
- dstack/api/_public/backends.py +42 -0
- dstack/api/_public/common.py +5 -0
- dstack/api/_public/repos.py +202 -0
- dstack/api/_public/runs.py +714 -0
- dstack/api/server/__init__.py +206 -0
- dstack/api/server/_auth.py +30 -0
- dstack/api/server/_backends.py +38 -0
- dstack/api/server/_events.py +64 -0
- dstack/api/server/_files.py +18 -0
- dstack/api/server/_fleets.py +82 -0
- dstack/api/server/_gateways.py +54 -0
- dstack/api/server/_gpus.py +27 -0
- dstack/api/server/_group.py +22 -0
- dstack/api/server/_logs.py +15 -0
- dstack/api/server/_metrics.py +23 -0
- dstack/api/server/_projects.py +124 -0
- dstack/api/server/_repos.py +64 -0
- dstack/api/server/_runs.py +102 -0
- dstack/api/server/_secrets.py +36 -0
- dstack/api/server/_users.py +82 -0
- dstack/api/server/_volumes.py +39 -0
- dstack/api/server/utils.py +34 -0
- dstack/api/utils.py +105 -0
- dstack/core/__init__.py +0 -0
- dstack/plugins/__init__.py +8 -0
- dstack/plugins/_base.py +72 -0
- dstack/plugins/_models.py +8 -0
- dstack/plugins/_utils.py +19 -0
- dstack/plugins/builtin/__init__.py +0 -0
- dstack/plugins/builtin/rest_plugin/__init__.py +18 -0
- dstack/plugins/builtin/rest_plugin/_models.py +48 -0
- dstack/plugins/builtin/rest_plugin/_plugin.py +147 -0
- dstack/version.py +3 -1
- dstack-0.20.7.dist-info/METADATA +519 -0
- dstack-0.20.7.dist-info/RECORD +720 -0
- {dstack-0.0.9.dist-info → dstack-0.20.7.dist-info}/WHEEL +1 -2
- dstack-0.20.7.dist-info/entry_points.txt +2 -0
- dstack-0.20.7.dist-info/licenses/LICENSE.md +353 -0
- dstack/aws/__init__.py +0 -180
- dstack/aws/artifacts.py +0 -111
- dstack/aws/config.py +0 -40
- dstack/aws/jobs.py +0 -245
- dstack/aws/logs.py +0 -186
- dstack/aws/repos.py +0 -137
- dstack/aws/run_names.py +0 -17
- dstack/aws/runners.py +0 -693
- dstack/aws/runs.py +0 -79
- dstack/aws/secrets.py +0 -99
- dstack/aws/tags.py +0 -138
- dstack/backend.py +0 -299
- dstack/cli/app.py +0 -41
- dstack/cli/artifacts.py +0 -87
- dstack/cli/common.py +0 -57
- dstack/cli/config.py +0 -194
- dstack/cli/dashboard.py +0 -26
- dstack/cli/delete.py +0 -49
- dstack/cli/init.py +0 -33
- dstack/cli/logs.py +0 -87
- dstack/cli/main.py +0 -81
- dstack/cli/restart.py +0 -43
- dstack/cli/run.py +0 -223
- dstack/cli/schema.py +0 -46
- dstack/cli/secrets.py +0 -97
- dstack/cli/status.py +0 -140
- dstack/cli/stop.py +0 -53
- dstack/cli/tags.py +0 -100
- dstack/config.py +0 -80
- dstack/dashboard/artifacts.py +0 -26
- dstack/dashboard/logs.py +0 -73
- dstack/dashboard/main.py +0 -45
- dstack/dashboard/repos.py +0 -41
- dstack/dashboard/runs.py +0 -140
- dstack/dashboard/secrets.py +0 -53
- dstack/dashboard/statics/4d6a4e032505c1efd23c.png +0 -0
- dstack/dashboard/statics/7e018c3e5566d7c349a8.png +0 -0
- dstack/dashboard/statics/assets/android-chrome-144x144.png +0 -0
- dstack/dashboard/statics/assets/android-chrome-192x192.png +0 -0
- dstack/dashboard/statics/assets/android-chrome-256x256.png +0 -0
- dstack/dashboard/statics/assets/android-chrome-36x36.png +0 -0
- dstack/dashboard/statics/assets/android-chrome-384x384.png +0 -0
- dstack/dashboard/statics/assets/android-chrome-48x48.png +0 -0
- dstack/dashboard/statics/assets/android-chrome-512x512.png +0 -0
- dstack/dashboard/statics/assets/android-chrome-72x72.png +0 -0
- dstack/dashboard/statics/assets/android-chrome-96x96.png +0 -0
- dstack/dashboard/statics/assets/apple-touch-icon-1024x1024.png +0 -0
- dstack/dashboard/statics/assets/apple-touch-icon-114x114.png +0 -0
- dstack/dashboard/statics/assets/apple-touch-icon-120x120.png +0 -0
- dstack/dashboard/statics/assets/apple-touch-icon-144x144.png +0 -0
- dstack/dashboard/statics/assets/apple-touch-icon-152x152.png +0 -0
- dstack/dashboard/statics/assets/apple-touch-icon-167x167.png +0 -0
- dstack/dashboard/statics/assets/apple-touch-icon-180x180.png +0 -0
- dstack/dashboard/statics/assets/apple-touch-icon-57x57.png +0 -0
- dstack/dashboard/statics/assets/apple-touch-icon-60x60.png +0 -0
- dstack/dashboard/statics/assets/apple-touch-icon-72x72.png +0 -0
- dstack/dashboard/statics/assets/apple-touch-icon-76x76.png +0 -0
- dstack/dashboard/statics/assets/apple-touch-icon-precomposed.png +0 -0
- dstack/dashboard/statics/assets/apple-touch-icon.png +0 -0
- dstack/dashboard/statics/assets/apple-touch-startup-image-1125x2436.png +0 -0
- dstack/dashboard/statics/assets/apple-touch-startup-image-1136x640.png +0 -0
- dstack/dashboard/statics/assets/apple-touch-startup-image-1242x2208.png +0 -0
- dstack/dashboard/statics/assets/apple-touch-startup-image-1242x2688.png +0 -0
- dstack/dashboard/statics/assets/apple-touch-startup-image-1334x750.png +0 -0
- dstack/dashboard/statics/assets/apple-touch-startup-image-1536x2048.png +0 -0
- dstack/dashboard/statics/assets/apple-touch-startup-image-1620x2160.png +0 -0
- dstack/dashboard/statics/assets/apple-touch-startup-image-1668x2224.png +0 -0
- dstack/dashboard/statics/assets/apple-touch-startup-image-1668x2388.png +0 -0
- dstack/dashboard/statics/assets/apple-touch-startup-image-1792x828.png +0 -0
- dstack/dashboard/statics/assets/apple-touch-startup-image-2048x1536.png +0 -0
- dstack/dashboard/statics/assets/apple-touch-startup-image-2048x2732.png +0 -0
- dstack/dashboard/statics/assets/apple-touch-startup-image-2160x1620.png +0 -0
- dstack/dashboard/statics/assets/apple-touch-startup-image-2208x1242.png +0 -0
- dstack/dashboard/statics/assets/apple-touch-startup-image-2224x1668.png +0 -0
- dstack/dashboard/statics/assets/apple-touch-startup-image-2388x1668.png +0 -0
- dstack/dashboard/statics/assets/apple-touch-startup-image-2436x1125.png +0 -0
- dstack/dashboard/statics/assets/apple-touch-startup-image-2688x1242.png +0 -0
- dstack/dashboard/statics/assets/apple-touch-startup-image-2732x2048.png +0 -0
- dstack/dashboard/statics/assets/apple-touch-startup-image-640x1136.png +0 -0
- dstack/dashboard/statics/assets/apple-touch-startup-image-750x1334.png +0 -0
- dstack/dashboard/statics/assets/apple-touch-startup-image-828x1792.png +0 -0
- dstack/dashboard/statics/assets/browserconfig.xml +0 -15
- dstack/dashboard/statics/assets/coast-228x228.png +0 -0
- dstack/dashboard/statics/assets/favicon-16x16.png +0 -0
- dstack/dashboard/statics/assets/favicon-32x32.png +0 -0
- dstack/dashboard/statics/assets/favicon-48x48.png +0 -0
- dstack/dashboard/statics/assets/favicon.ico +0 -0
- dstack/dashboard/statics/assets/firefox_app_128x128.png +0 -0
- dstack/dashboard/statics/assets/firefox_app_512x512.png +0 -0
- dstack/dashboard/statics/assets/firefox_app_60x60.png +0 -0
- dstack/dashboard/statics/assets/manifest.webapp +0 -14
- dstack/dashboard/statics/assets/mstile-144x144.png +0 -0
- dstack/dashboard/statics/assets/mstile-150x150.png +0 -0
- dstack/dashboard/statics/assets/mstile-310x150.png +0 -0
- dstack/dashboard/statics/assets/mstile-310x310.png +0 -0
- dstack/dashboard/statics/assets/mstile-70x70.png +0 -0
- dstack/dashboard/statics/assets/yandex-browser-50x50.png +0 -0
- dstack/dashboard/statics/d0f71e48806e25d72553.png +0 -0
- dstack/dashboard/statics/index.html +0 -7
- dstack/dashboard/statics/main-1d87e34eb0454da8ebb4.js +0 -3
- dstack/dashboard/statics/main-1d87e34eb0454da8ebb4.js.LICENSE.txt +0 -102
- dstack/dashboard/statics/main-1d87e34eb0454da8ebb4.js.map +0 -1
- dstack/dashboard/statics/main.css +0 -5058
- dstack/dashboard/statics/splash_thumbnail.png +0 -0
- dstack/dashboard/statics/static/media/check.3f68ffc787a15c0476793a6d18ecb71a.svg +0 -3
- dstack/dashboard/statics/static/media/chevron-down.bfd8f22c4a5db4d443e76bca3b02f334.svg +0 -3
- dstack/dashboard/statics/static/media/chevron-up.bade0c5d82d741cead615813264140c9.svg +0 -3
- dstack/dashboard/statics/static/media/clock.583b744f29b9d143718a55e7c35fe38e.svg +0 -3
- dstack/dashboard/statics/static/media/close.a8bb9e47361b03a3b5084dad676ba1da.svg +0 -3
- dstack/dashboard/statics/static/media/content-copy.73f5f2a175094757758e315243a4111e.svg +0 -3
- dstack/dashboard/statics/static/media/delete-outline.6a8abf4e4f9cb777781967efd56efe9b.svg +0 -3
- dstack/dashboard/statics/static/media/dots-vertical.82fc618192e0c7dc4d615ff93269246a.svg +0 -3
- dstack/dashboard/statics/static/media/earth.1ad57c7f59f4be5c8bb2fa00439c3149.svg +0 -3
- dstack/dashboard/statics/static/media/email.320bc3af24a5f1bb41ebd85f66a5dd70.svg +0 -3
- dstack/dashboard/statics/static/media/external-link.99b88e699c15afb820a1779d9a2261ed.svg +0 -3
- dstack/dashboard/statics/static/media/eye-off-outline.5b4afb7ad624a44dd307518ff93d1faa.svg +0 -3
- dstack/dashboard/statics/static/media/eye-outline.ca41708feaaed1edb15c5fff021fbafe.svg +0 -3
- dstack/dashboard/statics/static/media/file-download-outline.3634b41923ba79b297ff294ef898661c.svg +0 -3
- dstack/dashboard/statics/static/media/folder-outline.33378387af61821dd1207e4b2d061a07.svg +0 -3
- dstack/dashboard/statics/static/media/github-circle.1bb85d171c31a3c2eebad07319377171.svg +0 -3
- dstack/dashboard/statics/static/media/infinity.915f92939afc0a37f94adba211ceb172.svg +0 -3
- dstack/dashboard/statics/static/media/layers.b4b02cea267a617d7aa44c2719250c89.svg +0 -3
- dstack/dashboard/statics/static/media/linkedin.1c52fae553eee54397f0e63a79455a5e.svg +0 -3
- dstack/dashboard/statics/static/media/loading.e466be7b2c1f0ac9e7e51ca929d0e37d.svg +0 -3
- dstack/dashboard/statics/static/media/lock.4a4c7768d0fa60c716609ddc483470ef.svg +0 -3
- dstack/dashboard/statics/static/media/magnify.0c803314d039d21f3cb1504ccd1437a4.svg +0 -3
- dstack/dashboard/statics/static/media/mark.3f68ffc787a15c0476793a6d18ecb71a.svg +0 -3
- dstack/dashboard/statics/static/media/menu-close.3ee84714181017c6ff837830297c8437.svg +0 -3
- dstack/dashboard/statics/static/media/menu.922f81e0972fbcbb5adcd8def20c86a3.svg +0 -3
- dstack/dashboard/statics/static/media/pencil.f706a3b9dcbff4959a91bf72e1e6324f.svg +0 -3
- dstack/dashboard/statics/static/media/refresh.a80edb948e98b322cd73b67814a57a48.svg +0 -3
- dstack/dashboard/statics/static/media/shape-plus.63b093c7f4b44c3def774f30fcfbceca.svg +0 -3
- dstack/dashboard/statics/static/media/slack.ec2fca99c6b944950ac65404ddd26880.svg +0 -4
- dstack/dashboard/statics/static/media/small-logo.b9cc8d09f646a553e65fa336dafd8b10.svg +0 -116
- dstack/dashboard/statics/static/media/source-branch.b8d22cfc42a7bed81f0fc08130818e85.svg +0 -3
- dstack/dashboard/statics/static/media/source-commit.be2bb53c081b9b6836adffccc0b8d3e6.svg +0 -3
- dstack/dashboard/statics/static/media/stop.11488ff1437ad929476be8924a3b7075.svg +0 -3
- dstack/dashboard/statics/static/media/tag-minus.15680a815b0b8d027e973c84832c05e6.svg +0 -3
- dstack/dashboard/statics/static/media/tag-outline.19b0bf86a8afd7d6d9c716e9a91d94ca.svg +0 -3
- dstack/dashboard/statics/static/media/twitter.4af18861c84a2f3044c7546b55d5739c.svg +0 -3
- dstack/dashboard/tags.py +0 -119
- dstack/jobs.py +0 -255
- dstack/providers/__init__.py +0 -316
- dstack/providers/_python/main.py +0 -88
- dstack/providers/_tensorboard/main.py +0 -93
- dstack/providers/_torchrun/main.py +0 -121
- dstack/providers/bash/main.py +0 -90
- dstack/providers/code/main.py +0 -95
- dstack/providers/docker/main.py +0 -79
- dstack/providers/lab/main.py +0 -95
- dstack/providers/notebook/main.py +0 -90
- dstack/random_name.py +0 -29
- dstack/repo.py +0 -135
- dstack/runners.py +0 -35
- dstack/util.py +0 -15
- dstack-0.0.9.dist-info/METADATA +0 -176
- dstack-0.0.9.dist-info/RECORD +0 -179
- dstack-0.0.9.dist-info/entry_points.txt +0 -3
- dstack-0.0.9.dist-info/top_level.txt +0 -2
- tests/test_config.py +0 -70
- /dstack/{cli → _internal}/__init__.py +0 -0
- /dstack/{dashboard → _internal/cli}/__init__.py +0 -0
- /dstack/{providers/_python → _internal/cli/models}/__init__.py +0 -0
- /dstack/{providers/_tensorboard → _internal/cli/services}/__init__.py +0 -0
- /dstack/{providers/_torchrun → _internal/cli/utils}/__init__.py +0 -0
- /dstack/{providers/bash → _internal/core}/__init__.py +0 -0
- /dstack/{providers/code → _internal/core/backends}/__init__.py +0 -0
- /dstack/{providers/docker → _internal/core/backends/aws}/__init__.py +0 -0
- /dstack/{providers/lab → _internal/core/backends/azure}/__init__.py +0 -0
- /dstack/{providers/notebook → _internal/core/backends/base}/__init__.py +0 -0
- {tests → dstack/_internal/core/backends/cloudrift}/__init__.py +0 -0
- /dstack/{dashboard → _internal/server}/statics/assets/yandex-browser-manifest.json +0 -0
- /dstack/{dashboard → _internal/server}/statics/robots.txt +0 -0
|
@@ -0,0 +1,1220 @@
|
|
|
1
|
+
import json
|
|
2
|
+
import uuid
|
|
3
|
+
from collections.abc import Callable
|
|
4
|
+
from contextlib import contextmanager
|
|
5
|
+
from datetime import datetime, timezone
|
|
6
|
+
from typing import Dict, List, Literal, Optional, Union
|
|
7
|
+
from uuid import UUID
|
|
8
|
+
|
|
9
|
+
import gpuhunt
|
|
10
|
+
from sqlalchemy import delete, select
|
|
11
|
+
from sqlalchemy.ext.asyncio import AsyncSession
|
|
12
|
+
from sqlalchemy.orm import joinedload
|
|
13
|
+
|
|
14
|
+
from dstack._internal.core.backends.base.compute import (
|
|
15
|
+
Compute,
|
|
16
|
+
ComputeWithCreateInstanceSupport,
|
|
17
|
+
ComputeWithGatewaySupport,
|
|
18
|
+
ComputeWithGroupProvisioningSupport,
|
|
19
|
+
ComputeWithMultinodeSupport,
|
|
20
|
+
ComputeWithPlacementGroupSupport,
|
|
21
|
+
ComputeWithPrivateGatewaySupport,
|
|
22
|
+
ComputeWithPrivilegedSupport,
|
|
23
|
+
ComputeWithReservationSupport,
|
|
24
|
+
ComputeWithVolumeSupport,
|
|
25
|
+
)
|
|
26
|
+
from dstack._internal.core.models.backends.base import BackendType
|
|
27
|
+
from dstack._internal.core.models.common import NetworkMode
|
|
28
|
+
from dstack._internal.core.models.compute_groups import (
|
|
29
|
+
ComputeGroupProvisioningData,
|
|
30
|
+
ComputeGroupStatus,
|
|
31
|
+
)
|
|
32
|
+
from dstack._internal.core.models.configurations import (
|
|
33
|
+
AnyRunConfiguration,
|
|
34
|
+
DevEnvironmentConfiguration,
|
|
35
|
+
)
|
|
36
|
+
from dstack._internal.core.models.envs import Env
|
|
37
|
+
from dstack._internal.core.models.fleets import (
|
|
38
|
+
FleetConfiguration,
|
|
39
|
+
FleetNodesSpec,
|
|
40
|
+
FleetSpec,
|
|
41
|
+
FleetStatus,
|
|
42
|
+
InstanceGroupPlacement,
|
|
43
|
+
SSHHostParams,
|
|
44
|
+
SSHParams,
|
|
45
|
+
)
|
|
46
|
+
from dstack._internal.core.models.gateways import GatewayComputeConfiguration, GatewayStatus
|
|
47
|
+
from dstack._internal.core.models.health import HealthStatus
|
|
48
|
+
from dstack._internal.core.models.instances import (
|
|
49
|
+
Disk,
|
|
50
|
+
Gpu,
|
|
51
|
+
InstanceAvailability,
|
|
52
|
+
InstanceConfiguration,
|
|
53
|
+
InstanceOfferWithAvailability,
|
|
54
|
+
InstanceStatus,
|
|
55
|
+
InstanceType,
|
|
56
|
+
RemoteConnectionInfo,
|
|
57
|
+
Resources,
|
|
58
|
+
SSHKey,
|
|
59
|
+
)
|
|
60
|
+
from dstack._internal.core.models.placement import (
|
|
61
|
+
PlacementGroupConfiguration,
|
|
62
|
+
PlacementGroupProvisioningData,
|
|
63
|
+
PlacementStrategy,
|
|
64
|
+
)
|
|
65
|
+
from dstack._internal.core.models.profiles import (
|
|
66
|
+
DEFAULT_FLEET_TERMINATION_IDLE_TIME,
|
|
67
|
+
Profile,
|
|
68
|
+
TerminationPolicy,
|
|
69
|
+
)
|
|
70
|
+
from dstack._internal.core.models.repos.base import RepoType
|
|
71
|
+
from dstack._internal.core.models.repos.local import LocalRunRepoData
|
|
72
|
+
from dstack._internal.core.models.resources import CPUSpec, Memory, ResourcesSpec
|
|
73
|
+
from dstack._internal.core.models.runs import (
|
|
74
|
+
JobProvisioningData,
|
|
75
|
+
JobRuntimeData,
|
|
76
|
+
JobStatus,
|
|
77
|
+
JobTerminationReason,
|
|
78
|
+
Requirements,
|
|
79
|
+
RunSpec,
|
|
80
|
+
RunStatus,
|
|
81
|
+
RunTerminationReason,
|
|
82
|
+
)
|
|
83
|
+
from dstack._internal.core.models.users import GlobalRole
|
|
84
|
+
from dstack._internal.core.models.volumes import (
|
|
85
|
+
Volume,
|
|
86
|
+
VolumeAttachment,
|
|
87
|
+
VolumeConfiguration,
|
|
88
|
+
VolumeProvisioningData,
|
|
89
|
+
VolumeStatus,
|
|
90
|
+
)
|
|
91
|
+
from dstack._internal.server.models import (
|
|
92
|
+
BackendModel,
|
|
93
|
+
ComputeGroupModel,
|
|
94
|
+
DecryptedString,
|
|
95
|
+
EventModel,
|
|
96
|
+
FileArchiveModel,
|
|
97
|
+
FleetModel,
|
|
98
|
+
GatewayComputeModel,
|
|
99
|
+
GatewayModel,
|
|
100
|
+
InstanceHealthCheckModel,
|
|
101
|
+
InstanceModel,
|
|
102
|
+
JobMetricsPoint,
|
|
103
|
+
JobModel,
|
|
104
|
+
JobPrometheusMetrics,
|
|
105
|
+
PlacementGroupModel,
|
|
106
|
+
ProbeModel,
|
|
107
|
+
ProjectModel,
|
|
108
|
+
RepoCredsModel,
|
|
109
|
+
RepoModel,
|
|
110
|
+
RunModel,
|
|
111
|
+
SecretModel,
|
|
112
|
+
UserModel,
|
|
113
|
+
VolumeAttachmentModel,
|
|
114
|
+
VolumeModel,
|
|
115
|
+
)
|
|
116
|
+
from dstack._internal.server.services.jobs import get_job_specs_from_run_spec
|
|
117
|
+
from dstack._internal.server.services.permissions import (
|
|
118
|
+
DefaultPermissions,
|
|
119
|
+
get_default_permissions,
|
|
120
|
+
set_default_permissions,
|
|
121
|
+
)
|
|
122
|
+
from dstack._internal.server.services.users import get_token_hash
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
def get_auth_headers(token: Union[DecryptedString, str]) -> Dict:
|
|
126
|
+
if isinstance(token, DecryptedString):
|
|
127
|
+
token = token.get_plaintext_or_error()
|
|
128
|
+
return {"Authorization": f"Bearer {token}"}
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
async def create_user(
|
|
132
|
+
session: AsyncSession,
|
|
133
|
+
name: str = "test_user",
|
|
134
|
+
created_at: datetime = datetime(2023, 1, 2, 3, 4, tzinfo=timezone.utc),
|
|
135
|
+
global_role: GlobalRole = GlobalRole.ADMIN,
|
|
136
|
+
token: Optional[str] = None,
|
|
137
|
+
email: Optional[str] = None,
|
|
138
|
+
ssh_public_key: Optional[str] = None,
|
|
139
|
+
ssh_private_key: Optional[str] = None,
|
|
140
|
+
active: bool = True,
|
|
141
|
+
deleted: bool = False,
|
|
142
|
+
) -> UserModel:
|
|
143
|
+
if token is None:
|
|
144
|
+
token = str(uuid.uuid4())
|
|
145
|
+
user = UserModel(
|
|
146
|
+
name=name,
|
|
147
|
+
created_at=created_at,
|
|
148
|
+
global_role=global_role,
|
|
149
|
+
token=DecryptedString(plaintext=token),
|
|
150
|
+
token_hash=get_token_hash(token),
|
|
151
|
+
email=email,
|
|
152
|
+
ssh_public_key=ssh_public_key,
|
|
153
|
+
ssh_private_key=ssh_private_key,
|
|
154
|
+
active=active,
|
|
155
|
+
deleted=deleted,
|
|
156
|
+
)
|
|
157
|
+
session.add(user)
|
|
158
|
+
await session.commit()
|
|
159
|
+
return user
|
|
160
|
+
|
|
161
|
+
|
|
162
|
+
async def create_project(
|
|
163
|
+
session: AsyncSession,
|
|
164
|
+
owner: Optional[UserModel] = None,
|
|
165
|
+
name: str = "test_project",
|
|
166
|
+
created_at: datetime = datetime(2023, 1, 2, 3, 4, tzinfo=timezone.utc),
|
|
167
|
+
ssh_private_key: str = "",
|
|
168
|
+
ssh_public_key: str = "",
|
|
169
|
+
is_public: bool = False,
|
|
170
|
+
) -> ProjectModel:
|
|
171
|
+
if owner is None:
|
|
172
|
+
owner = await create_user(session=session, name="test_owner")
|
|
173
|
+
project = ProjectModel(
|
|
174
|
+
name=name,
|
|
175
|
+
owner_id=owner.id,
|
|
176
|
+
created_at=created_at,
|
|
177
|
+
ssh_private_key=ssh_private_key,
|
|
178
|
+
ssh_public_key=ssh_public_key,
|
|
179
|
+
is_public=is_public,
|
|
180
|
+
)
|
|
181
|
+
session.add(project)
|
|
182
|
+
await session.commit()
|
|
183
|
+
return project
|
|
184
|
+
|
|
185
|
+
|
|
186
|
+
async def create_backend(
|
|
187
|
+
session: AsyncSession,
|
|
188
|
+
project_id: UUID,
|
|
189
|
+
backend_type: BackendType = BackendType.AWS,
|
|
190
|
+
config: Optional[Dict] = None,
|
|
191
|
+
auth: Optional[Dict] = None,
|
|
192
|
+
) -> BackendModel:
|
|
193
|
+
if config is None:
|
|
194
|
+
config = {
|
|
195
|
+
"regions": ["eu-west-1"],
|
|
196
|
+
}
|
|
197
|
+
if auth is None:
|
|
198
|
+
auth = {
|
|
199
|
+
"type": "access_key",
|
|
200
|
+
"access_key": "test_access_key",
|
|
201
|
+
"secret_key": "test_secret_key",
|
|
202
|
+
}
|
|
203
|
+
backend = BackendModel(
|
|
204
|
+
project_id=project_id,
|
|
205
|
+
type=backend_type,
|
|
206
|
+
config=json.dumps(config),
|
|
207
|
+
auth=DecryptedString(plaintext=json.dumps(auth)),
|
|
208
|
+
)
|
|
209
|
+
session.add(backend)
|
|
210
|
+
await session.commit()
|
|
211
|
+
return backend
|
|
212
|
+
|
|
213
|
+
|
|
214
|
+
async def create_repo(
|
|
215
|
+
session: AsyncSession,
|
|
216
|
+
project_id: UUID,
|
|
217
|
+
repo_name: str = "test_repo",
|
|
218
|
+
repo_type: RepoType = RepoType.REMOTE,
|
|
219
|
+
info: Optional[Dict] = None,
|
|
220
|
+
creds: Optional[Dict] = None,
|
|
221
|
+
) -> RepoModel:
|
|
222
|
+
if info is None:
|
|
223
|
+
info = {
|
|
224
|
+
"repo_type": "remote",
|
|
225
|
+
"repo_name": "dstack",
|
|
226
|
+
}
|
|
227
|
+
repo = RepoModel(
|
|
228
|
+
project_id=project_id,
|
|
229
|
+
name=repo_name,
|
|
230
|
+
type=repo_type,
|
|
231
|
+
info=json.dumps(info),
|
|
232
|
+
creds=json.dumps(creds) if creds is not None else None,
|
|
233
|
+
)
|
|
234
|
+
session.add(repo)
|
|
235
|
+
await session.commit()
|
|
236
|
+
return repo
|
|
237
|
+
|
|
238
|
+
|
|
239
|
+
async def create_repo_creds(
|
|
240
|
+
session: AsyncSession,
|
|
241
|
+
repo_id: UUID,
|
|
242
|
+
user_id: UUID,
|
|
243
|
+
creds: Optional[dict] = None,
|
|
244
|
+
) -> RepoCredsModel:
|
|
245
|
+
if creds is None:
|
|
246
|
+
creds = {
|
|
247
|
+
"clone_url": "https://github.com/dstackai/dstack.git",
|
|
248
|
+
"private_key": None,
|
|
249
|
+
"oauth_token": "test_token",
|
|
250
|
+
}
|
|
251
|
+
repo_creds = RepoCredsModel(
|
|
252
|
+
repo_id=repo_id,
|
|
253
|
+
user_id=user_id,
|
|
254
|
+
creds=DecryptedString(plaintext=json.dumps(creds)),
|
|
255
|
+
)
|
|
256
|
+
session.add(repo_creds)
|
|
257
|
+
await session.commit()
|
|
258
|
+
return repo_creds
|
|
259
|
+
|
|
260
|
+
|
|
261
|
+
async def create_file_archive(
|
|
262
|
+
session: AsyncSession,
|
|
263
|
+
user_id: UUID,
|
|
264
|
+
blob_hash: str = "blob_hash",
|
|
265
|
+
blob: bytes = b"blob_content",
|
|
266
|
+
) -> FileArchiveModel:
|
|
267
|
+
archive = FileArchiveModel(
|
|
268
|
+
user_id=user_id,
|
|
269
|
+
blob_hash=blob_hash,
|
|
270
|
+
blob=blob,
|
|
271
|
+
)
|
|
272
|
+
session.add(archive)
|
|
273
|
+
await session.commit()
|
|
274
|
+
return archive
|
|
275
|
+
|
|
276
|
+
|
|
277
|
+
def get_run_spec(
|
|
278
|
+
repo_id: str,
|
|
279
|
+
run_name: str = "test-run",
|
|
280
|
+
configuration_path: str = "dstack.yaml",
|
|
281
|
+
profile: Union[Profile, Callable[[], Profile], None] = lambda: Profile(name="default"),
|
|
282
|
+
configuration: Optional[AnyRunConfiguration] = None,
|
|
283
|
+
ssh_key_pub: Optional[str] = "user_ssh_key",
|
|
284
|
+
) -> RunSpec:
|
|
285
|
+
if callable(profile):
|
|
286
|
+
profile = profile()
|
|
287
|
+
return RunSpec(
|
|
288
|
+
run_name=run_name,
|
|
289
|
+
repo_id=repo_id,
|
|
290
|
+
repo_data=LocalRunRepoData(repo_dir="/"),
|
|
291
|
+
repo_code_hash=None,
|
|
292
|
+
configuration_path=configuration_path,
|
|
293
|
+
configuration=configuration or DevEnvironmentConfiguration(ide="vscode"),
|
|
294
|
+
profile=profile,
|
|
295
|
+
ssh_key_pub=ssh_key_pub,
|
|
296
|
+
)
|
|
297
|
+
|
|
298
|
+
|
|
299
|
+
async def create_run(
|
|
300
|
+
session: AsyncSession,
|
|
301
|
+
project: ProjectModel,
|
|
302
|
+
repo: RepoModel,
|
|
303
|
+
user: UserModel,
|
|
304
|
+
fleet: Optional[FleetModel] = None,
|
|
305
|
+
run_name: str = "test-run",
|
|
306
|
+
status: RunStatus = RunStatus.SUBMITTED,
|
|
307
|
+
termination_reason: Optional[RunTerminationReason] = None,
|
|
308
|
+
submitted_at: datetime = datetime(2023, 1, 2, 3, 4, tzinfo=timezone.utc),
|
|
309
|
+
run_spec: Optional[RunSpec] = None,
|
|
310
|
+
run_id: Optional[UUID] = None,
|
|
311
|
+
deleted: bool = False,
|
|
312
|
+
priority: int = 0,
|
|
313
|
+
deployment_num: int = 0,
|
|
314
|
+
resubmission_attempt: int = 0,
|
|
315
|
+
next_triggered_at: Optional[datetime] = None,
|
|
316
|
+
) -> RunModel:
|
|
317
|
+
if run_spec is None:
|
|
318
|
+
run_spec = get_run_spec(
|
|
319
|
+
run_name=run_name,
|
|
320
|
+
repo_id=repo.name,
|
|
321
|
+
)
|
|
322
|
+
if run_id is None:
|
|
323
|
+
run_id = uuid.uuid4()
|
|
324
|
+
run = RunModel(
|
|
325
|
+
id=run_id,
|
|
326
|
+
deleted=deleted,
|
|
327
|
+
project_id=project.id,
|
|
328
|
+
repo_id=repo.id,
|
|
329
|
+
user_id=user.id,
|
|
330
|
+
fleet_id=fleet.id if fleet else None,
|
|
331
|
+
submitted_at=submitted_at,
|
|
332
|
+
run_name=run_name,
|
|
333
|
+
status=status,
|
|
334
|
+
termination_reason=termination_reason,
|
|
335
|
+
run_spec=run_spec.json(),
|
|
336
|
+
last_processed_at=submitted_at,
|
|
337
|
+
jobs=[],
|
|
338
|
+
priority=priority,
|
|
339
|
+
deployment_num=deployment_num,
|
|
340
|
+
desired_replica_count=1,
|
|
341
|
+
resubmission_attempt=resubmission_attempt,
|
|
342
|
+
next_triggered_at=next_triggered_at,
|
|
343
|
+
)
|
|
344
|
+
session.add(run)
|
|
345
|
+
await session.commit()
|
|
346
|
+
return run
|
|
347
|
+
|
|
348
|
+
|
|
349
|
+
async def create_job(
|
|
350
|
+
session: AsyncSession,
|
|
351
|
+
run: RunModel,
|
|
352
|
+
fleet: Optional[FleetModel] = None,
|
|
353
|
+
submission_num: int = 0,
|
|
354
|
+
status: JobStatus = JobStatus.SUBMITTED,
|
|
355
|
+
submitted_at: datetime = datetime(2023, 1, 2, 3, 4, tzinfo=timezone.utc),
|
|
356
|
+
last_processed_at: datetime = datetime(2023, 1, 2, 3, 4, tzinfo=timezone.utc),
|
|
357
|
+
termination_reason: Optional[JobTerminationReason] = None,
|
|
358
|
+
job_provisioning_data: Optional[JobProvisioningData] = None,
|
|
359
|
+
job_runtime_data: Optional[JobRuntimeData] = None,
|
|
360
|
+
instance: Optional[InstanceModel] = None,
|
|
361
|
+
job_num: int = 0,
|
|
362
|
+
replica_num: int = 0,
|
|
363
|
+
deployment_num: Optional[int] = None,
|
|
364
|
+
instance_assigned: bool = False,
|
|
365
|
+
disconnected_at: Optional[datetime] = None,
|
|
366
|
+
registered: bool = False,
|
|
367
|
+
waiting_master_job: Optional[bool] = None,
|
|
368
|
+
) -> JobModel:
|
|
369
|
+
if deployment_num is None:
|
|
370
|
+
deployment_num = run.deployment_num
|
|
371
|
+
run_spec = RunSpec.parse_raw(run.run_spec)
|
|
372
|
+
job_spec = (
|
|
373
|
+
await get_job_specs_from_run_spec(run_spec=run_spec, secrets={}, replica_num=replica_num)
|
|
374
|
+
)[0]
|
|
375
|
+
job_spec.job_num = job_num
|
|
376
|
+
job = JobModel(
|
|
377
|
+
project_id=run.project_id,
|
|
378
|
+
fleet=fleet,
|
|
379
|
+
run_id=run.id,
|
|
380
|
+
run_name=run.run_name,
|
|
381
|
+
job_num=job_num,
|
|
382
|
+
job_name=run.run_name + f"-{job_num}-{replica_num}",
|
|
383
|
+
replica_num=replica_num,
|
|
384
|
+
deployment_num=deployment_num,
|
|
385
|
+
submission_num=submission_num,
|
|
386
|
+
submitted_at=submitted_at,
|
|
387
|
+
last_processed_at=last_processed_at,
|
|
388
|
+
status=status,
|
|
389
|
+
termination_reason=termination_reason,
|
|
390
|
+
job_spec_data=job_spec.json(),
|
|
391
|
+
job_provisioning_data=job_provisioning_data.json() if job_provisioning_data else None,
|
|
392
|
+
job_runtime_data=job_runtime_data.json() if job_runtime_data else None,
|
|
393
|
+
instance=instance,
|
|
394
|
+
instance_assigned=instance_assigned,
|
|
395
|
+
used_instance_id=instance.id if instance is not None else None,
|
|
396
|
+
disconnected_at=disconnected_at,
|
|
397
|
+
probes=[],
|
|
398
|
+
registered=registered,
|
|
399
|
+
waiting_master_job=waiting_master_job,
|
|
400
|
+
)
|
|
401
|
+
session.add(job)
|
|
402
|
+
await session.commit()
|
|
403
|
+
return job
|
|
404
|
+
|
|
405
|
+
|
|
406
|
+
def get_job_provisioning_data(
|
|
407
|
+
dockerized: bool = False,
|
|
408
|
+
backend: BackendType = BackendType.AWS,
|
|
409
|
+
region: str = "us-east-1",
|
|
410
|
+
gpu_count: int = 0,
|
|
411
|
+
gpu_memory_gib: float = 16,
|
|
412
|
+
gpu_name: str = "T4",
|
|
413
|
+
cpu_count: int = 1,
|
|
414
|
+
memory_gib: float = 0.5,
|
|
415
|
+
spot: bool = False,
|
|
416
|
+
hostname: str = "127.0.0.4",
|
|
417
|
+
internal_ip: Optional[str] = "127.0.0.4",
|
|
418
|
+
price: float = 10.5,
|
|
419
|
+
instance_type: Optional[InstanceType] = None,
|
|
420
|
+
) -> JobProvisioningData:
|
|
421
|
+
gpus = [
|
|
422
|
+
Gpu(
|
|
423
|
+
name=gpu_name,
|
|
424
|
+
memory_mib=int(gpu_memory_gib * 1024),
|
|
425
|
+
vendor=gpuhunt.AcceleratorVendor.NVIDIA,
|
|
426
|
+
)
|
|
427
|
+
] * gpu_count
|
|
428
|
+
if instance_type is None:
|
|
429
|
+
instance_type = InstanceType(
|
|
430
|
+
name="instance",
|
|
431
|
+
resources=Resources(
|
|
432
|
+
cpus=cpu_count, memory_mib=int(memory_gib * 1024), spot=spot, gpus=gpus
|
|
433
|
+
),
|
|
434
|
+
)
|
|
435
|
+
return JobProvisioningData(
|
|
436
|
+
backend=backend,
|
|
437
|
+
instance_type=instance_type,
|
|
438
|
+
instance_id="instance_id",
|
|
439
|
+
hostname=hostname,
|
|
440
|
+
internal_ip=internal_ip,
|
|
441
|
+
region=region,
|
|
442
|
+
price=price,
|
|
443
|
+
username="ubuntu",
|
|
444
|
+
ssh_port=22,
|
|
445
|
+
dockerized=dockerized,
|
|
446
|
+
backend_data=None,
|
|
447
|
+
ssh_proxy=None,
|
|
448
|
+
)
|
|
449
|
+
|
|
450
|
+
|
|
451
|
+
def get_job_runtime_data(
|
|
452
|
+
network_mode: str = NetworkMode.HOST,
|
|
453
|
+
cpu: Optional[float] = None,
|
|
454
|
+
gpu: Optional[int] = None,
|
|
455
|
+
memory: Optional[float] = None,
|
|
456
|
+
ports: Optional[dict[int, int]] = None,
|
|
457
|
+
offer: Optional[InstanceOfferWithAvailability] = None,
|
|
458
|
+
volume_names: Optional[list[str]] = None,
|
|
459
|
+
) -> JobRuntimeData:
|
|
460
|
+
return JobRuntimeData(
|
|
461
|
+
network_mode=NetworkMode(network_mode),
|
|
462
|
+
cpu=cpu,
|
|
463
|
+
gpu=gpu,
|
|
464
|
+
memory=Memory(memory) if memory is not None else None,
|
|
465
|
+
ports=ports,
|
|
466
|
+
offer=offer,
|
|
467
|
+
volume_names=volume_names,
|
|
468
|
+
)
|
|
469
|
+
|
|
470
|
+
|
|
471
|
+
def get_compute_group_provisioning_data(
|
|
472
|
+
compute_group_id: str = "test_compute_group",
|
|
473
|
+
compute_group_name: str = "test_compute_group",
|
|
474
|
+
backend: BackendType = BackendType.RUNPOD,
|
|
475
|
+
region: str = "US",
|
|
476
|
+
job_provisioning_datas: Optional[list[JobProvisioningData]] = None,
|
|
477
|
+
backend_data: Optional[str] = None,
|
|
478
|
+
) -> ComputeGroupProvisioningData:
|
|
479
|
+
if job_provisioning_datas is None:
|
|
480
|
+
job_provisioning_datas = []
|
|
481
|
+
return ComputeGroupProvisioningData(
|
|
482
|
+
compute_group_id=compute_group_id,
|
|
483
|
+
compute_group_name=compute_group_name,
|
|
484
|
+
backend=backend,
|
|
485
|
+
region=region,
|
|
486
|
+
job_provisioning_datas=job_provisioning_datas,
|
|
487
|
+
backend_data=backend_data,
|
|
488
|
+
)
|
|
489
|
+
|
|
490
|
+
|
|
491
|
+
async def create_compute_group(
|
|
492
|
+
session: AsyncSession,
|
|
493
|
+
project: ProjectModel,
|
|
494
|
+
fleet: FleetModel,
|
|
495
|
+
status: ComputeGroupStatus = ComputeGroupStatus.RUNNING,
|
|
496
|
+
provisioning_data: Optional[ComputeGroupProvisioningData] = None,
|
|
497
|
+
last_processed_at: datetime = datetime(2023, 1, 2, 3, 4, tzinfo=timezone.utc),
|
|
498
|
+
):
|
|
499
|
+
if provisioning_data is None:
|
|
500
|
+
provisioning_data = get_compute_group_provisioning_data()
|
|
501
|
+
compute_group = ComputeGroupModel(
|
|
502
|
+
project=project,
|
|
503
|
+
fleet=fleet,
|
|
504
|
+
status=status,
|
|
505
|
+
provisioning_data=provisioning_data.json(),
|
|
506
|
+
last_processed_at=last_processed_at,
|
|
507
|
+
)
|
|
508
|
+
session.add(compute_group)
|
|
509
|
+
await session.commit()
|
|
510
|
+
return compute_group
|
|
511
|
+
|
|
512
|
+
|
|
513
|
+
async def create_probe(
|
|
514
|
+
session: AsyncSession,
|
|
515
|
+
job: JobModel,
|
|
516
|
+
probe_num: int = 0,
|
|
517
|
+
due: datetime = datetime(2025, 1, 2, 3, 4, tzinfo=timezone.utc),
|
|
518
|
+
success_streak: int = 0,
|
|
519
|
+
) -> ProbeModel:
|
|
520
|
+
probe = ProbeModel(
|
|
521
|
+
name=f"{job.job_name}-{probe_num}",
|
|
522
|
+
job=job,
|
|
523
|
+
probe_num=probe_num,
|
|
524
|
+
due=due,
|
|
525
|
+
success_streak=success_streak,
|
|
526
|
+
active=True,
|
|
527
|
+
)
|
|
528
|
+
session.add(probe)
|
|
529
|
+
await session.commit()
|
|
530
|
+
return probe
|
|
531
|
+
|
|
532
|
+
|
|
533
|
+
async def create_gateway(
|
|
534
|
+
session: AsyncSession,
|
|
535
|
+
project_id: UUID,
|
|
536
|
+
backend_id: UUID,
|
|
537
|
+
name: str = "test_gateway",
|
|
538
|
+
region: str = "us",
|
|
539
|
+
wildcard_domain: Optional[str] = None,
|
|
540
|
+
gateway_compute_id: Optional[UUID] = None,
|
|
541
|
+
status: Optional[GatewayStatus] = GatewayStatus.SUBMITTED,
|
|
542
|
+
last_processed_at: datetime = datetime(2023, 1, 2, 3, 4, tzinfo=timezone.utc),
|
|
543
|
+
) -> GatewayModel:
|
|
544
|
+
gateway = GatewayModel(
|
|
545
|
+
project_id=project_id,
|
|
546
|
+
backend_id=backend_id,
|
|
547
|
+
name=name,
|
|
548
|
+
region=region,
|
|
549
|
+
wildcard_domain=wildcard_domain,
|
|
550
|
+
gateway_compute_id=gateway_compute_id,
|
|
551
|
+
status=status,
|
|
552
|
+
last_processed_at=last_processed_at,
|
|
553
|
+
)
|
|
554
|
+
session.add(gateway)
|
|
555
|
+
await session.commit()
|
|
556
|
+
return gateway
|
|
557
|
+
|
|
558
|
+
|
|
559
|
+
async def create_gateway_compute(
|
|
560
|
+
session: AsyncSession,
|
|
561
|
+
backend_id: Optional[UUID] = None,
|
|
562
|
+
ip_address: Optional[str] = "1.1.1.1",
|
|
563
|
+
region: str = "us",
|
|
564
|
+
instance_id: Optional[str] = "i-1234567890",
|
|
565
|
+
ssh_private_key: str = "",
|
|
566
|
+
ssh_public_key: str = "",
|
|
567
|
+
) -> GatewayComputeModel:
|
|
568
|
+
gateway_compute = GatewayComputeModel(
|
|
569
|
+
backend_id=backend_id,
|
|
570
|
+
ip_address=ip_address,
|
|
571
|
+
region=region,
|
|
572
|
+
instance_id=instance_id,
|
|
573
|
+
ssh_private_key=ssh_private_key,
|
|
574
|
+
ssh_public_key=ssh_public_key,
|
|
575
|
+
)
|
|
576
|
+
session.add(gateway_compute)
|
|
577
|
+
await session.commit()
|
|
578
|
+
return gateway_compute
|
|
579
|
+
|
|
580
|
+
|
|
581
|
+
def get_gateway_compute_configuration(
|
|
582
|
+
project_name: str = "test-project",
|
|
583
|
+
instance_name: str = "test-instance",
|
|
584
|
+
backend: BackendType = BackendType.AWS,
|
|
585
|
+
region: str = "us",
|
|
586
|
+
public_ip: bool = True,
|
|
587
|
+
) -> GatewayComputeConfiguration:
|
|
588
|
+
return GatewayComputeConfiguration(
|
|
589
|
+
project_name=project_name,
|
|
590
|
+
instance_name=instance_name,
|
|
591
|
+
backend=backend,
|
|
592
|
+
region=region,
|
|
593
|
+
public_ip=public_ip,
|
|
594
|
+
ssh_key_pub="",
|
|
595
|
+
certificate=None,
|
|
596
|
+
)
|
|
597
|
+
|
|
598
|
+
|
|
599
|
+
async def create_fleet(
|
|
600
|
+
session: AsyncSession,
|
|
601
|
+
project: ProjectModel,
|
|
602
|
+
created_at: datetime = datetime(2023, 1, 2, 3, 4, tzinfo=timezone.utc),
|
|
603
|
+
spec: Optional[FleetSpec] = None,
|
|
604
|
+
fleet_id: Optional[UUID] = None,
|
|
605
|
+
status: FleetStatus = FleetStatus.ACTIVE,
|
|
606
|
+
deleted: bool = False,
|
|
607
|
+
name: Optional[str] = None,
|
|
608
|
+
last_processed_at: datetime = datetime(2023, 1, 2, 3, 4, tzinfo=timezone.utc),
|
|
609
|
+
) -> FleetModel:
|
|
610
|
+
if fleet_id is None:
|
|
611
|
+
fleet_id = uuid.uuid4()
|
|
612
|
+
if spec is None:
|
|
613
|
+
spec = get_fleet_spec()
|
|
614
|
+
if name is not None:
|
|
615
|
+
spec.configuration.name = name
|
|
616
|
+
fm = FleetModel(
|
|
617
|
+
id=fleet_id,
|
|
618
|
+
project=project,
|
|
619
|
+
deleted=deleted,
|
|
620
|
+
name=spec.configuration.name,
|
|
621
|
+
status=status,
|
|
622
|
+
created_at=created_at,
|
|
623
|
+
spec=spec.json(),
|
|
624
|
+
instances=[],
|
|
625
|
+
runs=[],
|
|
626
|
+
last_processed_at=last_processed_at,
|
|
627
|
+
)
|
|
628
|
+
session.add(fm)
|
|
629
|
+
await session.commit()
|
|
630
|
+
return fm
|
|
631
|
+
|
|
632
|
+
|
|
633
|
+
def get_fleet_spec(conf: Optional[FleetConfiguration] = None) -> FleetSpec:
|
|
634
|
+
if conf is None:
|
|
635
|
+
conf = get_fleet_configuration()
|
|
636
|
+
return FleetSpec(
|
|
637
|
+
configuration=conf,
|
|
638
|
+
configuration_path="fleet.dstack.yml",
|
|
639
|
+
profile=Profile(),
|
|
640
|
+
)
|
|
641
|
+
|
|
642
|
+
|
|
643
|
+
def get_fleet_configuration(
|
|
644
|
+
name: str = "test-fleet",
|
|
645
|
+
nodes: FleetNodesSpec = FleetNodesSpec(min=1, target=1, max=1),
|
|
646
|
+
placement: Optional[InstanceGroupPlacement] = None,
|
|
647
|
+
) -> FleetConfiguration:
|
|
648
|
+
return FleetConfiguration(
|
|
649
|
+
name=name,
|
|
650
|
+
nodes=nodes,
|
|
651
|
+
placement=placement,
|
|
652
|
+
)
|
|
653
|
+
|
|
654
|
+
|
|
655
|
+
def get_ssh_fleet_configuration(
|
|
656
|
+
name: str = "test-fleet",
|
|
657
|
+
user: str = "ubuntu",
|
|
658
|
+
ssh_key: Optional[SSHKey] = None,
|
|
659
|
+
hosts: Optional[list[Union[SSHHostParams, str]]] = None,
|
|
660
|
+
network: Optional[str] = None,
|
|
661
|
+
placement: Optional[InstanceGroupPlacement] = None,
|
|
662
|
+
) -> FleetConfiguration:
|
|
663
|
+
if ssh_key is None:
|
|
664
|
+
ssh_key = SSHKey(public="", private=get_private_key_string())
|
|
665
|
+
if hosts is None:
|
|
666
|
+
hosts = ["10.0.0.100"]
|
|
667
|
+
ssh_config = SSHParams(
|
|
668
|
+
user=user,
|
|
669
|
+
ssh_key=ssh_key,
|
|
670
|
+
hosts=hosts,
|
|
671
|
+
network=network,
|
|
672
|
+
)
|
|
673
|
+
return FleetConfiguration(
|
|
674
|
+
name=name,
|
|
675
|
+
ssh_config=ssh_config,
|
|
676
|
+
placement=placement,
|
|
677
|
+
)
|
|
678
|
+
|
|
679
|
+
|
|
680
|
+
async def create_instance(
|
|
681
|
+
session: AsyncSession,
|
|
682
|
+
project: ProjectModel,
|
|
683
|
+
fleet: Optional[FleetModel] = None,
|
|
684
|
+
status: InstanceStatus = InstanceStatus.IDLE,
|
|
685
|
+
unreachable: bool = False,
|
|
686
|
+
health_status: HealthStatus = HealthStatus.HEALTHY,
|
|
687
|
+
created_at: datetime = datetime(2023, 1, 2, 3, 4, tzinfo=timezone.utc),
|
|
688
|
+
finished_at: Optional[datetime] = None,
|
|
689
|
+
spot: bool = False,
|
|
690
|
+
profile: Optional[Profile] = None,
|
|
691
|
+
requirements: Optional[Requirements] = None,
|
|
692
|
+
instance_configuration: Optional[InstanceConfiguration] = None,
|
|
693
|
+
instance_id: Optional[UUID] = None,
|
|
694
|
+
job: Optional[JobModel] = None,
|
|
695
|
+
instance_num: int = 0,
|
|
696
|
+
backend: BackendType = BackendType.VERDA,
|
|
697
|
+
termination_policy: Optional[TerminationPolicy] = None,
|
|
698
|
+
termination_idle_time: int = DEFAULT_FLEET_TERMINATION_IDLE_TIME,
|
|
699
|
+
region: str = "eu-west",
|
|
700
|
+
remote_connection_info: Optional[RemoteConnectionInfo] = None,
|
|
701
|
+
offer: Optional[Union[InstanceOfferWithAvailability, Literal["auto"]]] = "auto",
|
|
702
|
+
job_provisioning_data: Optional[Union[JobProvisioningData, Literal["auto"]]] = "auto",
|
|
703
|
+
total_blocks: Optional[int] = 1,
|
|
704
|
+
busy_blocks: int = 0,
|
|
705
|
+
name: str = "test_instance",
|
|
706
|
+
volumes: Optional[List[VolumeModel]] = None,
|
|
707
|
+
price: float = 1.0,
|
|
708
|
+
last_processed_at: datetime = datetime(2023, 1, 2, 3, 4, tzinfo=timezone.utc),
|
|
709
|
+
) -> InstanceModel:
|
|
710
|
+
if instance_id is None:
|
|
711
|
+
instance_id = uuid.uuid4()
|
|
712
|
+
if job_provisioning_data == "auto":
|
|
713
|
+
job_provisioning_data = get_job_provisioning_data(
|
|
714
|
+
dockerized=True,
|
|
715
|
+
backend=backend,
|
|
716
|
+
region=region,
|
|
717
|
+
spot=spot,
|
|
718
|
+
hostname="running_instance.ip",
|
|
719
|
+
internal_ip=None,
|
|
720
|
+
)
|
|
721
|
+
if offer == "auto":
|
|
722
|
+
offer = get_instance_offer_with_availability(
|
|
723
|
+
backend=backend, region=region, spot=spot, price=price
|
|
724
|
+
)
|
|
725
|
+
if profile is None:
|
|
726
|
+
profile = Profile(name="test_name")
|
|
727
|
+
|
|
728
|
+
if requirements is None:
|
|
729
|
+
requirements = Requirements(resources=ResourcesSpec(cpu=CPUSpec.parse("1")))
|
|
730
|
+
|
|
731
|
+
if instance_configuration is None:
|
|
732
|
+
instance_configuration = get_instance_configuration()
|
|
733
|
+
|
|
734
|
+
if volumes is None:
|
|
735
|
+
volumes = []
|
|
736
|
+
volume_attachments = []
|
|
737
|
+
for volume in volumes:
|
|
738
|
+
volume_attachments.append(VolumeAttachmentModel(volume=volume))
|
|
739
|
+
|
|
740
|
+
im = InstanceModel(
|
|
741
|
+
id=instance_id,
|
|
742
|
+
name=name,
|
|
743
|
+
instance_num=instance_num,
|
|
744
|
+
fleet=fleet,
|
|
745
|
+
project=project,
|
|
746
|
+
status=status,
|
|
747
|
+
last_processed_at=last_processed_at,
|
|
748
|
+
unreachable=unreachable,
|
|
749
|
+
health=health_status,
|
|
750
|
+
created_at=created_at,
|
|
751
|
+
started_at=created_at,
|
|
752
|
+
finished_at=finished_at,
|
|
753
|
+
job_provisioning_data=job_provisioning_data.json() if job_provisioning_data else None,
|
|
754
|
+
offer=offer.json() if offer else None,
|
|
755
|
+
price=price,
|
|
756
|
+
region=region,
|
|
757
|
+
backend=backend,
|
|
758
|
+
termination_policy=termination_policy,
|
|
759
|
+
termination_idle_time=termination_idle_time,
|
|
760
|
+
profile=profile.json(),
|
|
761
|
+
requirements=requirements.json(),
|
|
762
|
+
instance_configuration=instance_configuration.json(),
|
|
763
|
+
remote_connection_info=remote_connection_info.json() if remote_connection_info else None,
|
|
764
|
+
volume_attachments=volume_attachments,
|
|
765
|
+
total_blocks=total_blocks,
|
|
766
|
+
busy_blocks=busy_blocks,
|
|
767
|
+
)
|
|
768
|
+
if job:
|
|
769
|
+
im.jobs.append(job)
|
|
770
|
+
session.add(im)
|
|
771
|
+
await session.commit()
|
|
772
|
+
return im
|
|
773
|
+
|
|
774
|
+
|
|
775
|
+
def get_instance_configuration(
|
|
776
|
+
project_name: str = "test-project",
|
|
777
|
+
instance_name: str = "test-instance",
|
|
778
|
+
user: str = "dstack-user",
|
|
779
|
+
) -> InstanceConfiguration:
|
|
780
|
+
return InstanceConfiguration(
|
|
781
|
+
project_name=project_name,
|
|
782
|
+
instance_name=instance_name,
|
|
783
|
+
user=user,
|
|
784
|
+
ssh_keys=[],
|
|
785
|
+
)
|
|
786
|
+
|
|
787
|
+
|
|
788
|
+
def get_instance_offer_with_availability(
|
|
789
|
+
backend: BackendType = BackendType.AWS,
|
|
790
|
+
region: str = "eu-west",
|
|
791
|
+
gpu_count: int = 0,
|
|
792
|
+
gpu_name: str = "T4",
|
|
793
|
+
gpu_memory_gib: float = 16,
|
|
794
|
+
cpu_count: int = 2,
|
|
795
|
+
memory_gib: float = 12,
|
|
796
|
+
disk_gib: float = 100.0,
|
|
797
|
+
spot: bool = False,
|
|
798
|
+
blocks: int = 1,
|
|
799
|
+
total_blocks: int = 1,
|
|
800
|
+
availability_zones: Optional[List[str]] = None,
|
|
801
|
+
price: float = 1.0,
|
|
802
|
+
instance_type: str = "instance",
|
|
803
|
+
availability: InstanceAvailability = InstanceAvailability.AVAILABLE,
|
|
804
|
+
):
|
|
805
|
+
gpus = [
|
|
806
|
+
Gpu(
|
|
807
|
+
name=gpu_name,
|
|
808
|
+
memory_mib=int(gpu_memory_gib * 1024),
|
|
809
|
+
vendor=gpuhunt.AcceleratorVendor.NVIDIA,
|
|
810
|
+
)
|
|
811
|
+
] * gpu_count
|
|
812
|
+
return InstanceOfferWithAvailability(
|
|
813
|
+
backend=backend,
|
|
814
|
+
instance=InstanceType(
|
|
815
|
+
name=instance_type,
|
|
816
|
+
resources=Resources(
|
|
817
|
+
cpus=cpu_count,
|
|
818
|
+
memory_mib=int(memory_gib * 1024),
|
|
819
|
+
gpus=gpus,
|
|
820
|
+
spot=spot,
|
|
821
|
+
disk=Disk(size_mib=int(disk_gib * 1024)),
|
|
822
|
+
description="",
|
|
823
|
+
),
|
|
824
|
+
),
|
|
825
|
+
region=region,
|
|
826
|
+
price=price,
|
|
827
|
+
availability=availability,
|
|
828
|
+
availability_zones=availability_zones,
|
|
829
|
+
blocks=blocks,
|
|
830
|
+
total_blocks=total_blocks,
|
|
831
|
+
)
|
|
832
|
+
|
|
833
|
+
|
|
834
|
+
def get_remote_connection_info(
|
|
835
|
+
host: str = "10.0.0.10",
|
|
836
|
+
port: int = 22,
|
|
837
|
+
ssh_user: str = "ubuntu",
|
|
838
|
+
ssh_keys: Optional[list[SSHKey]] = None,
|
|
839
|
+
env: Optional[Union[Env, dict]] = None,
|
|
840
|
+
):
|
|
841
|
+
if ssh_keys is None:
|
|
842
|
+
ssh_keys = [get_ssh_key()]
|
|
843
|
+
if env is None:
|
|
844
|
+
env = Env()
|
|
845
|
+
elif isinstance(env, dict):
|
|
846
|
+
env = Env.parse_obj(env)
|
|
847
|
+
return RemoteConnectionInfo(
|
|
848
|
+
host=host,
|
|
849
|
+
port=port,
|
|
850
|
+
ssh_user=ssh_user,
|
|
851
|
+
ssh_keys=ssh_keys,
|
|
852
|
+
env=env,
|
|
853
|
+
)
|
|
854
|
+
|
|
855
|
+
|
|
856
|
+
def get_ssh_key() -> SSHKey:
|
|
857
|
+
return SSHKey(
|
|
858
|
+
public="ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIO6mJxVbNtm0zXgMLvByrhXJCmJRveSrJxLB5/OzcyCk",
|
|
859
|
+
private="""
|
|
860
|
+
-----BEGIN OPENSSH PRIVATE KEY-----
|
|
861
|
+
b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAAAMwAAAAtzc2gtZW
|
|
862
|
+
QyNTUxOQAAACDupicVWzbZtM14DC7wcq4VyQpiUb3kqycSwefzs3MgpAAAAJCiWa5Volmu
|
|
863
|
+
VQAAAAtzc2gtZWQyNTUxOQAAACDupicVWzbZtM14DC7wcq4VyQpiUb3kqycSwefzs3MgpA
|
|
864
|
+
AAAEAncHi4AhS6XdMp5Gzd+IMse/4ekyQ54UngByf0Sp0uH+6mJxVbNtm0zXgMLvByrhXJ
|
|
865
|
+
CmJRveSrJxLB5/OzcyCkAAAACWRlZkBkZWZwYwECAwQ=
|
|
866
|
+
-----END OPENSSH PRIVATE KEY-----
|
|
867
|
+
""",
|
|
868
|
+
)
|
|
869
|
+
|
|
870
|
+
|
|
871
|
+
async def create_instance_health_check(
|
|
872
|
+
session: AsyncSession,
|
|
873
|
+
instance: InstanceModel,
|
|
874
|
+
collected_at: datetime = datetime(2023, 1, 2, 3, 4, tzinfo=timezone.utc),
|
|
875
|
+
status: HealthStatus = HealthStatus.HEALTHY,
|
|
876
|
+
response: str = "{}",
|
|
877
|
+
) -> InstanceHealthCheckModel:
|
|
878
|
+
health_check = InstanceHealthCheckModel(
|
|
879
|
+
instance_id=instance.id,
|
|
880
|
+
collected_at=collected_at,
|
|
881
|
+
status=status,
|
|
882
|
+
response=response,
|
|
883
|
+
)
|
|
884
|
+
session.add(health_check)
|
|
885
|
+
await session.commit()
|
|
886
|
+
return health_check
|
|
887
|
+
|
|
888
|
+
|
|
889
|
+
async def create_volume(
|
|
890
|
+
session: AsyncSession,
|
|
891
|
+
project: ProjectModel,
|
|
892
|
+
user: UserModel,
|
|
893
|
+
status: VolumeStatus = VolumeStatus.SUBMITTED,
|
|
894
|
+
created_at: datetime = datetime(2023, 1, 2, 3, 4, tzinfo=timezone.utc),
|
|
895
|
+
last_processed_at: Optional[datetime] = None,
|
|
896
|
+
last_job_processed_at: Optional[datetime] = None,
|
|
897
|
+
configuration: Optional[VolumeConfiguration] = None,
|
|
898
|
+
volume_provisioning_data: Optional[VolumeProvisioningData] = None,
|
|
899
|
+
deleted_at: Optional[datetime] = None,
|
|
900
|
+
backend: BackendType = BackendType.AWS,
|
|
901
|
+
region: str = "eu-west-1",
|
|
902
|
+
) -> VolumeModel:
|
|
903
|
+
if configuration is None:
|
|
904
|
+
configuration = get_volume_configuration(backend=backend, region=region)
|
|
905
|
+
if last_processed_at is None:
|
|
906
|
+
last_processed_at = created_at
|
|
907
|
+
vm = VolumeModel(
|
|
908
|
+
project=project,
|
|
909
|
+
user_id=user.id,
|
|
910
|
+
name=configuration.name,
|
|
911
|
+
status=status,
|
|
912
|
+
created_at=created_at,
|
|
913
|
+
last_processed_at=last_processed_at,
|
|
914
|
+
last_job_processed_at=last_job_processed_at,
|
|
915
|
+
configuration=configuration.json(),
|
|
916
|
+
volume_provisioning_data=volume_provisioning_data.json()
|
|
917
|
+
if volume_provisioning_data
|
|
918
|
+
else None,
|
|
919
|
+
attachments=[],
|
|
920
|
+
deleted_at=deleted_at,
|
|
921
|
+
deleted=True if deleted_at else False,
|
|
922
|
+
)
|
|
923
|
+
session.add(vm)
|
|
924
|
+
await session.commit()
|
|
925
|
+
return vm
|
|
926
|
+
|
|
927
|
+
|
|
928
|
+
def get_volume(
|
|
929
|
+
id_: Optional[UUID] = None,
|
|
930
|
+
name: str = "test_volume",
|
|
931
|
+
user: str = "test_user",
|
|
932
|
+
project_name: str = "test_project",
|
|
933
|
+
configuration: Optional[VolumeConfiguration] = None,
|
|
934
|
+
external: bool = False,
|
|
935
|
+
created_at: datetime = datetime(2023, 1, 2, 3, 4, tzinfo=timezone.utc),
|
|
936
|
+
last_processed_at: datetime = datetime(2023, 1, 2, 3, 4, tzinfo=timezone.utc),
|
|
937
|
+
status: VolumeStatus = VolumeStatus.ACTIVE,
|
|
938
|
+
status_message: Optional[str] = None,
|
|
939
|
+
deleted: bool = False,
|
|
940
|
+
deleted_at: Optional[datetime] = None,
|
|
941
|
+
volume_id: Optional[str] = None,
|
|
942
|
+
provisioning_data: Optional[VolumeProvisioningData] = None,
|
|
943
|
+
attachments: Optional[List[VolumeAttachment]] = None,
|
|
944
|
+
) -> Volume:
|
|
945
|
+
if id_ is None:
|
|
946
|
+
id_ = uuid.uuid4()
|
|
947
|
+
if configuration is None:
|
|
948
|
+
configuration = get_volume_configuration()
|
|
949
|
+
if attachments is None:
|
|
950
|
+
attachments = []
|
|
951
|
+
return Volume(
|
|
952
|
+
id=id_,
|
|
953
|
+
name=name,
|
|
954
|
+
user=user,
|
|
955
|
+
project_name=project_name,
|
|
956
|
+
configuration=configuration,
|
|
957
|
+
external=external,
|
|
958
|
+
created_at=created_at,
|
|
959
|
+
last_processed_at=last_processed_at,
|
|
960
|
+
status=status,
|
|
961
|
+
status_message=status_message,
|
|
962
|
+
deleted=deleted,
|
|
963
|
+
deleted_at=deleted_at,
|
|
964
|
+
volume_id=volume_id,
|
|
965
|
+
provisioning_data=provisioning_data,
|
|
966
|
+
attachments=attachments,
|
|
967
|
+
)
|
|
968
|
+
|
|
969
|
+
|
|
970
|
+
def get_volume_configuration(
|
|
971
|
+
name: str = "test-volume",
|
|
972
|
+
backend: BackendType = BackendType.AWS,
|
|
973
|
+
region: str = "eu-west-1",
|
|
974
|
+
size: Optional[Memory] = Memory(100),
|
|
975
|
+
volume_id: Optional[str] = None,
|
|
976
|
+
auto_cleanup_duration: Optional[Union[str, int]] = None,
|
|
977
|
+
) -> VolumeConfiguration:
|
|
978
|
+
return VolumeConfiguration(
|
|
979
|
+
name=name,
|
|
980
|
+
backend=backend,
|
|
981
|
+
region=region,
|
|
982
|
+
size=size,
|
|
983
|
+
volume_id=volume_id,
|
|
984
|
+
auto_cleanup_duration=auto_cleanup_duration,
|
|
985
|
+
)
|
|
986
|
+
|
|
987
|
+
|
|
988
|
+
def get_volume_provisioning_data(
|
|
989
|
+
volume_id: str = "vol-1234",
|
|
990
|
+
size_gb: int = 100,
|
|
991
|
+
availability_zone: Optional[str] = None,
|
|
992
|
+
price: Optional[float] = 1.0,
|
|
993
|
+
backend_data: Optional[str] = None,
|
|
994
|
+
backend: Optional[BackendType] = None,
|
|
995
|
+
) -> VolumeProvisioningData:
|
|
996
|
+
return VolumeProvisioningData(
|
|
997
|
+
backend=backend,
|
|
998
|
+
volume_id=volume_id,
|
|
999
|
+
size_gb=size_gb,
|
|
1000
|
+
availability_zone=availability_zone,
|
|
1001
|
+
price=price,
|
|
1002
|
+
backend_data=backend_data,
|
|
1003
|
+
)
|
|
1004
|
+
|
|
1005
|
+
|
|
1006
|
+
async def create_placement_group(
|
|
1007
|
+
session: AsyncSession,
|
|
1008
|
+
project: ProjectModel,
|
|
1009
|
+
fleet: FleetModel,
|
|
1010
|
+
name: str = "test-pg",
|
|
1011
|
+
created_at: datetime = datetime(2023, 1, 2, 3, 4, tzinfo=timezone.utc),
|
|
1012
|
+
configuration: Optional[PlacementGroupConfiguration] = None,
|
|
1013
|
+
provisioning_data: Optional[PlacementGroupProvisioningData] = None,
|
|
1014
|
+
fleet_deleted: Optional[bool] = False,
|
|
1015
|
+
deleted: Optional[bool] = False,
|
|
1016
|
+
deleted_at: Optional[datetime] = None,
|
|
1017
|
+
) -> PlacementGroupModel:
|
|
1018
|
+
if configuration is None:
|
|
1019
|
+
configuration = get_placement_group_configuration()
|
|
1020
|
+
if provisioning_data is None:
|
|
1021
|
+
provisioning_data = get_placement_group_provisioning_data()
|
|
1022
|
+
pg = PlacementGroupModel(
|
|
1023
|
+
project=project,
|
|
1024
|
+
fleet=fleet,
|
|
1025
|
+
name=name,
|
|
1026
|
+
created_at=created_at,
|
|
1027
|
+
configuration=configuration.json(),
|
|
1028
|
+
provisioning_data=provisioning_data.json(),
|
|
1029
|
+
fleet_deleted=fleet_deleted,
|
|
1030
|
+
deleted=deleted,
|
|
1031
|
+
deleted_at=deleted_at,
|
|
1032
|
+
)
|
|
1033
|
+
session.add(pg)
|
|
1034
|
+
await session.commit()
|
|
1035
|
+
return pg
|
|
1036
|
+
|
|
1037
|
+
|
|
1038
|
+
def get_placement_group_configuration(
|
|
1039
|
+
backend: BackendType = BackendType.AWS,
|
|
1040
|
+
region: str = "eu-central-1",
|
|
1041
|
+
strategy: PlacementStrategy = PlacementStrategy.CLUSTER,
|
|
1042
|
+
) -> PlacementGroupConfiguration:
|
|
1043
|
+
return PlacementGroupConfiguration(
|
|
1044
|
+
backend=backend,
|
|
1045
|
+
region=region,
|
|
1046
|
+
placement_strategy=strategy,
|
|
1047
|
+
)
|
|
1048
|
+
|
|
1049
|
+
|
|
1050
|
+
def get_placement_group_provisioning_data(
|
|
1051
|
+
backend: BackendType = BackendType.AWS,
|
|
1052
|
+
) -> PlacementGroupProvisioningData:
|
|
1053
|
+
return PlacementGroupProvisioningData(backend=backend)
|
|
1054
|
+
|
|
1055
|
+
|
|
1056
|
+
async def create_job_metrics_point(
|
|
1057
|
+
session: AsyncSession,
|
|
1058
|
+
job_model: JobModel,
|
|
1059
|
+
timestamp: datetime,
|
|
1060
|
+
cpu_usage_micro: int = 1_000_000,
|
|
1061
|
+
memory_usage_bytes: int = 1024,
|
|
1062
|
+
memory_working_set_bytes: int = 1024,
|
|
1063
|
+
gpus_memory_usage_bytes: Optional[List[int]] = None,
|
|
1064
|
+
gpus_util_percent: Optional[List[int]] = None,
|
|
1065
|
+
) -> JobMetricsPoint:
|
|
1066
|
+
timestamp_micro = int(timestamp.timestamp() * 1_000_000)
|
|
1067
|
+
if gpus_memory_usage_bytes is None:
|
|
1068
|
+
gpus_memory_usage_bytes = []
|
|
1069
|
+
if gpus_util_percent is None:
|
|
1070
|
+
gpus_util_percent = []
|
|
1071
|
+
jmp = JobMetricsPoint(
|
|
1072
|
+
job_id=job_model.id,
|
|
1073
|
+
timestamp_micro=timestamp_micro,
|
|
1074
|
+
cpu_usage_micro=cpu_usage_micro,
|
|
1075
|
+
memory_usage_bytes=memory_usage_bytes,
|
|
1076
|
+
memory_working_set_bytes=memory_working_set_bytes,
|
|
1077
|
+
gpus_memory_usage_bytes=json.dumps(gpus_memory_usage_bytes),
|
|
1078
|
+
gpus_util_percent=json.dumps(gpus_util_percent),
|
|
1079
|
+
)
|
|
1080
|
+
session.add(jmp)
|
|
1081
|
+
await session.commit()
|
|
1082
|
+
return jmp
|
|
1083
|
+
|
|
1084
|
+
|
|
1085
|
+
async def create_job_prometheus_metrics(
|
|
1086
|
+
session: AsyncSession,
|
|
1087
|
+
job: JobModel,
|
|
1088
|
+
collected_at: datetime = datetime(2023, 1, 2, 3, 4, tzinfo=timezone.utc),
|
|
1089
|
+
text: str = "# Prometheus metrics\n",
|
|
1090
|
+
):
|
|
1091
|
+
metrics = JobPrometheusMetrics(
|
|
1092
|
+
job_id=job.id,
|
|
1093
|
+
collected_at=collected_at,
|
|
1094
|
+
text=text,
|
|
1095
|
+
)
|
|
1096
|
+
session.add(metrics)
|
|
1097
|
+
await session.commit()
|
|
1098
|
+
return metrics
|
|
1099
|
+
|
|
1100
|
+
|
|
1101
|
+
async def create_secret(
|
|
1102
|
+
session: AsyncSession,
|
|
1103
|
+
project: ProjectModel,
|
|
1104
|
+
name: str,
|
|
1105
|
+
value: str,
|
|
1106
|
+
):
|
|
1107
|
+
secret_model = SecretModel(
|
|
1108
|
+
project=project,
|
|
1109
|
+
name=name,
|
|
1110
|
+
value=DecryptedString(plaintext=value),
|
|
1111
|
+
)
|
|
1112
|
+
session.add(secret_model)
|
|
1113
|
+
await session.commit()
|
|
1114
|
+
return secret_model
|
|
1115
|
+
|
|
1116
|
+
|
|
1117
|
+
async def list_events(session: AsyncSession) -> list[EventModel]:
|
|
1118
|
+
res = await session.execute(
|
|
1119
|
+
select(EventModel)
|
|
1120
|
+
.order_by(EventModel.recorded_at, EventModel.id)
|
|
1121
|
+
.options(joinedload(EventModel.targets))
|
|
1122
|
+
)
|
|
1123
|
+
return list(res.scalars().unique().all())
|
|
1124
|
+
|
|
1125
|
+
|
|
1126
|
+
async def clear_events(session: AsyncSession) -> None:
|
|
1127
|
+
await session.execute(delete(EventModel))
|
|
1128
|
+
|
|
1129
|
+
|
|
1130
|
+
def get_private_key_string() -> str:
|
|
1131
|
+
return """
|
|
1132
|
+
-----BEGIN RSA PRIVATE KEY-----
|
|
1133
|
+
MIIJJwIBAAKCAgEApZ8j9eU/C2/XvM7tG9tjhT85IHuJ2hQ61DYYDIPb8bY8/KWJ
|
|
1134
|
+
WIVb90CBElVtmRnO7AvGsceKJ2I6YFsr37RVLAgo6Is0osvO+co+3bGiHxNwT7sX
|
|
1135
|
+
+MatuiLtzvGZLQW8Os/xMy+aIIgzTZ0pDmEJIIlO2msd4jZO9R6UpPa1F4z0Oj0G
|
|
1136
|
+
0So262qXHMGBs63CFqbLeQKecUK8e0RfUD1mxr8f4zJ33JpW0rjg0uZiAjLnYOYN
|
|
1137
|
+
C4e4bWnIS7byGrcuRDXpYIrGXrxcrG16CKr7zrFNq+h4f5e7wDUICwPz5X8ke+JZ
|
|
1138
|
+
0DIm5ooXWO07BLPNG9fbQHIR8SQgT4X+sfYasYUT9cFugwEiWSWyrRKoc4ZRmwiL
|
|
1139
|
+
Rz5Tb5Rgn+OFXq1yYr+CnguTr4n6Ldv9RLMBye1r8S/h1Yi5DBZOyJDCTuw0tPhL
|
|
1140
|
+
eUjS/pBLZ5oxSnUDQ1lirSOHDPpn6N9Mxtm9IN6WElv1W2pM55sCp33NuMbsC0C3
|
|
1141
|
+
8iCan3Z0giKxaNyeejzHEEkgeGq8UMGDaQglfDIOkKMI6zHeGQc0201lDsCXKGeN
|
|
1142
|
+
6xeXdubtuZg1EPKdnNeZDZB636LZ+opi/6OLPNo7ml/zU24eymKMHF21+eO2TTVk
|
|
1143
|
+
Eh0skTs4b9R0tHRhzAvZrDC6NR4CyJFCCE+lzkkLenSD1DLiEjExoLChGtECAwEA
|
|
1144
|
+
AQKCAgB734gs7RZ3PmKUdAxBzpgj3AKlOeED/Cd3+zGHgsPpiE0bBdCxJaWAS31+
|
|
1145
|
+
Mej0Hqp2P+SPqVe6VyykTuyEt8MQWNYH/74RmPAoQc09UROZvJc++wdV6XucgW1u
|
|
1146
|
+
X6MaWnTLZCXaC9tyQ4xjm41OlOMXs7sHgCBsxgPOL94rd95ATAuK14QWw0UqVKHL
|
|
1147
|
+
Pyv8MJS/DmeXDY9l1O1WIPBM+m+5bM+zxVaC5+jSWLbG5ssdK+eEwOu22P7mzryh
|
|
1148
|
+
bKattp5jJBN2QrVVu/pweL1SaFhH4rLeRdSCUgF6I+/tFTrBRpQKGGTmY+xWd6g4
|
|
1149
|
+
uc5vmO9qyMrS675hpoyIDgdOIW0abm8Jb1rnAbKVtBx4yTfLeD+Cx5a+o24JEIH7
|
|
1150
|
+
4J6yutUabWvRNz0JT9bpiEQYZBKZROt1sSdjf+8xxgXQHIuAn1F/xjfqdBvxG0UE
|
|
1151
|
+
2UkP3+UO6DEl7ciE4+eBaBoJp1DHkWOyXgAC/RvR9aNuPvOV5RfTw/DtL5eLTuZQ
|
|
1152
|
+
1AUnKcjE0CAryCAkNdY42gRT1m/BvUrf96zKbcQS61YgHS9jtPsoaPh2AKiUAo96
|
|
1153
|
+
a4M+fRMmVPxlO8TcykTL4BRVihuz2Gx+DOB7M/UVGTtk1pHVJqjDFuX4M5gzrkjt
|
|
1154
|
+
+px34flQaBPR7um/91aEicV3t4x4OGIDhcjd49wor8fLp3AxcQKCAQEA256rxqeG
|
|
1155
|
+
oZxlaqXALr5uRlAVf2uf2DtVP7bWwoQpT8ULm4hQfKz+yvntm7jq7wuW5RYzGpFA
|
|
1156
|
+
einBFbbsUs8VGtMYOmiD2IR7KYYsqd+4wEIvv5LhWAtIHMu+E3zir1aXj0yEZELM
|
|
1157
|
+
Ou+zNxhhwewxgzPg3LmfjD0bnL/yvJavlEvxKcZy7kODHCW9j4B3/6Mm4KlcFC5p
|
|
1158
|
+
DYmtlhBGPK6FpH1PDJrrzZKZApLoAT8D6h71ZH9p/9q6CmKduy3hGGVlDYQNhEI4
|
|
1159
|
+
40S7r9cMsI6Rz6hT/uj5EexUc0LYbPCDMlXhOMXRNnrAHwKW1myD4Mp8o4suaTYT
|
|
1160
|
+
c0IY4imqP+/a9QKCAQEAwQ6XR0WnnyHjgWF5z2l/TG5Io4GBOwZBHzbOb+6afBGZ
|
|
1161
|
+
ScnlVuGhyfusiYBXEdejwZGuE+jR5Oe+6yP+mEtDfxeXPQ91KhSbu5i0zu+Mkokb
|
|
1162
|
+
LXjhL/MlPM6TKGG4XHZ+BHSV4aqQPp2EL2jViyd9/vbb/oNhTLDP4pNMX90G/bYq
|
|
1163
|
+
VIa1GH5lCS0xg611HwgLGSTVnggrcUsytgpMprdV0N/NWla9dOeUaIBqt/m2RbuH
|
|
1164
|
+
Csyqe/AjwwB9CLKYnGL5gus14guHWXBEPUR/GjcyODIq/0WIlOyANAzHWy2WXzgq
|
|
1165
|
+
w4NGo6L7IoiIbL1EED3gljPlHd5JeXU9MtjWDvIO7QKCAQB52vk+mTdHNmrDGMKg
|
|
1166
|
+
bQLsuoSjFYk0Rf+QAZf5h7EQVKmTG7hk5OvenXvsGlcoWYrZA09Jn2xiHAbJUJyh
|
|
1167
|
+
ecsg/h2EUvdMzH011f+0JbDx5AdwSUQFQQU7DQUi9PkmBmrDlNYkdzewP811dW7Q
|
|
1168
|
+
VYhHXyKV9dyDyGgougwp/YXgR57A6h5c+1Kk7H/YPpTWX6UzpGS1weaCH3EUQWVn
|
|
1169
|
+
SAJY+TpCKTdK8ds6JV7bSiaW4aSQpW2gC7GMD5mrANLTYXcHX8zMJJ5B46Ir96tP
|
|
1170
|
+
z1syGBi66HNCMZnN9jn1gCGbbTEw+fmSO9ubmSkuQjmOIWu0poYS1HFIU1VRL4MK
|
|
1171
|
+
RMB9AoIBAFiNhcx2Yc23cLCO8p216WM4ju8Y3xsg4kwcCpMDIi9YrzROfHjepCSO
|
|
1172
|
+
4XRsvwN7Iy0N0ohlWamit0sKRqS6mSo5uvCSH47+xvREtmLZNGSeqS2xbbFd2S3M
|
|
1173
|
+
H2n9cOBQpbsLcxiA8QsXm2NXtePPaJbDyuMyhjX0QFbQc87hBmzn2wDMjVK/3z5X
|
|
1174
|
+
UYfxz3A9c0HESIvleW/NK2Se0swB+kYF8h7G/L4b31IT3V+oFfhkbSwB9w1EeFLg
|
|
1175
|
+
7XlI2oGZUJPBqgSWfy4CNfrYaWiv+sQWFuziiySsWp4FYogrH/drPwpRM9ypTIJp
|
|
1176
|
+
mBIwuoCssVCUWzrZFGC26yxgk8dlNn0CggEAOfjn13/pSPzjlEOMA3IrUd/5cllI
|
|
1177
|
+
hST6gzwXr4DmxnTzyKsLGPoMoE2r/whWReZTTSzFh+CbNBMOzQdlNo5k2WBt6mg8
|
|
1178
|
+
ey1hVYhkH6plOHJ8W4Abx+S/6C2s+QgUeEhFzeDAkYHNdJdQuPg/HWzk08RGmruA
|
|
1179
|
+
kXYzp3q5IQqgKM4abf8oye3n6d3bl6Vc4MHTV+1Kxm6za6Of7wMcZ9uNEqxozw2H
|
|
1180
|
+
mgsoXQqZBWaHGwLv8fkPuUmRp+JPaJW8Aag/3swpyTCZ21DneYcqy6S8MG2R8NjV
|
|
1181
|
+
VOl2sg6hJrQQHfmKH7ru4U5PTZzhHIw1RAWdagjiBONB2MeHYIFWncxKGw==
|
|
1182
|
+
-----END RSA PRIVATE KEY-----
|
|
1183
|
+
"""
|
|
1184
|
+
|
|
1185
|
+
|
|
1186
|
+
@contextmanager
|
|
1187
|
+
def default_permissions_context(default_permissions: DefaultPermissions):
|
|
1188
|
+
prev_default_permissions = get_default_permissions()
|
|
1189
|
+
set_default_permissions(default_permissions)
|
|
1190
|
+
try:
|
|
1191
|
+
yield
|
|
1192
|
+
finally:
|
|
1193
|
+
set_default_permissions(prev_default_permissions)
|
|
1194
|
+
|
|
1195
|
+
|
|
1196
|
+
class AsyncContextManager:
|
|
1197
|
+
async def __aenter__(self):
|
|
1198
|
+
pass
|
|
1199
|
+
|
|
1200
|
+
async def __aexit__(self, exc_type, exc, traceback):
|
|
1201
|
+
pass
|
|
1202
|
+
|
|
1203
|
+
|
|
1204
|
+
class ComputeMockSpec(
|
|
1205
|
+
Compute,
|
|
1206
|
+
ComputeWithCreateInstanceSupport,
|
|
1207
|
+
ComputeWithGroupProvisioningSupport,
|
|
1208
|
+
ComputeWithPrivilegedSupport,
|
|
1209
|
+
ComputeWithMultinodeSupport,
|
|
1210
|
+
ComputeWithReservationSupport,
|
|
1211
|
+
ComputeWithPlacementGroupSupport,
|
|
1212
|
+
ComputeWithGatewaySupport,
|
|
1213
|
+
ComputeWithPrivateGatewaySupport,
|
|
1214
|
+
ComputeWithVolumeSupport,
|
|
1215
|
+
):
|
|
1216
|
+
"""
|
|
1217
|
+
Can be used to create Compute mocks that pass all `isinstance()` asserts.
|
|
1218
|
+
"""
|
|
1219
|
+
|
|
1220
|
+
pass
|