@@ -319,6 +319,9 @@ async def create_program(
319319 vcpus : Optional [int ] = None ,
320320 timeout_seconds : Optional [float ] = None ,
321321 persistent : bool = False ,
322+ allow_amend : bool = False ,
323+ internet : bool = True ,
324+ aleph_api : bool = True ,
322325 encoding : Encoding = Encoding .zip ,
323326 volumes : Optional [List [Mapping ]] = None ,
324327 subscriptions : Optional [List [Mapping ]] = None ,
@@ -340,6 +343,9 @@ async def create_program(
340343 vcpus = vcpus ,
341344 timeout_seconds = timeout_seconds ,
342345 persistent = persistent ,
346+ allow_amend = allow_amend ,
347+ internet = internet ,
348+ aleph_api = aleph_api ,
343349 encoding = encoding ,
344350 volumes = volumes ,
345351 subscriptions = subscriptions ,
@@ -350,6 +356,57 @@ async def create_program(
350356 asyncio .create_task (self .delete_if_rejected (resp .item_hash ))
351357 return resp , status
352358
359+ async def create_instance (
360+ self ,
361+ rootfs : str ,
362+ rootfs_size : int ,
363+ rootfs_name : str ,
364+ environment_variables : Optional [Mapping [str , str ]] = None ,
365+ storage_engine : StorageEnum = StorageEnum .storage ,
366+ channel : Optional [str ] = None ,
367+ address : Optional [str ] = None ,
368+ sync : bool = False ,
369+ memory : Optional [int ] = None ,
370+ vcpus : Optional [int ] = None ,
371+ timeout_seconds : Optional [float ] = None ,
372+ allow_amend : bool = False ,
373+ internet : bool = True ,
374+ aleph_api : bool = True ,
375+ encoding : Encoding = Encoding .zip ,
376+ volumes : Optional [List [Mapping ]] = None ,
377+ volume_persistence : str = "host" ,
378+ ssh_keys : Optional [List [str ]] = None ,
379+ metadata : Optional [Mapping [str , Any ]] = None ,
380+ ) -> Tuple [AlephMessage , MessageStatus ]:
381+ self .check_validity (
382+ MessageType .instance , address , channel , dict (metadata ) if metadata else None
383+ )
384+ resp , status = await self .session .create_instance (
385+ rootfs = rootfs ,
386+ rootfs_size = rootfs_size ,
387+ rootfs_name = rootfs_name ,
388+ environment_variables = environment_variables ,
389+ storage_engine = storage_engine ,
390+ channel = channel ,
391+ address = address ,
392+ sync = sync ,
393+ memory = memory ,
394+ vcpus = vcpus ,
395+ timeout_seconds = timeout_seconds ,
396+ allow_amend = allow_amend ,
397+ internet = internet ,
398+ aleph_api = aleph_api ,
399+ encoding = encoding ,
400+ volumes = volumes ,
401+ volume_persistence = volume_persistence ,
402+ ssh_keys = ssh_keys ,
403+ metadata = metadata ,
404+ )
405+ if status in [MessageStatus .PENDING , MessageStatus .PROCESSED ]:
406+ self .add (resp )
407+ asyncio .create_task (self .delete_if_rejected (resp .item_hash ))
408+ return resp , status
409+
353410 async def forget (
354411 self ,
355412 hashes : List [str ],
0 commit comments