20
20
21
21
from aleph_message .models import (
22
22
AlephMessage ,
23
+ ExecutableContent ,
23
24
ItemHash ,
24
25
ItemType ,
25
- MessagesResponse ,
26
26
MessageType ,
27
27
Payment ,
28
28
PostMessage ,
41
41
from aleph .sdk .utils import extended_json_encoder
42
42
43
43
from ..query .filters import MessageFilter , PostFilter
44
- from ..query .responses import PostsResponse , PriceResponse
44
+ from ..query .responses import MessagesResponse , PostsResponse , PriceResponse
45
45
from ..types import GenericMessage , StorageEnum
46
46
from ..utils import Writable , compute_sha256
47
47
@@ -110,7 +110,7 @@ async def get_posts_iterator(
110
110
)
111
111
page += 1
112
112
for post in resp .posts :
113
- yield post
113
+ yield post # type: ignore
114
114
115
115
@abstractmethod
116
116
async def download_file (self , file_hash : str ) -> bytes :
@@ -242,6 +242,18 @@ def watch_messages(
242
242
"""
243
243
raise NotImplementedError ("Did you mean to import `AlephHttpClient`?" )
244
244
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
+
245
257
@abstractmethod
246
258
def get_program_price (
247
259
self ,
@@ -265,7 +277,7 @@ async def create_post(
265
277
post_type : str ,
266
278
ref : Optional [str ] = None ,
267
279
address : Optional [str ] = None ,
268
- channel : Optional [str ] = None ,
280
+ channel : Optional [str ] = settings . DEFAULT_CHANNEL ,
269
281
inline : bool = True ,
270
282
storage_engine : StorageEnum = StorageEnum .storage ,
271
283
sync : bool = False ,
@@ -290,9 +302,9 @@ async def create_post(
290
302
async def create_aggregate (
291
303
self ,
292
304
key : str ,
293
- content : Mapping [str , Any ],
305
+ content : dict [str , Any ],
294
306
address : Optional [str ] = None ,
295
- channel : Optional [str ] = None ,
307
+ channel : Optional [str ] = settings . DEFAULT_CHANNEL ,
296
308
inline : bool = True ,
297
309
sync : bool = False ,
298
310
) -> Tuple [AlephMessage , MessageStatus ]:
@@ -302,7 +314,7 @@ async def create_aggregate(
302
314
:param key: Key to use to store the content
303
315
:param content: Content to store
304
316
: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 ")
306
318
:param inline: Whether to write content inside the message (Default: True)
307
319
:param sync: If true, waits for the message to be processed by the API server (Default: False)
308
320
"""
@@ -321,7 +333,7 @@ async def create_store(
321
333
ref : Optional [str ] = None ,
322
334
storage_engine : StorageEnum = StorageEnum .storage ,
323
335
extra_fields : Optional [dict ] = None ,
324
- channel : Optional [str ] = None ,
336
+ channel : Optional [str ] = settings . DEFAULT_CHANNEL ,
325
337
sync : bool = False ,
326
338
) -> Tuple [AlephMessage , MessageStatus ]:
327
339
"""
@@ -350,45 +362,47 @@ async def create_program(
350
362
program_ref : str ,
351
363
entrypoint : str ,
352
364
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 ,
356
366
address : Optional [str ] = None ,
357
- sync : bool = False ,
358
- memory : Optional [int ] = None ,
367
+ payment : Optional [Payment ] = None ,
359
368
vcpus : Optional [int ] = None ,
369
+ memory : Optional [int ] = None ,
360
370
timeout_seconds : Optional [float ] = None ,
361
- persistent : bool = False ,
362
- allow_amend : bool = False ,
363
371
internet : bool = True ,
372
+ allow_amend : bool = False ,
364
373
aleph_api : bool = True ,
365
374
encoding : Encoding = Encoding .zip ,
375
+ persistent : bool = False ,
366
376
volumes : Optional [List [Mapping ]] = None ,
367
- subscriptions : Optional [List [Mapping ]] = None ,
368
- metadata : Optional [Mapping [str , Any ]] = None ,
377
+ environment_variables : Optional [dict [str , str ]] = None ,
378
+ subscriptions : Optional [List [dict ]] = None ,
379
+ sync : bool = False ,
380
+ channel : Optional [str ] = settings .DEFAULT_CHANNEL ,
381
+ storage_engine : StorageEnum = StorageEnum .storage ,
369
382
) -> Tuple [AlephMessage , MessageStatus ]:
370
383
"""
371
384
Post a (create) PROGRAM message.
372
385
373
386
:param program_ref: Reference to the program to run
374
387
:param entrypoint: Entrypoint to run
375
388
: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")
389
+ :param metadata: Metadata to attach to the message
379
390
: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)
391
+ :param payment: Payment method used to pay for the program (Default: None)
382
392
:param vcpus: Number of vCPUs to allocate (Default: 1)
393
+ :param memory: Memory in MB for the VM to be allocated (Default: 128)
383
394
: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)
386
395
:param internet: Whether the VM should have internet connectivity. (Default: True)
396
+ :param allow_amend: Whether the deployed VM image may be changed (Default: False)
387
397
:param aleph_api: Whether the VM needs access to Aleph messages API (Default: True)
388
398
:param encoding: Encoding to use (Default: Encoding.zip)
399
+ :param persistent: Whether the program should be persistent or not (Default: False)
389
400
:param volumes: Volumes to mount
401
+ :param environment_variables: Environment variables to pass to the program
390
402
:param subscriptions: Patterns of aleph.im messages to forward to the program's event receiver
391
- :param metadata: Metadata to attach to the message
403
+ :param sync: If true, waits for the message to be processed by the API server
404
+ :param channel: Channel to use (Default: "ALEPH-CLOUDSOLUTIONS")
405
+ :param storage_engine: Storage engine to use (Default: "storage")
392
406
"""
393
407
raise NotImplementedError (
394
408
"Did you mean to import `AuthenticatedAlephHttpClient`?"
@@ -400,9 +414,9 @@ async def create_instance(
400
414
rootfs : str ,
401
415
rootfs_size : int ,
402
416
payment : Optional [Payment ] = None ,
403
- environment_variables : Optional [Mapping [str , str ]] = None ,
417
+ environment_variables : Optional [dict [str , str ]] = None ,
404
418
storage_engine : StorageEnum = StorageEnum .storage ,
405
- channel : Optional [str ] = None ,
419
+ channel : Optional [str ] = settings . DEFAULT_CHANNEL ,
406
420
address : Optional [str ] = None ,
407
421
sync : bool = False ,
408
422
memory : Optional [int ] = None ,
@@ -416,7 +430,7 @@ async def create_instance(
416
430
volumes : Optional [List [Mapping ]] = None ,
417
431
volume_persistence : str = "host" ,
418
432
ssh_keys : Optional [List [str ]] = None ,
419
- metadata : Optional [Mapping [str , Any ]] = None ,
433
+ metadata : Optional [dict [str , Any ]] = None ,
420
434
requirements : Optional [HostRequirements ] = None ,
421
435
) -> Tuple [AlephMessage , MessageStatus ]:
422
436
"""
@@ -427,7 +441,7 @@ async def create_instance(
427
441
:param payment: Payment method used to pay for the instance
428
442
:param environment_variables: Environment variables to pass to the program
429
443
:param storage_engine: Storage engine to use (Default: "storage")
430
- :param channel: Channel to use (Default: "TEST ")
444
+ :param channel: Channel to use (Default: "ALEPH-CLOUDSOLUTIONS ")
431
445
:param address: Address to use (Default: account.get_address())
432
446
:param sync: If true, waits for the message to be processed by the API server
433
447
:param memory: Memory in MB for the VM to be allocated (Default: 2048)
@@ -455,7 +469,7 @@ async def forget(
455
469
hashes : List [ItemHash ],
456
470
reason : Optional [str ],
457
471
storage_engine : StorageEnum = StorageEnum .storage ,
458
- channel : Optional [str ] = None ,
472
+ channel : Optional [str ] = settings . DEFAULT_CHANNEL ,
459
473
address : Optional [str ] = None ,
460
474
sync : bool = False ,
461
475
) -> Tuple [AlephMessage , MessageStatus ]:
@@ -468,7 +482,7 @@ async def forget(
468
482
:param hashes: Hashes of the messages to forget
469
483
:param reason: Reason for forgetting the messages
470
484
:param storage_engine: Storage engine to use (Default: "storage")
471
- :param channel: Channel to use (Default: "TEST ")
485
+ :param channel: Channel to use (Default: "ALEPH-CLOUDSOLUTIONS ")
472
486
:param address: Address to use (Default: account.get_address())
473
487
:param sync: If true, waits for the message to be processed by the API server (Default: False)
474
488
"""
@@ -490,7 +504,7 @@ async def generate_signed_message(
490
504
491
505
:param message_type: Type of the message (PostMessage, ...)
492
506
:param content: User-defined content of the message
493
- :param channel: Channel to use (Default: "TEST ")
507
+ :param channel: Channel to use (Default: "ALEPH-CLOUDSOLUTIONS ")
494
508
:param allow_inlining: Whether to allow inlining the content of the message (Default: True)
495
509
:param storage_engine: Storage engine to use (Default: "storage")
496
510
"""
@@ -537,7 +551,7 @@ async def submit(
537
551
self ,
538
552
content : Dict [str , Any ],
539
553
message_type : MessageType ,
540
- channel : Optional [str ] = None ,
554
+ channel : Optional [str ] = settings . DEFAULT_CHANNEL ,
541
555
storage_engine : StorageEnum = StorageEnum .storage ,
542
556
allow_inlining : bool = True ,
543
557
sync : bool = False ,
@@ -549,7 +563,7 @@ async def submit(
549
563
550
564
:param content: Content of the message
551
565
:param message_type: Type of the message
552
- :param channel: Channel to use (Default: "TEST ")
566
+ :param channel: Channel to use (Default: "ALEPH-CLOUDSOLUTIONS ")
553
567
:param storage_engine: Storage engine to use (Default: "storage")
554
568
:param allow_inlining: Whether to allow inlining the content of the message (Default: True)
555
569
:param sync: If true, waits for the message to be processed by the API server (Default: False)
0 commit comments