Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,9 @@ include = [
"src/dstack/plugins",
"src/dstack/_internal/server",
"src/dstack/_internal/core/services",
"src/dstack/_internal/cli/commands",
"src/dstack/_internal/core/backends/kubernetes",
"src/dstack/_internal/cli/services/configurators",
"src/dstack/_internal/cli/commands",
]
ignore = [
"src/dstack/_internal/server/migrations/versions",
Expand Down
32 changes: 23 additions & 9 deletions src/dstack/_internal/core/backends/base/compute.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,16 @@
import threading
from abc import ABC, abstractmethod
from collections.abc import Iterable
from enum import Enum
from functools import lru_cache
from pathlib import Path
from typing import Callable, Dict, List, Literal, Optional
from typing import Callable, Dict, List, Optional

import git
import requests
import yaml
from cachetools import TTLCache, cachedmethod
from gpuhunt import CPUArchitecture

from dstack._internal import settings
from dstack._internal.core.backends.base.offers import filter_offers_by_requirements
Expand Down Expand Up @@ -49,7 +51,21 @@
DSTACK_RUNNER_BINARY_NAME = "dstack-runner"
DEFAULT_PRIVATE_SUBNETS = ("10.0.0.0/8", "172.16.0.0/12", "192.168.0.0/16")

GoArchType = Literal["amd64", "arm64"]

class GoArchType(str, Enum):
"""
A subset of GOARCH values
"""

AMD64 = "amd64"
ARM64 = "arm64"

def to_cpu_architecture(self) -> CPUArchitecture:
if self == self.AMD64:
return CPUArchitecture.X86
if self == self.ARM64:
return CPUArchitecture.ARM
assert False, self


class Compute(ABC):
Expand Down Expand Up @@ -688,14 +704,14 @@ def normalize_arch(arch: Optional[str] = None) -> GoArchType:
If the arch is not specified, falls back to `amd64`.
"""
if not arch:
return "amd64"
return GoArchType.AMD64
arch_lower = arch.lower()
if "32" in arch_lower or arch_lower in ["i386", "i686"]:
raise ValueError(f"32-bit architectures are not supported: {arch}")
if arch_lower.startswith("x86") or arch_lower.startswith("amd"):
return "amd64"
return GoArchType.AMD64
if arch_lower.startswith("arm") or arch_lower.startswith("aarch"):
return "arm64"
return GoArchType.ARM64
raise ValueError(f"Unsupported architecture: {arch}")


Expand All @@ -711,8 +727,7 @@ def get_dstack_runner_download_url(arch: Optional[str] = None) -> str:
"/{version}/binaries/dstack-runner-linux-{arch}"
)
version = get_dstack_runner_version()
arch = normalize_arch(arch)
return url_template.format(version=version, arch=arch)
return url_template.format(version=version, arch=normalize_arch(arch).value)


def get_dstack_shim_download_url(arch: Optional[str] = None) -> str:
Expand All @@ -727,8 +742,7 @@ def get_dstack_shim_download_url(arch: Optional[str] = None) -> str:
"/{version}/binaries/dstack-shim-linux-{arch}"
)
version = get_dstack_runner_version()
arch = normalize_arch(arch)
return url_template.format(version=version, arch=arch)
return url_template.format(version=version, arch=normalize_arch(arch).value)


def get_setup_cloud_instance_commands(
Expand Down
Loading
Loading