@@ -24,7 +24,8 @@ def __init__(self,
2424 os_volume_id : str ,
2525 gpu_memory : dict ,
2626 location : str = "FIN1" ,
27- startup_script_id : str = None
27+ startup_script_id : str = None ,
28+ is_spot : bool = False
2829 ) -> None :
2930 """Initialize the instance object
3031
@@ -64,6 +65,8 @@ def __init__(self,
6465 :type location: str, optional
6566 :param startup_script_id: startup script id, defaults to None
6667 :type startup_script_id: str, optional
68+ :param is_spot: is this a spot instance, defaults to None
69+ :type is_spot: bool, optional
6770 """
6871 self ._id = id
6972 self ._instance_type = instance_type
@@ -83,6 +86,7 @@ def __init__(self,
8386 self ._storage = storage
8487 self ._os_volume_id = os_volume_id
8588 self ._gpu_memory = gpu_memory
89+ self ._is_spot = is_spot
8690
8791 @property
8892 def id (self ) -> str :
@@ -246,6 +250,14 @@ def gpu_memory(self) -> dict:
246250 """
247251 return self ._gpu_memory
248252
253+ @property
254+ def is_spot (self ) -> bool :
255+ """Is this a spot instance
256+
257+ :return: is spot details
258+ :rtype: bool
259+ """
260+ return self ._is_spot
249261
250262class InstancesService :
251263 """A service for interacting with the instances endpoint"""
@@ -281,7 +293,8 @@ def get(self, status: str = None) -> List[Instance]:
281293 memory = instance_dict ['memory' ],
282294 storage = instance_dict ['storage' ],
283295 os_volume_id = instance_dict ['os_volume_id' ] if 'os_volume_id' in instance_dict else None ,
284- gpu_memory = instance_dict ['gpu_memory' ] if 'gpu_memory' in instance_dict else None
296+ gpu_memory = instance_dict ['gpu_memory' ] if 'gpu_memory' in instance_dict else None ,
297+ is_spot = instance_dict ['is_spot' ] if 'is_spot' in instance_dict else False
285298 ), instances_dict ))
286299 return instances
287300
@@ -313,8 +326,8 @@ def get_by_id(self, id: str) -> Instance:
313326 memory = instance_dict ['memory' ],
314327 storage = instance_dict ['storage' ],
315328 os_volume_id = instance_dict ['os_volume_id' ] if 'os_volume_id' in instance_dict else None ,
316- gpu_memory = instance_dict ['gpu_memory' ] if 'gpu_memory' in instance_dict else None
317-
329+ gpu_memory = instance_dict ['gpu_memory' ] if 'gpu_memory' in instance_dict else None ,
330+ is_spot = instance_dict [ 'is_spot' ] if 'is_spot' in instance_dict else False
318331 )
319332 return instance
320333
@@ -327,7 +340,8 @@ def create(self,
327340 location : str = "FIN1" ,
328341 startup_script_id : str = None ,
329342 volumes : List [Dict ] = None ,
330- os_volume : Dict = None ) -> Instance :
343+ os_volume : Dict = None ,
344+ is_spot : bool = False ) -> Instance :
331345 """Creates (deploys) a new instance
332346
333347 :param instance_type: instance type. e.g. '8V100.48M'
@@ -348,6 +362,8 @@ def create(self,
348362 :type volumes: List[Dict], optional
349363 :param os_volume: OS volume details, defaults to None
350364 :type os_volume: Dict, optional
365+ :param is_spot: Is spot instance
366+ :type is_spot: bool, optional
351367 :return: the new instance object
352368 :rtype: id
353369 """
@@ -360,7 +376,8 @@ def create(self,
360376 "description" : description ,
361377 "location" : location ,
362378 "os_volume" : os_volume ,
363- "volumes" : volumes
379+ "volumes" : volumes ,
380+ "is_spot" : is_spot
364381 }
365382 id = self ._http_client .post (INSTANCES_ENDPOINT , json = payload ).text
366383 instance = self .get_by_id (id )
0 commit comments