Skip to content

Commit 8f5b1b1

Browse files
committed
feat: add from_name helpers to Runtime and Region
1 parent 741969c commit 8f5b1b1

File tree

2 files changed

+13
-18
lines changed

2 files changed

+13
-18
lines changed

wherobots/db/region.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,10 @@
44
class Region(Enum):
55
AWS_US_WEST_2 = "aws-us-west-2"
66
AWS_EU_WEST_1 = "aws-eu-west-1"
7+
8+
9+
_NAME_TO_ENUM = {region.value: region for region in Region}
10+
11+
12+
def from_name(region: str) -> Region:
13+
return _NAME_TO_ENUM[region]

wherobots/db/runtime.py

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -22,21 +22,9 @@ class Runtime(Enum):
2222
SMALL_A10_GPU = "small-a10-gpu"
2323
MEDIUM_A10_GPU = "medium-a10-gpu"
2424

25-
# Deprecated names; will be removed in a later major version.
26-
SEDONA = "tiny"
27-
SAN_FRANCISCO = "small"
28-
NEW_YORK = "medium"
29-
CAIRO = "large"
30-
DELHI = "x-large"
31-
TOKYO = "2x-large"
32-
ATLANTIS = "4x-large"
33-
34-
NEW_YORK_HIMEM = "medium-himem"
35-
CAIRO_HIMEM = "large-himem"
36-
DELHI_HIMEM = "x-large-himem"
37-
TOKYO_HIMEM = "2x-large-himem"
38-
ATLANTIS_HIMEM = "4x-large-himem"
39-
40-
SEDONA_GPU = "tiny-a10-gpu"
41-
SAN_FRANCISCO_GPU = "small-a10-gpu"
42-
NEW_YORK_GPU = "medium-a10-gpu"
25+
26+
_NAME_TO_ENUM = {runtime.value: runtime for runtime in Runtime}
27+
28+
29+
def from_name(runtime: str) -> Runtime:
30+
return _NAME_TO_ENUM[runtime]

0 commit comments

Comments
 (0)