dstack icon indicating copy to clipboard operation
dstack copied to clipboard

Support unified dstack regions that map to cloud regions

Open r4victor opened this issue 4 months ago • 2 comments

#877 allowed users to specify cloud-specific regions via CLI. While it may be convenient if only one backend is configured, if multiple backends are configured, users would need to specify cloud-specific regions for every backend. E.g. separately for aws and gcp:

dstack run . -r us-east-1 -r us-east1

To simplify this, we may introduce aliases for popular regions (a.k.a. dstack regions) that would map to cloud-specific regions. Here's an initial list of aliases we can introduce and with some mapping examples:

* north-america -> us-east-1, , ca-central-1, us-east1, centralus
* south-america -> southamerica-east1, brazilsouth
* europe -> ...
* asia -> ...
* australia -> ...
* middle-east -> ...
* us -> ...

So users can run:

dstack run . -r us

The dstack regions may overlap. For example, both north-america and us include us-east-1, and we should have us because it's easier to specify and north-america because it includes Canada. In future we may introduce more regions, e.g. us-east, germany, etc.

Implementation details:

Backends should implement a mapping from dstack regions to cloud regions. This can be a Backend/Compute/Configurator method. From the implementation perspective, it's probably easier to put it into Configurator since configurators need to deal with regions anyway:

class SomeConfigurator(Configurator):
    def get_regions_mapping(self) -> Dict[DstackRegion, List[str]]:
        return {
            DstackRegion.NORTH_AMERICA: ["centralus", "eastus"],
            DstackRegion.SOUTH_AMERICA: ["brazilsouth"],
        }

A backend may choose to map only some dstack regions – only those it needs to support. If a backend does not implement the mapping at all, it's fine – the dstack regions won't be supported but it should still be possible to specify cloud-specific regions.

r4victor avatar Feb 29 '24 06:02 r4victor