-
Notifications
You must be signed in to change notification settings - Fork 87
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
84 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
from enum import Enum | ||
|
||
|
||
class CloudProvider(Enum): | ||
AWS = "aws" | ||
GCP = "gcp" | ||
AZURE = "azure" | ||
|
||
|
||
class AwsRegion(Enum): | ||
US_EAST_1 = "us-east-1" | ||
US_WEST_2 = "us-west-2" | ||
EU_WEST_1 = "eu-west-1" | ||
|
||
|
||
class GcpRegion(Enum): | ||
US_CENTRAL1 = "us-central1" | ||
EUROPE_WEST4 = "europe-west4" | ||
|
||
|
||
class AzureRegion(Enum): | ||
EAST_US = "eastus2" | ||
|
||
|
||
class PodIndexEnvironment(Enum): | ||
US_WEST1_GCP = "us-west1-gcp" | ||
US_CENTRAL1_GCP = "us-central1-gcp" | ||
US_WEST4_GCP = "us-west4-gcp" | ||
US_EAST4_GCP = "us-east4-gcp" | ||
NORTHAMERICA_NORTHEAST1_GCP = "northamerica-northeast1-gcp" | ||
ASIA_NORTHEAST1_GCP = "asia-northeast1-gcp" | ||
ASIA_SOUTHEAST1_GCP = "asia-southeast1-gcp" | ||
US_EAST1_GCP = "us-east1-gcp" | ||
EU_WEST1_GCP = "eu-west1-gcp" | ||
EU_WEST4_GCP = "eu-west4-gcp" | ||
US_EAST1_AWS = "us-east-1-aws" | ||
EASTUS_AZURE = "eastus-azure" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,25 @@ | ||
from typing import NamedTuple | ||
from dataclasses import dataclass | ||
from typing import Union | ||
from enum import Enum | ||
|
||
from .clouds import CloudProvider, AwsRegion, GcpRegion, AzureRegion | ||
|
||
class ServerlessSpec(NamedTuple): | ||
|
||
@dataclass(frozen=True) | ||
class ServerlessSpec: | ||
cloud: str | ||
region: str | ||
|
||
def __init__( | ||
self, | ||
cloud: Union[CloudProvider, str], | ||
region: Union[AwsRegion, GcpRegion, AzureRegion, str], | ||
): | ||
# Convert Enums to their string values if necessary | ||
object.__setattr__(self, "cloud", cloud.value if isinstance(cloud, Enum) else str(cloud)) | ||
object.__setattr__( | ||
self, "region", region.value if isinstance(region, Enum) else str(region) | ||
) | ||
|
||
def asdict(self): | ||
return {"serverless": self._asdict()} | ||
return {"serverless": {"cloud": self.cloud, "region": self.region}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters