Skip to content

Commit f929891

Browse files
feat(instance): add GPU information in ServerType (#901)
Co-authored-by: Laure-di <[email protected]>
1 parent 0abb8a9 commit f929891

File tree

6 files changed

+128
-18
lines changed

6 files changed

+128
-18
lines changed

scaleway-async/scaleway_async/instance/v1/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
from .types import VolumeServer
5656
from .types import SnapshotBaseVolume
5757
from .types import ServerTypeCapabilities
58+
from .types import ServerTypeGPUInfo
5859
from .types import ServerTypeNetwork
5960
from .types import ServerTypeVolumeConstraintsByType
6061
from .types import VolumeTypeCapabilities
@@ -253,6 +254,7 @@
253254
"VolumeServer",
254255
"SnapshotBaseVolume",
255256
"ServerTypeCapabilities",
257+
"ServerTypeGPUInfo",
256258
"ServerTypeNetwork",
257259
"ServerTypeVolumeConstraintsByType",
258260
"VolumeTypeCapabilities",

scaleway-async/scaleway_async/instance/v1/marshalling.py

Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@
8282
ServerTypeNetworkInterface,
8383
ServerTypeVolumeConstraintSizes,
8484
ServerTypeCapabilities,
85+
ServerTypeGPUInfo,
8586
ServerTypeNetwork,
8687
ServerTypeVolumeConstraintsByType,
8788
ServerType,
@@ -2060,6 +2061,29 @@ def unmarshal_ServerTypeCapabilities(data: Any) -> ServerTypeCapabilities:
20602061
return ServerTypeCapabilities(**args)
20612062

20622063

2064+
def unmarshal_ServerTypeGPUInfo(data: Any) -> ServerTypeGPUInfo:
2065+
if not isinstance(data, dict):
2066+
raise TypeError(
2067+
"Unmarshalling the type 'ServerTypeGPUInfo' failed as data isn't a dictionary."
2068+
)
2069+
2070+
args: Dict[str, Any] = {}
2071+
2072+
field = data.get("gpu_manufacturer", None)
2073+
if field is not None:
2074+
args["gpu_manufacturer"] = field
2075+
2076+
field = data.get("gpu_name", None)
2077+
if field is not None:
2078+
args["gpu_name"] = field
2079+
2080+
field = data.get("gpu_memory", None)
2081+
if field is not None:
2082+
args["gpu_memory"] = field
2083+
2084+
return ServerTypeGPUInfo(**args)
2085+
2086+
20632087
def unmarshal_ServerTypeNetwork(data: Any) -> ServerTypeNetwork:
20642088
if not isinstance(data, dict):
20652089
raise TypeError(
@@ -2152,10 +2176,6 @@ def unmarshal_ServerType(data: Any) -> ServerType:
21522176
if field is not None:
21532177
args["baremetal"] = field
21542178

2155-
field = data.get("end_of_service", None)
2156-
if field is not None:
2157-
args["end_of_service"] = field
2158-
21592179
field = data.get("per_volume_constraint", None)
21602180
if field is not None:
21612181
args["per_volume_constraint"] = unmarshal_ServerTypeVolumeConstraintsByType(
@@ -2176,6 +2196,16 @@ def unmarshal_ServerType(data: Any) -> ServerType:
21762196
else:
21772197
args["gpu"] = None
21782198

2199+
field = data.get("end_of_service", None)
2200+
if field is not None:
2201+
args["end_of_service"] = field
2202+
2203+
field = data.get("gpu_info", None)
2204+
if field is not None:
2205+
args["gpu_info"] = unmarshal_ServerTypeGPUInfo(field)
2206+
else:
2207+
args["gpu_info"] = None
2208+
21792209
field = data.get("network", None)
21802210
if field is not None:
21812211
args["network"] = unmarshal_ServerTypeNetwork(field)

scaleway-async/scaleway_async/instance/v1/types.py

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -714,6 +714,24 @@ class ServerTypeCapabilities:
714714
"""
715715

716716

717+
@dataclass
718+
class ServerTypeGPUInfo:
719+
gpu_manufacturer: str
720+
"""
721+
GPU manufacturer.
722+
"""
723+
724+
gpu_name: str
725+
"""
726+
GPU model name.
727+
"""
728+
729+
gpu_memory: int
730+
"""
731+
RAM of a single GPU, in bytes.
732+
"""
733+
734+
717735
@dataclass
718736
class ServerTypeNetwork:
719737
interfaces: List[ServerTypeNetworkInterface]
@@ -1342,11 +1360,6 @@ class ServerType:
13421360
True if it is a baremetal Instance.
13431361
"""
13441362

1345-
end_of_service: bool
1346-
"""
1347-
True if this Instance type has reached end of service.
1348-
"""
1349-
13501363
per_volume_constraint: Optional[ServerTypeVolumeConstraintsByType]
13511364
"""
13521365
Additional volume constraints.
@@ -1362,6 +1375,16 @@ class ServerType:
13621375
Number of GPU.
13631376
"""
13641377

1378+
end_of_service: bool
1379+
"""
1380+
True if this Instance type has reached end of service.
1381+
"""
1382+
1383+
gpu_info: Optional[ServerTypeGPUInfo]
1384+
"""
1385+
GPU information.
1386+
"""
1387+
13651388
network: Optional[ServerTypeNetwork]
13661389
"""
13671390
Network available for the Instance.

scaleway/scaleway/instance/v1/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
from .types import VolumeServer
5656
from .types import SnapshotBaseVolume
5757
from .types import ServerTypeCapabilities
58+
from .types import ServerTypeGPUInfo
5859
from .types import ServerTypeNetwork
5960
from .types import ServerTypeVolumeConstraintsByType
6061
from .types import VolumeTypeCapabilities
@@ -253,6 +254,7 @@
253254
"VolumeServer",
254255
"SnapshotBaseVolume",
255256
"ServerTypeCapabilities",
257+
"ServerTypeGPUInfo",
256258
"ServerTypeNetwork",
257259
"ServerTypeVolumeConstraintsByType",
258260
"VolumeTypeCapabilities",

scaleway/scaleway/instance/v1/marshalling.py

Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@
8282
ServerTypeNetworkInterface,
8383
ServerTypeVolumeConstraintSizes,
8484
ServerTypeCapabilities,
85+
ServerTypeGPUInfo,
8586
ServerTypeNetwork,
8687
ServerTypeVolumeConstraintsByType,
8788
ServerType,
@@ -2060,6 +2061,29 @@ def unmarshal_ServerTypeCapabilities(data: Any) -> ServerTypeCapabilities:
20602061
return ServerTypeCapabilities(**args)
20612062

20622063

2064+
def unmarshal_ServerTypeGPUInfo(data: Any) -> ServerTypeGPUInfo:
2065+
if not isinstance(data, dict):
2066+
raise TypeError(
2067+
"Unmarshalling the type 'ServerTypeGPUInfo' failed as data isn't a dictionary."
2068+
)
2069+
2070+
args: Dict[str, Any] = {}
2071+
2072+
field = data.get("gpu_manufacturer", None)
2073+
if field is not None:
2074+
args["gpu_manufacturer"] = field
2075+
2076+
field = data.get("gpu_name", None)
2077+
if field is not None:
2078+
args["gpu_name"] = field
2079+
2080+
field = data.get("gpu_memory", None)
2081+
if field is not None:
2082+
args["gpu_memory"] = field
2083+
2084+
return ServerTypeGPUInfo(**args)
2085+
2086+
20632087
def unmarshal_ServerTypeNetwork(data: Any) -> ServerTypeNetwork:
20642088
if not isinstance(data, dict):
20652089
raise TypeError(
@@ -2152,10 +2176,6 @@ def unmarshal_ServerType(data: Any) -> ServerType:
21522176
if field is not None:
21532177
args["baremetal"] = field
21542178

2155-
field = data.get("end_of_service", None)
2156-
if field is not None:
2157-
args["end_of_service"] = field
2158-
21592179
field = data.get("per_volume_constraint", None)
21602180
if field is not None:
21612181
args["per_volume_constraint"] = unmarshal_ServerTypeVolumeConstraintsByType(
@@ -2176,6 +2196,16 @@ def unmarshal_ServerType(data: Any) -> ServerType:
21762196
else:
21772197
args["gpu"] = None
21782198

2199+
field = data.get("end_of_service", None)
2200+
if field is not None:
2201+
args["end_of_service"] = field
2202+
2203+
field = data.get("gpu_info", None)
2204+
if field is not None:
2205+
args["gpu_info"] = unmarshal_ServerTypeGPUInfo(field)
2206+
else:
2207+
args["gpu_info"] = None
2208+
21792209
field = data.get("network", None)
21802210
if field is not None:
21812211
args["network"] = unmarshal_ServerTypeNetwork(field)

scaleway/scaleway/instance/v1/types.py

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -714,6 +714,24 @@ class ServerTypeCapabilities:
714714
"""
715715

716716

717+
@dataclass
718+
class ServerTypeGPUInfo:
719+
gpu_manufacturer: str
720+
"""
721+
GPU manufacturer.
722+
"""
723+
724+
gpu_name: str
725+
"""
726+
GPU model name.
727+
"""
728+
729+
gpu_memory: int
730+
"""
731+
RAM of a single GPU, in bytes.
732+
"""
733+
734+
717735
@dataclass
718736
class ServerTypeNetwork:
719737
interfaces: List[ServerTypeNetworkInterface]
@@ -1342,11 +1360,6 @@ class ServerType:
13421360
True if it is a baremetal Instance.
13431361
"""
13441362

1345-
end_of_service: bool
1346-
"""
1347-
True if this Instance type has reached end of service.
1348-
"""
1349-
13501363
per_volume_constraint: Optional[ServerTypeVolumeConstraintsByType]
13511364
"""
13521365
Additional volume constraints.
@@ -1362,6 +1375,16 @@ class ServerType:
13621375
Number of GPU.
13631376
"""
13641377

1378+
end_of_service: bool
1379+
"""
1380+
True if this Instance type has reached end of service.
1381+
"""
1382+
1383+
gpu_info: Optional[ServerTypeGPUInfo]
1384+
"""
1385+
GPU information.
1386+
"""
1387+
13651388
network: Optional[ServerTypeNetwork]
13661389
"""
13671390
Network available for the Instance.

0 commit comments

Comments
 (0)