2020
2121from aleph_message .models import (
2222 AlephMessage ,
23+ ExecutableContent ,
2324 ItemHash ,
2425 ItemType ,
25- MessagesResponse ,
2626 MessageType ,
2727 Payment ,
2828 PostMessage ,
4141from aleph .sdk .utils import extended_json_encoder
4242
4343from ..query .filters import MessageFilter , PostFilter
44- from ..query .responses import PostsResponse , PriceResponse
44+ from ..query .responses import MessagesResponse , PostsResponse , PriceResponse
4545from ..types import GenericMessage , StorageEnum
4646from ..utils import Writable , compute_sha256
4747
@@ -110,7 +110,7 @@ async def get_posts_iterator(
110110 )
111111 page += 1
112112 for post in resp .posts :
113- yield post
113+ yield post # type: ignore
114114
115115 @abstractmethod
116116 async def download_file (self , file_hash : str ) -> bytes :
@@ -242,6 +242,18 @@ def watch_messages(
242242 """
243243 raise NotImplementedError ("Did you mean to import `AlephHttpClient`?" )
244244
245+ @abstractmethod
246+ def get_estimated_price (
247+ self ,
248+ content : ExecutableContent ,
249+ ) -> Coroutine [Any , Any , PriceResponse ]:
250+ """
251+ Get Instance/Program content estimated price
252+
253+ :param content: Instance or Program content
254+ """
255+ raise NotImplementedError ("Did you mean to import `AlephHttpClient`?" )
256+
245257 @abstractmethod
246258 def get_program_price (
247259 self ,
@@ -265,7 +277,7 @@ async def create_post(
265277 post_type : str ,
266278 ref : Optional [str ] = None ,
267279 address : Optional [str ] = None ,
268- channel : Optional [str ] = None ,
280+ channel : Optional [str ] = settings . DEFAULT_CHANNEL ,
269281 inline : bool = True ,
270282 storage_engine : StorageEnum = StorageEnum .storage ,
271283 sync : bool = False ,
@@ -290,9 +302,9 @@ async def create_post(
290302 async def create_aggregate (
291303 self ,
292304 key : str ,
293- content : Mapping [str , Any ],
305+ content : dict [str , Any ],
294306 address : Optional [str ] = None ,
295- channel : Optional [str ] = None ,
307+ channel : Optional [str ] = settings . DEFAULT_CHANNEL ,
296308 inline : bool = True ,
297309 sync : bool = False ,
298310 ) -> Tuple [AlephMessage , MessageStatus ]:
@@ -302,7 +314,7 @@ async def create_aggregate(
302314 :param key: Key to use to store the content
303315 :param content: Content to store
304316 :param address: Address to use to sign the message
305- :param channel: Channel to use (Default: "TEST ")
317+ :param channel: Channel to use (Default: "ALEPH-CLOUDSOLUTIONS ")
306318 :param inline: Whether to write content inside the message (Default: True)
307319 :param sync: If true, waits for the message to be processed by the API server (Default: False)
308320 """
@@ -321,7 +333,7 @@ async def create_store(
321333 ref : Optional [str ] = None ,
322334 storage_engine : StorageEnum = StorageEnum .storage ,
323335 extra_fields : Optional [dict ] = None ,
324- channel : Optional [str ] = None ,
336+ channel : Optional [str ] = settings . DEFAULT_CHANNEL ,
325337 sync : bool = False ,
326338 ) -> Tuple [AlephMessage , MessageStatus ]:
327339 """
@@ -350,45 +362,45 @@ async def create_program(
350362 program_ref : str ,
351363 entrypoint : str ,
352364 runtime : str ,
353- environment_variables : Optional [Mapping [str , str ]] = None ,
354- storage_engine : StorageEnum = StorageEnum .storage ,
355- channel : Optional [str ] = None ,
365+ metadata : Optional [dict [str , Any ]] = None ,
356366 address : Optional [str ] = None ,
357- sync : bool = False ,
358- memory : Optional [int ] = None ,
359367 vcpus : Optional [int ] = None ,
368+ memory : Optional [int ] = None ,
360369 timeout_seconds : Optional [float ] = None ,
361- persistent : bool = False ,
362- allow_amend : bool = False ,
363370 internet : bool = True ,
371+ allow_amend : bool = False ,
364372 aleph_api : bool = True ,
365373 encoding : Encoding = Encoding .zip ,
374+ persistent : bool = False ,
366375 volumes : Optional [List [Mapping ]] = None ,
367- subscriptions : Optional [List [Mapping ]] = None ,
368- metadata : Optional [Mapping [str , Any ]] = None ,
376+ environment_variables : Optional [dict [str , str ]] = None ,
377+ subscriptions : Optional [List [dict ]] = None ,
378+ sync : bool = False ,
379+ channel : Optional [str ] = settings .DEFAULT_CHANNEL ,
380+ storage_engine : StorageEnum = StorageEnum .storage ,
369381 ) -> Tuple [AlephMessage , MessageStatus ]:
370382 """
371383 Post a (create) PROGRAM message.
372384
373385 :param program_ref: Reference to the program to run
374386 :param entrypoint: Entrypoint to run
375387 :param runtime: Runtime to use
376- :param environment_variables: Environment variables to pass to the program
377- :param storage_engine: Storage engine to use (Default: "storage")
378- :param channel: Channel to use (Default: "TEST")
388+ :param metadata: Metadata to attach to the message
379389 :param address: Address to use (Default: account.get_address())
380- :param sync: If true, waits for the message to be processed by the API server
381- :param memory: Memory in MB for the VM to be allocated (Default: 128)
382390 :param vcpus: Number of vCPUs to allocate (Default: 1)
391+ :param memory: Memory in MB for the VM to be allocated (Default: 128)
383392 :param timeout_seconds: Timeout in seconds (Default: 30.0)
384- :param persistent: Whether the program should be persistent or not (Default: False)
385- :param allow_amend: Whether the deployed VM image may be changed (Default: False)
386393 :param internet: Whether the VM should have internet connectivity. (Default: True)
394+ :param allow_amend: Whether the deployed VM image may be changed (Default: False)
387395 :param aleph_api: Whether the VM needs access to Aleph messages API (Default: True)
388396 :param encoding: Encoding to use (Default: Encoding.zip)
397+ :param persistent: Whether the program should be persistent or not (Default: False)
389398 :param volumes: Volumes to mount
399+ :param environment_variables: Environment variables to pass to the program
390400 :param subscriptions: Patterns of aleph.im messages to forward to the program's event receiver
391- :param metadata: Metadata to attach to the message
401+ :param sync: If true, waits for the message to be processed by the API server
402+ :param channel: Channel to use (Default: "ALEPH-CLOUDSOLUTIONS")
403+ :param storage_engine: Storage engine to use (Default: "storage")
392404 """
393405 raise NotImplementedError (
394406 "Did you mean to import `AuthenticatedAlephHttpClient`?"
@@ -400,9 +412,9 @@ async def create_instance(
400412 rootfs : str ,
401413 rootfs_size : int ,
402414 payment : Optional [Payment ] = None ,
403- environment_variables : Optional [Mapping [str , str ]] = None ,
415+ environment_variables : Optional [dict [str , str ]] = None ,
404416 storage_engine : StorageEnum = StorageEnum .storage ,
405- channel : Optional [str ] = None ,
417+ channel : Optional [str ] = settings . DEFAULT_CHANNEL ,
406418 address : Optional [str ] = None ,
407419 sync : bool = False ,
408420 memory : Optional [int ] = None ,
@@ -416,7 +428,7 @@ async def create_instance(
416428 volumes : Optional [List [Mapping ]] = None ,
417429 volume_persistence : str = "host" ,
418430 ssh_keys : Optional [List [str ]] = None ,
419- metadata : Optional [Mapping [str , Any ]] = None ,
431+ metadata : Optional [dict [str , Any ]] = None ,
420432 requirements : Optional [HostRequirements ] = None ,
421433 ) -> Tuple [AlephMessage , MessageStatus ]:
422434 """
@@ -427,7 +439,7 @@ async def create_instance(
427439 :param payment: Payment method used to pay for the instance
428440 :param environment_variables: Environment variables to pass to the program
429441 :param storage_engine: Storage engine to use (Default: "storage")
430- :param channel: Channel to use (Default: "TEST ")
442+ :param channel: Channel to use (Default: "ALEPH-CLOUDSOLUTIONS ")
431443 :param address: Address to use (Default: account.get_address())
432444 :param sync: If true, waits for the message to be processed by the API server
433445 :param memory: Memory in MB for the VM to be allocated (Default: 2048)
@@ -455,7 +467,7 @@ async def forget(
455467 hashes : List [ItemHash ],
456468 reason : Optional [str ],
457469 storage_engine : StorageEnum = StorageEnum .storage ,
458- channel : Optional [str ] = None ,
470+ channel : Optional [str ] = settings . DEFAULT_CHANNEL ,
459471 address : Optional [str ] = None ,
460472 sync : bool = False ,
461473 ) -> Tuple [AlephMessage , MessageStatus ]:
@@ -468,7 +480,7 @@ async def forget(
468480 :param hashes: Hashes of the messages to forget
469481 :param reason: Reason for forgetting the messages
470482 :param storage_engine: Storage engine to use (Default: "storage")
471- :param channel: Channel to use (Default: "TEST ")
483+ :param channel: Channel to use (Default: "ALEPH-CLOUDSOLUTIONS ")
472484 :param address: Address to use (Default: account.get_address())
473485 :param sync: If true, waits for the message to be processed by the API server (Default: False)
474486 """
@@ -490,7 +502,7 @@ async def generate_signed_message(
490502
491503 :param message_type: Type of the message (PostMessage, ...)
492504 :param content: User-defined content of the message
493- :param channel: Channel to use (Default: "TEST ")
505+ :param channel: Channel to use (Default: "ALEPH-CLOUDSOLUTIONS ")
494506 :param allow_inlining: Whether to allow inlining the content of the message (Default: True)
495507 :param storage_engine: Storage engine to use (Default: "storage")
496508 """
@@ -537,7 +549,7 @@ async def submit(
537549 self ,
538550 content : Dict [str , Any ],
539551 message_type : MessageType ,
540- channel : Optional [str ] = None ,
552+ channel : Optional [str ] = settings . DEFAULT_CHANNEL ,
541553 storage_engine : StorageEnum = StorageEnum .storage ,
542554 allow_inlining : bool = True ,
543555 sync : bool = False ,
@@ -549,7 +561,7 @@ async def submit(
549561
550562 :param content: Content of the message
551563 :param message_type: Type of the message
552- :param channel: Channel to use (Default: "TEST ")
564+ :param channel: Channel to use (Default: "ALEPH-CLOUDSOLUTIONS ")
553565 :param storage_engine: Storage engine to use (Default: "storage")
554566 :param allow_inlining: Whether to allow inlining the content of the message (Default: True)
555567 :param sync: If true, waits for the message to be processed by the API server (Default: False)
0 commit comments