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,836 @@
|
|
|
1
|
+
import base64
|
|
2
|
+
import dataclasses
|
|
3
|
+
import datetime
|
|
4
|
+
import time
|
|
5
|
+
from concurrent.futures import Executor, ThreadPoolExecutor, as_completed
|
|
6
|
+
from functools import reduce
|
|
7
|
+
from itertools import islice
|
|
8
|
+
from typing import (
|
|
9
|
+
Any,
|
|
10
|
+
Callable,
|
|
11
|
+
Collection,
|
|
12
|
+
Dict,
|
|
13
|
+
Iterable,
|
|
14
|
+
Iterator,
|
|
15
|
+
List,
|
|
16
|
+
Mapping,
|
|
17
|
+
Optional,
|
|
18
|
+
Set,
|
|
19
|
+
Tuple,
|
|
20
|
+
)
|
|
21
|
+
|
|
22
|
+
import oci
|
|
23
|
+
from oci.object_storage.models import CreatePreauthenticatedRequestDetails
|
|
24
|
+
|
|
25
|
+
from dstack import version
|
|
26
|
+
from dstack._internal.core.backends.base.compute import requires_nvidia_proprietary_kernel_modules
|
|
27
|
+
from dstack._internal.core.backends.oci.region import OCIRegionClient
|
|
28
|
+
from dstack._internal.core.consts import DSTACK_OS_IMAGE_WITH_PROPRIETARY_NVIDIA_KERNEL_MODULES
|
|
29
|
+
from dstack._internal.core.errors import BackendError
|
|
30
|
+
from dstack._internal.core.models.instances import InstanceOffer
|
|
31
|
+
from dstack._internal.utils.common import batched
|
|
32
|
+
from dstack._internal.utils.logging import get_logger
|
|
33
|
+
|
|
34
|
+
logger = get_logger(__name__)
|
|
35
|
+
LIST_SHAPES_MAX_LIMIT = 100
|
|
36
|
+
CAPACITY_REPORT_MAX_SHAPES = 10 # undocumented, found by experiment
|
|
37
|
+
REMOVE_SECURITY_RULES_MAX_CHUNK_SIZE = 25
|
|
38
|
+
ADD_SECURITY_RULES_MAX_CHUNK_SIZE = 25
|
|
39
|
+
LIST_OBJECTS_MAX_LIMIT = 1000
|
|
40
|
+
VCN_CIDR = "10.0.0.0/16"
|
|
41
|
+
WAIT_FOR_COMPARTMENT_ATTEMPS = 36
|
|
42
|
+
WAIT_FOR_COMPARTMENT_DELAY = 5
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
@dataclasses.dataclass(frozen=True)
|
|
46
|
+
class SecurityRule:
|
|
47
|
+
"""
|
|
48
|
+
A rule in a security group. This class is needed as an intermediate representation,
|
|
49
|
+
as OCI SDK provides several security rule classes that are not mutually comparable.
|
|
50
|
+
"""
|
|
51
|
+
|
|
52
|
+
direction: str
|
|
53
|
+
protocol: str
|
|
54
|
+
description: Optional[str] = None
|
|
55
|
+
destination: Optional[str] = None
|
|
56
|
+
destination_type: Optional[str] = None
|
|
57
|
+
icmp_options: Optional[oci.core.models.IcmpOptions] = None
|
|
58
|
+
is_stateless: bool = False
|
|
59
|
+
source: Optional[str] = None
|
|
60
|
+
source_type: Optional[str] = None
|
|
61
|
+
tcp_options: Optional[oci.core.models.TcpOptions] = None
|
|
62
|
+
udp_options: Optional[oci.core.models.UdpOptions] = None
|
|
63
|
+
|
|
64
|
+
@classmethod
|
|
65
|
+
def from_sdk_rule(cls, rule: oci.core.models.SecurityRule) -> "SecurityRule":
|
|
66
|
+
fields = {field.name: getattr(rule, field.name) for field in dataclasses.fields(cls)}
|
|
67
|
+
fields["is_stateless"] = bool(fields["is_stateless"])
|
|
68
|
+
return SecurityRule(**fields)
|
|
69
|
+
|
|
70
|
+
def to_sdk_add_rule_details(self) -> oci.core.models.AddSecurityRuleDetails:
|
|
71
|
+
return oci.core.models.AddSecurityRuleDetails(**dataclasses.asdict(self))
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
class ShapesQuota:
|
|
75
|
+
def __init__(self, region_to_domain_to_shape_names: Dict[str, Dict[str, Set[str]]]):
|
|
76
|
+
self._domain_to_shape_names = {
|
|
77
|
+
domain: shape_names
|
|
78
|
+
for domain_to_shape_names in region_to_domain_to_shape_names.values()
|
|
79
|
+
for domain, shape_names in domain_to_shape_names.items()
|
|
80
|
+
}
|
|
81
|
+
self._region_to_shape_names = {
|
|
82
|
+
region_name: reduce(set.union, domain_to_shape_names.values())
|
|
83
|
+
for region_name, domain_to_shape_names in region_to_domain_to_shape_names.items()
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
def is_within_region_quota(self, shape_name: str, region_name: str) -> bool:
|
|
87
|
+
return shape_name in self._region_to_shape_names.get(region_name, set())
|
|
88
|
+
|
|
89
|
+
def is_within_domain_quota(self, shape_name: str, domain_name: str) -> bool:
|
|
90
|
+
return shape_name in self._domain_to_shape_names.get(domain_name, set())
|
|
91
|
+
|
|
92
|
+
@staticmethod
|
|
93
|
+
def load(regions: Mapping[str, OCIRegionClient], compartment_id: str) -> "ShapesQuota":
|
|
94
|
+
with ThreadPoolExecutor(max_workers=8) as executor:
|
|
95
|
+
return ShapesQuota(list_shapes(regions, compartment_id, executor))
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
def chain_paginated_responses(
|
|
99
|
+
api_method: Callable[..., oci.response.Response], *args, **kwargs
|
|
100
|
+
) -> Iterator[Any]:
|
|
101
|
+
"""
|
|
102
|
+
Call `api_method` multiple times to fetch all response pages.
|
|
103
|
+
Entries from all pages are chained into one iterator.
|
|
104
|
+
|
|
105
|
+
It is recommended to always use this function with API methods that support
|
|
106
|
+
pagination, as OCI's paginated responses are inconsistent, e.g. the first
|
|
107
|
+
page may have 0 entries while the other pages have more entries.
|
|
108
|
+
"""
|
|
109
|
+
|
|
110
|
+
has_next_page = True
|
|
111
|
+
while has_next_page:
|
|
112
|
+
resp = api_method(*args, **kwargs)
|
|
113
|
+
yield from resp.data
|
|
114
|
+
kwargs["page"] = resp.next_page
|
|
115
|
+
has_next_page = resp.has_next_page
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
def list_shapes_in_domain(
|
|
119
|
+
availability_domain_name: str, client: oci.core.ComputeClient, compartment_id: str
|
|
120
|
+
) -> Set[str]:
|
|
121
|
+
"""
|
|
122
|
+
Returns a set of shape names allowed to be used in `availability_domain_name`.
|
|
123
|
+
"""
|
|
124
|
+
|
|
125
|
+
return {
|
|
126
|
+
shape.shape
|
|
127
|
+
for shape in chain_paginated_responses(
|
|
128
|
+
client.list_shapes,
|
|
129
|
+
availability_domain=availability_domain_name,
|
|
130
|
+
compartment_id=compartment_id,
|
|
131
|
+
limit=LIST_SHAPES_MAX_LIMIT,
|
|
132
|
+
)
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
def list_shapes_in_region(region: OCIRegionClient, compartment_id: str) -> Dict[str, Set[str]]:
|
|
137
|
+
"""
|
|
138
|
+
Returns a mapping of availability domain names to sets of shape names
|
|
139
|
+
allowed to be used in these domains.
|
|
140
|
+
"""
|
|
141
|
+
|
|
142
|
+
result = {}
|
|
143
|
+
for availability_domain in region.availability_domains:
|
|
144
|
+
result[availability_domain.name] = list_shapes_in_domain(
|
|
145
|
+
availability_domain.name, region.compute_client, compartment_id
|
|
146
|
+
)
|
|
147
|
+
return result
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
def list_shapes(
|
|
151
|
+
regions: Mapping[str, OCIRegionClient], compartment_id: str, executor: Executor
|
|
152
|
+
) -> Dict[str, Dict[str, Set[str]]]:
|
|
153
|
+
"""
|
|
154
|
+
Returns a mapping of region names to mappings of availability domain names
|
|
155
|
+
to sets of shape names allowed to be used in these availability domains.
|
|
156
|
+
"""
|
|
157
|
+
|
|
158
|
+
future_to_region_name = {}
|
|
159
|
+
for region_name, region_client in regions.items():
|
|
160
|
+
future = executor.submit(list_shapes_in_region, region_client, compartment_id)
|
|
161
|
+
future_to_region_name[future] = region_name
|
|
162
|
+
|
|
163
|
+
result = {}
|
|
164
|
+
for future in as_completed(future_to_region_name):
|
|
165
|
+
region_name = future_to_region_name[future]
|
|
166
|
+
result[region_name] = future.result()
|
|
167
|
+
|
|
168
|
+
return result
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
def check_availability_in_domain(
|
|
172
|
+
shape_names: Iterable[str],
|
|
173
|
+
availability_domain_name: str,
|
|
174
|
+
client: oci.core.ComputeClient,
|
|
175
|
+
compartment_id: str,
|
|
176
|
+
) -> Set[str]:
|
|
177
|
+
"""
|
|
178
|
+
Returns a subset of `shape_names` with only the shapes available in
|
|
179
|
+
`availability_domain_name`.
|
|
180
|
+
"""
|
|
181
|
+
|
|
182
|
+
unchecked = set(shape_names)
|
|
183
|
+
available = set()
|
|
184
|
+
|
|
185
|
+
while chunk := set(islice(unchecked, CAPACITY_REPORT_MAX_SHAPES)):
|
|
186
|
+
unchecked -= chunk
|
|
187
|
+
report: oci.core.models.ComputeCapacityReport = client.create_compute_capacity_report(
|
|
188
|
+
oci.core.models.CreateComputeCapacityReportDetails(
|
|
189
|
+
compartment_id=compartment_id,
|
|
190
|
+
availability_domain=availability_domain_name,
|
|
191
|
+
shape_availabilities=[
|
|
192
|
+
oci.core.models.CreateCapacityReportShapeAvailabilityDetails(
|
|
193
|
+
instance_shape=shape_name,
|
|
194
|
+
)
|
|
195
|
+
for shape_name in chunk
|
|
196
|
+
],
|
|
197
|
+
)
|
|
198
|
+
).data
|
|
199
|
+
item: oci.core.models.CapacityReportShapeAvailability
|
|
200
|
+
|
|
201
|
+
for item in report.shape_availabilities:
|
|
202
|
+
if item.availability_status == item.AVAILABILITY_STATUS_AVAILABLE:
|
|
203
|
+
available.add(item.instance_shape)
|
|
204
|
+
|
|
205
|
+
return available
|
|
206
|
+
|
|
207
|
+
|
|
208
|
+
def check_availability_per_domain(
|
|
209
|
+
shape_names: Iterable[str],
|
|
210
|
+
shapes_quota: ShapesQuota,
|
|
211
|
+
region: OCIRegionClient,
|
|
212
|
+
compartment_id: str,
|
|
213
|
+
) -> Dict[str, Set[str]]:
|
|
214
|
+
all_shapes = set(shape_names)
|
|
215
|
+
available_shapes_per_domain = {}
|
|
216
|
+
|
|
217
|
+
for availability_domain in region.availability_domains:
|
|
218
|
+
shapes_to_check = {
|
|
219
|
+
shape
|
|
220
|
+
for shape in all_shapes
|
|
221
|
+
if shapes_quota.is_within_domain_quota(shape, availability_domain.name)
|
|
222
|
+
}
|
|
223
|
+
available_shapes_per_domain[availability_domain.name] = check_availability_in_domain(
|
|
224
|
+
shape_names=shapes_to_check,
|
|
225
|
+
availability_domain_name=availability_domain.name,
|
|
226
|
+
client=region.compute_client,
|
|
227
|
+
compartment_id=compartment_id,
|
|
228
|
+
)
|
|
229
|
+
|
|
230
|
+
return available_shapes_per_domain
|
|
231
|
+
|
|
232
|
+
|
|
233
|
+
def get_shapes_availability(
|
|
234
|
+
offers: Iterable[InstanceOffer],
|
|
235
|
+
shapes_quota: ShapesQuota,
|
|
236
|
+
regions: Mapping[str, OCIRegionClient],
|
|
237
|
+
compartment_id: str,
|
|
238
|
+
executor: Executor,
|
|
239
|
+
) -> Dict[str, Dict[str, List[str]]]:
|
|
240
|
+
"""
|
|
241
|
+
Returns availability domains where shapes are available as regions->shapes->availability_domains mapping.
|
|
242
|
+
Only shapes from `offers` are checked.
|
|
243
|
+
"""
|
|
244
|
+
shape_names_per_region = {region: set() for region in regions}
|
|
245
|
+
for offer in offers:
|
|
246
|
+
if shapes_quota.is_within_region_quota(offer.instance.name, offer.region):
|
|
247
|
+
shape_names_per_region[offer.region].add(offer.instance.name)
|
|
248
|
+
|
|
249
|
+
future_to_region_name = {}
|
|
250
|
+
for region_name, shape_names in shape_names_per_region.items():
|
|
251
|
+
future = executor.submit(
|
|
252
|
+
check_availability_per_domain,
|
|
253
|
+
shape_names,
|
|
254
|
+
shapes_quota,
|
|
255
|
+
regions[region_name],
|
|
256
|
+
compartment_id,
|
|
257
|
+
)
|
|
258
|
+
future_to_region_name[future] = region_name
|
|
259
|
+
|
|
260
|
+
result = {}
|
|
261
|
+
for future in as_completed(future_to_region_name):
|
|
262
|
+
domains_to_shape_names = future.result()
|
|
263
|
+
shape_names_to_domains = {}
|
|
264
|
+
for domain, shape_names in domains_to_shape_names.items():
|
|
265
|
+
for shape_name in shape_names:
|
|
266
|
+
shape_names_to_domains.setdefault(shape_name, []).append(domain)
|
|
267
|
+
result[future_to_region_name[future]] = shape_names_to_domains
|
|
268
|
+
|
|
269
|
+
return result
|
|
270
|
+
|
|
271
|
+
|
|
272
|
+
def get_available_domains(
|
|
273
|
+
shape_name: str, shapes_quota: ShapesQuota, region: OCIRegionClient, compartment_id: str
|
|
274
|
+
) -> List[str]:
|
|
275
|
+
"""
|
|
276
|
+
Returns the names of all availability domains in `region` in which
|
|
277
|
+
`shape_name` is available and within `shapes_quota`.
|
|
278
|
+
"""
|
|
279
|
+
domains = []
|
|
280
|
+
for domain in region.availability_domains:
|
|
281
|
+
if shapes_quota.is_within_domain_quota(
|
|
282
|
+
shape_name, domain.name
|
|
283
|
+
) and check_availability_in_domain(
|
|
284
|
+
{shape_name}, domain.name, region.compute_client, compartment_id
|
|
285
|
+
):
|
|
286
|
+
domains.append(domain.name)
|
|
287
|
+
return domains
|
|
288
|
+
|
|
289
|
+
|
|
290
|
+
def get_instance_vnic(
|
|
291
|
+
instance_id: str, region: OCIRegionClient, compartment_id: str
|
|
292
|
+
) -> Optional[oci.core.models.Vnic]:
|
|
293
|
+
attachments: Iterator[oci.core.models.VnicAttachment] = chain_paginated_responses(
|
|
294
|
+
region.compute_client.list_vnic_attachments, compartment_id, instance_id=instance_id
|
|
295
|
+
)
|
|
296
|
+
if attachment := next(attachments, None):
|
|
297
|
+
return region.virtual_network_client.get_vnic(attachment.vnic_id).data
|
|
298
|
+
return None
|
|
299
|
+
|
|
300
|
+
|
|
301
|
+
def launch_instance(
|
|
302
|
+
region: OCIRegionClient,
|
|
303
|
+
availability_domain: str,
|
|
304
|
+
compartment_id: str,
|
|
305
|
+
subnet_id: str,
|
|
306
|
+
security_group_id: str,
|
|
307
|
+
display_name: str,
|
|
308
|
+
cloud_init_user_data: str,
|
|
309
|
+
shape: str,
|
|
310
|
+
is_spot: bool,
|
|
311
|
+
disk_size_gb: int,
|
|
312
|
+
image_id: str,
|
|
313
|
+
) -> oci.core.models.Instance:
|
|
314
|
+
preemptible_config = None
|
|
315
|
+
if is_spot:
|
|
316
|
+
preemptible_config = oci.core.models.PreemptibleInstanceConfigDetails(
|
|
317
|
+
preemption_action=oci.core.models.TerminatePreemptionAction(preserve_boot_volume=False)
|
|
318
|
+
)
|
|
319
|
+
|
|
320
|
+
return region.compute_client.launch_instance(
|
|
321
|
+
oci.core.models.LaunchInstanceDetails(
|
|
322
|
+
availability_domain=availability_domain,
|
|
323
|
+
compartment_id=compartment_id,
|
|
324
|
+
create_vnic_details=oci.core.models.CreateVnicDetails(
|
|
325
|
+
subnet_id=subnet_id, nsg_ids=[security_group_id]
|
|
326
|
+
),
|
|
327
|
+
display_name=display_name,
|
|
328
|
+
instance_options=oci.core.models.InstanceOptions(
|
|
329
|
+
are_legacy_imds_endpoints_disabled=True
|
|
330
|
+
),
|
|
331
|
+
metadata=dict(
|
|
332
|
+
user_data=base64.b64encode(cloud_init_user_data.encode()).decode(),
|
|
333
|
+
),
|
|
334
|
+
preemptible_instance_config=preemptible_config,
|
|
335
|
+
shape=shape,
|
|
336
|
+
source_details=oci.core.models.InstanceSourceViaImageDetails(
|
|
337
|
+
image_id=image_id,
|
|
338
|
+
boot_volume_size_in_gbs=disk_size_gb,
|
|
339
|
+
),
|
|
340
|
+
)
|
|
341
|
+
).data
|
|
342
|
+
|
|
343
|
+
|
|
344
|
+
def terminate_instance_if_exists(client: oci.core.ComputeClient, instance_id: str) -> None:
|
|
345
|
+
try:
|
|
346
|
+
client.terminate_instance(
|
|
347
|
+
instance_id=instance_id,
|
|
348
|
+
preserve_boot_volume=False,
|
|
349
|
+
preserve_data_volumes_created_at_launch=False,
|
|
350
|
+
)
|
|
351
|
+
except oci.exceptions.ServiceError as e:
|
|
352
|
+
if e.status != 404:
|
|
353
|
+
raise
|
|
354
|
+
|
|
355
|
+
|
|
356
|
+
def get_marketplace_listing_and_package(
|
|
357
|
+
gpu_name: Optional[str], client: oci.marketplace.MarketplaceClient
|
|
358
|
+
) -> Tuple[oci.marketplace.models.Listing, oci.marketplace.models.ImageListingPackage]:
|
|
359
|
+
listing_name = f"dstack-{version.base_image}"
|
|
360
|
+
if gpu_name is not None:
|
|
361
|
+
if not requires_nvidia_proprietary_kernel_modules(gpu_name):
|
|
362
|
+
listing_name = f"dstack-cuda-{version.base_image}"
|
|
363
|
+
else:
|
|
364
|
+
listing_name = f"dstack-cuda-{DSTACK_OS_IMAGE_WITH_PROPRIETARY_NVIDIA_KERNEL_MODULES}"
|
|
365
|
+
|
|
366
|
+
listing_summaries = list_marketplace_listings(listing_name, client)
|
|
367
|
+
if len(listing_summaries) != 1:
|
|
368
|
+
msg = f"Expected to find 1 listing by name {listing_name}, found {len(listing_summaries)}"
|
|
369
|
+
raise BackendError(msg)
|
|
370
|
+
|
|
371
|
+
listing: oci.marketplace.models.Listing = client.get_listing(listing_summaries[0].id).data
|
|
372
|
+
package = client.get_package(listing.id, listing.default_package_version).data
|
|
373
|
+
return listing, package
|
|
374
|
+
|
|
375
|
+
|
|
376
|
+
def list_marketplace_listings(
|
|
377
|
+
listing_name: str, client: oci.marketplace.MarketplaceClient
|
|
378
|
+
) -> List[oci.marketplace.models.ListingSummary]:
|
|
379
|
+
return [
|
|
380
|
+
listing
|
|
381
|
+
for listing in chain_paginated_responses(
|
|
382
|
+
client.list_listings,
|
|
383
|
+
name=listing_name,
|
|
384
|
+
listing_types=[oci.marketplace.models.Listing.LISTING_TYPE_COMMUNITY],
|
|
385
|
+
)
|
|
386
|
+
if listing.name == listing_name # list_listings returns inexact matches
|
|
387
|
+
]
|
|
388
|
+
|
|
389
|
+
|
|
390
|
+
def accept_marketplace_listing_agreements(
|
|
391
|
+
listing: oci.marketplace.models.Listing,
|
|
392
|
+
compartment_id: str,
|
|
393
|
+
client: oci.marketplace.MarketplaceClient,
|
|
394
|
+
) -> None:
|
|
395
|
+
accepted_agreement_ids = {
|
|
396
|
+
a.agreement_id
|
|
397
|
+
for a in chain_paginated_responses(
|
|
398
|
+
client.list_accepted_agreements,
|
|
399
|
+
compartment_id=compartment_id,
|
|
400
|
+
listing_id=listing.id,
|
|
401
|
+
package_version=listing.default_package_version,
|
|
402
|
+
)
|
|
403
|
+
}
|
|
404
|
+
agreement_summaries: Iterator[oci.marketplace.models.AgreementSummary] = (
|
|
405
|
+
chain_paginated_responses(
|
|
406
|
+
client.list_agreements, listing.id, listing.default_package_version
|
|
407
|
+
)
|
|
408
|
+
)
|
|
409
|
+
for agreement_summary in agreement_summaries:
|
|
410
|
+
if agreement_summary.id in accepted_agreement_ids:
|
|
411
|
+
continue
|
|
412
|
+
agreement: oci.marketplace.models.Agreement = client.get_agreement(
|
|
413
|
+
listing_id=listing.id,
|
|
414
|
+
package_version=listing.default_package_version,
|
|
415
|
+
agreement_id=agreement_summary.id,
|
|
416
|
+
compartment_id=compartment_id,
|
|
417
|
+
).data
|
|
418
|
+
client.create_accepted_agreement(
|
|
419
|
+
oci.marketplace.models.CreateAcceptedAgreementDetails(
|
|
420
|
+
compartment_id=compartment_id,
|
|
421
|
+
listing_id=listing.id,
|
|
422
|
+
package_version=listing.default_package_version,
|
|
423
|
+
agreement_id=agreement.id,
|
|
424
|
+
signature=agreement.signature,
|
|
425
|
+
)
|
|
426
|
+
)
|
|
427
|
+
|
|
428
|
+
|
|
429
|
+
def get_or_create_compartment(
|
|
430
|
+
name: str, parent_compartment_id: str, client: oci.identity.IdentityClient
|
|
431
|
+
) -> oci.identity.models.Compartment:
|
|
432
|
+
query_results = chain_paginated_responses(
|
|
433
|
+
client.list_compartments, compartment_id=parent_compartment_id, name=name
|
|
434
|
+
)
|
|
435
|
+
if compartment := next(query_results, None):
|
|
436
|
+
return compartment
|
|
437
|
+
|
|
438
|
+
return client.create_compartment(
|
|
439
|
+
oci.identity.models.CreateCompartmentDetails(
|
|
440
|
+
compartment_id=parent_compartment_id,
|
|
441
|
+
name=name,
|
|
442
|
+
description="Resources created and managed by dstack",
|
|
443
|
+
)
|
|
444
|
+
).data
|
|
445
|
+
|
|
446
|
+
|
|
447
|
+
def get_compartment_lifecycle_state(id: str, client: oci.identity.IdentityClient) -> Optional[str]:
|
|
448
|
+
try:
|
|
449
|
+
return client.get_compartment(id).data.lifecycle_state
|
|
450
|
+
except oci.exceptions.ServiceError as e:
|
|
451
|
+
if e.status == 404:
|
|
452
|
+
return None
|
|
453
|
+
raise
|
|
454
|
+
|
|
455
|
+
|
|
456
|
+
def wait_until_compartment_active(id: str, regions: Mapping[str, OCIRegionClient]) -> None:
|
|
457
|
+
start_time = int(time.time())
|
|
458
|
+
state_active = oci.identity.models.Compartment.LIFECYCLE_STATE_ACTIVE
|
|
459
|
+
state_creating = oci.identity.models.Compartment.LIFECYCLE_STATE_CREATING
|
|
460
|
+
pending_regions = set(regions)
|
|
461
|
+
|
|
462
|
+
for attempt in range(1, WAIT_FOR_COMPARTMENT_ATTEMPS + 1):
|
|
463
|
+
while region := next(iter(pending_regions), None):
|
|
464
|
+
state = get_compartment_lifecycle_state(id, regions[region].identity_client)
|
|
465
|
+
if state == state_active:
|
|
466
|
+
pending_regions.remove(region)
|
|
467
|
+
elif state == state_creating or state is None:
|
|
468
|
+
break
|
|
469
|
+
else:
|
|
470
|
+
msg = f"Unexpected state {state} for compartment {id}"
|
|
471
|
+
raise BackendError(msg)
|
|
472
|
+
|
|
473
|
+
if not pending_regions:
|
|
474
|
+
return
|
|
475
|
+
|
|
476
|
+
logger.debug(
|
|
477
|
+
f"Waiting for OCI compartment {id} to become active. "
|
|
478
|
+
f"Tried {attempt}/{WAIT_FOR_COMPARTMENT_ATTEMPS} times"
|
|
479
|
+
)
|
|
480
|
+
if attempt != WAIT_FOR_COMPARTMENT_ATTEMPS:
|
|
481
|
+
time.sleep(WAIT_FOR_COMPARTMENT_DELAY)
|
|
482
|
+
|
|
483
|
+
time_spent = int(time.time() - start_time)
|
|
484
|
+
msg = (
|
|
485
|
+
f"Compartment {id} did not become active in {time_spent} seconds. "
|
|
486
|
+
"This can mean that it takes longer to activate, does not exist, "
|
|
487
|
+
"or the user does not have permission to access it"
|
|
488
|
+
)
|
|
489
|
+
raise BackendError(msg)
|
|
490
|
+
|
|
491
|
+
|
|
492
|
+
def set_up_network_resources(
|
|
493
|
+
compartment_id: str, project_name: str, regions: Mapping[str, OCIRegionClient]
|
|
494
|
+
) -> Dict[str, str]:
|
|
495
|
+
"""
|
|
496
|
+
Create or update a VCN and a subnet with Internet access in each region.
|
|
497
|
+
Returns a mapping of region names to subnet IDs.
|
|
498
|
+
"""
|
|
499
|
+
|
|
500
|
+
with ThreadPoolExecutor(max_workers=8) as executor:
|
|
501
|
+
future_to_region_name = {}
|
|
502
|
+
for region_name, region_client in regions.items():
|
|
503
|
+
future = executor.submit(
|
|
504
|
+
set_up_network_resources_in_region,
|
|
505
|
+
compartment_id,
|
|
506
|
+
project_name,
|
|
507
|
+
region_client.virtual_network_client,
|
|
508
|
+
)
|
|
509
|
+
future_to_region_name[future] = region_name
|
|
510
|
+
|
|
511
|
+
result = {}
|
|
512
|
+
for future in as_completed(future_to_region_name):
|
|
513
|
+
region_name = future_to_region_name[future]
|
|
514
|
+
result[region_name] = future.result()
|
|
515
|
+
|
|
516
|
+
return result
|
|
517
|
+
|
|
518
|
+
|
|
519
|
+
def set_up_network_resources_in_region(
|
|
520
|
+
compartment_id: str, project_name: str, client: oci.core.VirtualNetworkClient
|
|
521
|
+
) -> str:
|
|
522
|
+
"""
|
|
523
|
+
Create or update a VCN and a subnet with Internet access. Returns subnet ID.
|
|
524
|
+
"""
|
|
525
|
+
|
|
526
|
+
vcn = get_or_create_vcn(f"dstack-{project_name}-default-vcn", compartment_id, client)
|
|
527
|
+
internet_gateway = get_or_create_internet_gateway(
|
|
528
|
+
f"dstack-{project_name}-default-internet-gateway", vcn.id, compartment_id, client
|
|
529
|
+
)
|
|
530
|
+
update_route_table(vcn.default_route_table_id, internet_gateway.id, client)
|
|
531
|
+
subnet = get_or_create_subnet(
|
|
532
|
+
f"dstack-{project_name}-default-subnet", vcn.id, compartment_id, client
|
|
533
|
+
)
|
|
534
|
+
return subnet.id
|
|
535
|
+
|
|
536
|
+
|
|
537
|
+
def get_or_create_vcn(
|
|
538
|
+
name: str, compartment_id: str, client: oci.core.VirtualNetworkClient
|
|
539
|
+
) -> oci.core.models.Vcn:
|
|
540
|
+
query_results = chain_paginated_responses(
|
|
541
|
+
client.list_vcns, compartment_id=compartment_id, display_name=name
|
|
542
|
+
)
|
|
543
|
+
if vcn := next(query_results, None):
|
|
544
|
+
return vcn
|
|
545
|
+
|
|
546
|
+
return client.create_vcn(
|
|
547
|
+
oci.core.models.CreateVcnDetails(
|
|
548
|
+
cidr_blocks=[VCN_CIDR],
|
|
549
|
+
compartment_id=compartment_id,
|
|
550
|
+
display_name=name,
|
|
551
|
+
)
|
|
552
|
+
).data
|
|
553
|
+
|
|
554
|
+
|
|
555
|
+
def get_or_create_subnet(
|
|
556
|
+
name: str, vcn_id: str, compartment_id: str, client: oci.core.VirtualNetworkClient
|
|
557
|
+
) -> oci.core.models.Subnet:
|
|
558
|
+
query_results = chain_paginated_responses(
|
|
559
|
+
client.list_subnets, compartment_id=compartment_id, display_name=name
|
|
560
|
+
)
|
|
561
|
+
if subnet := next(query_results, None):
|
|
562
|
+
return subnet
|
|
563
|
+
|
|
564
|
+
return client.create_subnet(
|
|
565
|
+
oci.core.models.CreateSubnetDetails(
|
|
566
|
+
cidr_block=VCN_CIDR,
|
|
567
|
+
compartment_id=compartment_id,
|
|
568
|
+
display_name=name,
|
|
569
|
+
vcn_id=vcn_id,
|
|
570
|
+
)
|
|
571
|
+
).data
|
|
572
|
+
|
|
573
|
+
|
|
574
|
+
def get_or_create_internet_gateway(
|
|
575
|
+
name: str, vcn_id: str, compartment_id: str, client: oci.core.VirtualNetworkClient
|
|
576
|
+
) -> oci.core.models.InternetGateway:
|
|
577
|
+
query_results = chain_paginated_responses(
|
|
578
|
+
client.list_internet_gateways,
|
|
579
|
+
compartment_id=compartment_id,
|
|
580
|
+
vcn_id=vcn_id,
|
|
581
|
+
display_name=name,
|
|
582
|
+
)
|
|
583
|
+
if gateway := next(query_results, None):
|
|
584
|
+
return gateway
|
|
585
|
+
|
|
586
|
+
return client.create_internet_gateway(
|
|
587
|
+
oci.core.models.CreateInternetGatewayDetails(
|
|
588
|
+
compartment_id=compartment_id, display_name=name, vcn_id=vcn_id, is_enabled=True
|
|
589
|
+
)
|
|
590
|
+
).data
|
|
591
|
+
|
|
592
|
+
|
|
593
|
+
def update_route_table(
|
|
594
|
+
route_table_id: str, internet_gateway_id: str, client: oci.core.VirtualNetworkClient
|
|
595
|
+
) -> oci.core.models.RouteTable:
|
|
596
|
+
return client.update_route_table(
|
|
597
|
+
route_table_id,
|
|
598
|
+
oci.core.models.UpdateRouteTableDetails(
|
|
599
|
+
route_rules=[
|
|
600
|
+
oci.core.models.RouteRule(
|
|
601
|
+
destination="0.0.0.0/0", network_entity_id=internet_gateway_id
|
|
602
|
+
)
|
|
603
|
+
]
|
|
604
|
+
),
|
|
605
|
+
).data
|
|
606
|
+
|
|
607
|
+
|
|
608
|
+
def get_or_create_security_group(
|
|
609
|
+
name: str, vcn_id: str, compartment_id: str, client: oci.core.VirtualNetworkClient
|
|
610
|
+
) -> oci.core.models.NetworkSecurityGroup:
|
|
611
|
+
query_results = chain_paginated_responses(
|
|
612
|
+
client.list_network_security_groups,
|
|
613
|
+
display_name=name,
|
|
614
|
+
vcn_id=vcn_id,
|
|
615
|
+
compartment_id=compartment_id,
|
|
616
|
+
)
|
|
617
|
+
if security_group := next(query_results, None):
|
|
618
|
+
return security_group
|
|
619
|
+
|
|
620
|
+
return client.create_network_security_group(
|
|
621
|
+
oci.core.models.CreateNetworkSecurityGroupDetails(
|
|
622
|
+
display_name=name, vcn_id=vcn_id, compartment_id=compartment_id
|
|
623
|
+
)
|
|
624
|
+
).data
|
|
625
|
+
|
|
626
|
+
|
|
627
|
+
def update_security_group_rules_for_runner_instances(
|
|
628
|
+
security_group_id: str, client: oci.core.VirtualNetworkClient
|
|
629
|
+
) -> None:
|
|
630
|
+
# These rules are combined with subnet's default Security List that allows
|
|
631
|
+
# ingress TCP on port 22 from anywhere
|
|
632
|
+
rules = [
|
|
633
|
+
SecurityRule(
|
|
634
|
+
description="Allow all traffic within this security group",
|
|
635
|
+
direction=oci.core.models.AddSecurityRuleDetails.DIRECTION_INGRESS,
|
|
636
|
+
source_type=oci.core.models.AddSecurityRuleDetails.SOURCE_TYPE_NETWORK_SECURITY_GROUP,
|
|
637
|
+
source=security_group_id,
|
|
638
|
+
protocol="all",
|
|
639
|
+
),
|
|
640
|
+
]
|
|
641
|
+
update_security_group_rules(security_group_id, rules, client)
|
|
642
|
+
|
|
643
|
+
|
|
644
|
+
def update_security_group_rules(
|
|
645
|
+
security_group_id: str, rules: Collection[SecurityRule], client: oci.core.VirtualNetworkClient
|
|
646
|
+
) -> None:
|
|
647
|
+
"""
|
|
648
|
+
Ensure the group `security_group_id` has all `rules` and no other rules
|
|
649
|
+
"""
|
|
650
|
+
|
|
651
|
+
existing_rules = list_security_group_rules(security_group_id, client)
|
|
652
|
+
if len(existing_rules) == len(rules) and set(
|
|
653
|
+
map(SecurityRule.from_sdk_rule, existing_rules)
|
|
654
|
+
) == set(rules):
|
|
655
|
+
return
|
|
656
|
+
|
|
657
|
+
add_security_group_rules(security_group_id, rules, client)
|
|
658
|
+
remove_security_group_rules(security_group_id, (r.id for r in existing_rules), client)
|
|
659
|
+
|
|
660
|
+
|
|
661
|
+
def list_security_group_rules(
|
|
662
|
+
security_group_id: str, client: oci.core.VirtualNetworkClient
|
|
663
|
+
) -> List[oci.core.models.SecurityRule]:
|
|
664
|
+
return list(
|
|
665
|
+
chain_paginated_responses(
|
|
666
|
+
client.list_network_security_group_security_rules, security_group_id
|
|
667
|
+
)
|
|
668
|
+
)
|
|
669
|
+
|
|
670
|
+
|
|
671
|
+
def add_security_group_rules(
|
|
672
|
+
security_group_id: str, rules: Iterable[SecurityRule], client: oci.core.VirtualNetworkClient
|
|
673
|
+
) -> None:
|
|
674
|
+
rules_details = map(SecurityRule.to_sdk_add_rule_details, rules)
|
|
675
|
+
for batch in batched(rules_details, ADD_SECURITY_RULES_MAX_CHUNK_SIZE):
|
|
676
|
+
client.add_network_security_group_security_rules(
|
|
677
|
+
security_group_id,
|
|
678
|
+
oci.core.models.AddNetworkSecurityGroupSecurityRulesDetails(security_rules=batch),
|
|
679
|
+
)
|
|
680
|
+
|
|
681
|
+
|
|
682
|
+
def remove_security_group_rules(
|
|
683
|
+
security_group_id: str, rule_ids: Iterable[str], client: oci.core.VirtualNetworkClient
|
|
684
|
+
) -> None:
|
|
685
|
+
for batch in batched(rule_ids, REMOVE_SECURITY_RULES_MAX_CHUNK_SIZE):
|
|
686
|
+
client.remove_network_security_group_security_rules(
|
|
687
|
+
security_group_id,
|
|
688
|
+
oci.core.models.RemoveNetworkSecurityGroupSecurityRulesDetails(
|
|
689
|
+
security_rule_ids=batch
|
|
690
|
+
),
|
|
691
|
+
)
|
|
692
|
+
|
|
693
|
+
|
|
694
|
+
def get_or_create_bucket(
|
|
695
|
+
namespace: str, name: str, compartment_id: str, client: oci.object_storage.ObjectStorageClient
|
|
696
|
+
) -> oci.object_storage.models.Bucket:
|
|
697
|
+
try:
|
|
698
|
+
return client.get_bucket(namespace, name).data
|
|
699
|
+
except oci.exceptions.ServiceError as e:
|
|
700
|
+
if e.code != "BucketNotFound":
|
|
701
|
+
raise
|
|
702
|
+
return client.create_bucket(
|
|
703
|
+
namespace,
|
|
704
|
+
oci.object_storage.models.CreateBucketDetails(name=name, compartment_id=compartment_id),
|
|
705
|
+
).data
|
|
706
|
+
|
|
707
|
+
|
|
708
|
+
def create_pre_authenticated_request(
|
|
709
|
+
name: str,
|
|
710
|
+
namespace: str,
|
|
711
|
+
bucket_name: str,
|
|
712
|
+
object_name: str,
|
|
713
|
+
time_expires: datetime.datetime,
|
|
714
|
+
client: oci.object_storage.ObjectStorageClient,
|
|
715
|
+
) -> oci.object_storage.models.PreauthenticatedRequest:
|
|
716
|
+
return client.create_preauthenticated_request(
|
|
717
|
+
namespace,
|
|
718
|
+
bucket_name,
|
|
719
|
+
CreatePreauthenticatedRequestDetails(
|
|
720
|
+
name=name,
|
|
721
|
+
object_name=object_name,
|
|
722
|
+
access_type=CreatePreauthenticatedRequestDetails.ACCESS_TYPE_OBJECT_READ,
|
|
723
|
+
time_expires=time_expires,
|
|
724
|
+
),
|
|
725
|
+
).data
|
|
726
|
+
|
|
727
|
+
|
|
728
|
+
def delete_bucket(
|
|
729
|
+
namespace: str, bucket_name: str, client: oci.object_storage.ObjectStorageClient
|
|
730
|
+
) -> None:
|
|
731
|
+
par_ids = {
|
|
732
|
+
par.id
|
|
733
|
+
for par in chain_paginated_responses(
|
|
734
|
+
client.list_preauthenticated_requests, namespace, bucket_name
|
|
735
|
+
)
|
|
736
|
+
}
|
|
737
|
+
for par_id in par_ids:
|
|
738
|
+
client.delete_preauthenticated_request(namespace, bucket_name, par_id)
|
|
739
|
+
|
|
740
|
+
objects: List[oci.object_storage.models.ObjectSummary]
|
|
741
|
+
while objects := client.list_objects(
|
|
742
|
+
namespace, bucket_name, limit=LIST_OBJECTS_MAX_LIMIT
|
|
743
|
+
).data.objects:
|
|
744
|
+
for obj in objects:
|
|
745
|
+
client.delete_object(namespace, bucket_name, obj.name)
|
|
746
|
+
|
|
747
|
+
client.delete_bucket(namespace, bucket_name)
|
|
748
|
+
|
|
749
|
+
|
|
750
|
+
def find_image(
|
|
751
|
+
name: str, compartment_id: str, client: oci.core.ComputeClient
|
|
752
|
+
) -> Optional[oci.core.models.Image]:
|
|
753
|
+
query_results = chain_paginated_responses(
|
|
754
|
+
client.list_images, compartment_id=compartment_id, display_name=name
|
|
755
|
+
)
|
|
756
|
+
return next(query_results, None)
|
|
757
|
+
|
|
758
|
+
|
|
759
|
+
def export_image_to_bucket(
|
|
760
|
+
image_id: str,
|
|
761
|
+
storage_namespace: str,
|
|
762
|
+
bucket_name: str,
|
|
763
|
+
object_name: str,
|
|
764
|
+
client: oci.core.ComputeClient,
|
|
765
|
+
) -> str:
|
|
766
|
+
resp: oci.response.Response = client.export_image(
|
|
767
|
+
image_id,
|
|
768
|
+
oci.core.models.ExportImageViaObjectStorageTupleDetails(
|
|
769
|
+
export_format="OCI",
|
|
770
|
+
namespace_name=storage_namespace,
|
|
771
|
+
bucket_name=bucket_name,
|
|
772
|
+
object_name=object_name,
|
|
773
|
+
),
|
|
774
|
+
)
|
|
775
|
+
return resp.headers["opc-work-request-id"]
|
|
776
|
+
|
|
777
|
+
|
|
778
|
+
def import_image_from_uri(
|
|
779
|
+
name: str, full_uri: str, compartment_id: str, client: oci.core.ComputeClient
|
|
780
|
+
) -> str:
|
|
781
|
+
resp: oci.response.Response = client.create_image(
|
|
782
|
+
oci.core.models.CreateImageDetails(
|
|
783
|
+
compartment_id=compartment_id,
|
|
784
|
+
display_name=name,
|
|
785
|
+
image_source_details=oci.core.models.ImageSourceViaObjectStorageUriDetails(
|
|
786
|
+
source_uri=full_uri
|
|
787
|
+
),
|
|
788
|
+
)
|
|
789
|
+
)
|
|
790
|
+
return resp.headers["opc-work-request-id"]
|
|
791
|
+
|
|
792
|
+
|
|
793
|
+
def publish_image_in_marketplace(
|
|
794
|
+
name: str,
|
|
795
|
+
version: str,
|
|
796
|
+
short_description: str,
|
|
797
|
+
os_name: str,
|
|
798
|
+
eula_text: str,
|
|
799
|
+
contact_name: str,
|
|
800
|
+
contact_email: str,
|
|
801
|
+
image_id: str,
|
|
802
|
+
compartment_id: str,
|
|
803
|
+
client: oci.marketplace.MarketplaceClient,
|
|
804
|
+
) -> oci.marketplace.models.Publication:
|
|
805
|
+
return client.create_publication(
|
|
806
|
+
create_publication_details=oci.marketplace.models.CreatePublicationDetails(
|
|
807
|
+
listing_type=oci.marketplace.models.CreatePublicationDetails.LISTING_TYPE_COMMUNITY,
|
|
808
|
+
name=name,
|
|
809
|
+
short_description=short_description,
|
|
810
|
+
support_contacts=[
|
|
811
|
+
oci.marketplace.models.SupportContact(
|
|
812
|
+
name=contact_name,
|
|
813
|
+
email=contact_email,
|
|
814
|
+
)
|
|
815
|
+
],
|
|
816
|
+
compartment_id=compartment_id,
|
|
817
|
+
package_details=oci.marketplace.models.CreateImagePublicationPackage(
|
|
818
|
+
package_version=version,
|
|
819
|
+
operating_system=oci.marketplace.models.OperatingSystem(name=os_name),
|
|
820
|
+
eula=[
|
|
821
|
+
oci.marketplace.models.TextBasedEula(
|
|
822
|
+
eula_type="TEXT",
|
|
823
|
+
license_text=eula_text,
|
|
824
|
+
)
|
|
825
|
+
],
|
|
826
|
+
image_id=image_id,
|
|
827
|
+
),
|
|
828
|
+
is_agreement_acknowledged=True,
|
|
829
|
+
),
|
|
830
|
+
).data
|
|
831
|
+
|
|
832
|
+
|
|
833
|
+
def list_work_request_errors(
|
|
834
|
+
work_request_id: str, client: oci.work_requests.WorkRequestClient
|
|
835
|
+
) -> List[oci.work_requests.models.WorkRequestError]:
|
|
836
|
+
return list(chain_paginated_responses(client.list_work_request_errors, work_request_id))
|