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,45 @@ 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 ,
359
367
vcpus : Optional [int ] = None ,
368
+ memory : Optional [int ] = None ,
360
369
timeout_seconds : Optional [float ] = None ,
361
- persistent : bool = False ,
362
- allow_amend : bool = False ,
363
370
internet : bool = True ,
371
+ allow_amend : bool = False ,
364
372
aleph_api : bool = True ,
365
373
encoding : Encoding = Encoding .zip ,
374
+ persistent : bool = False ,
366
375
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 ,
369
381
) -> Tuple [AlephMessage , MessageStatus ]:
370
382
"""
371
383
Post a (create) PROGRAM message.
372
384
373
385
:param program_ref: Reference to the program to run
374
386
:param entrypoint: Entrypoint to run
375
387
: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
379
389
: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)
382
390
:param vcpus: Number of vCPUs to allocate (Default: 1)
391
+ :param memory: Memory in MB for the VM to be allocated (Default: 128)
383
392
: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
393
: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)
387
395
:param aleph_api: Whether the VM needs access to Aleph messages API (Default: True)
388
396
:param encoding: Encoding to use (Default: Encoding.zip)
397
+ :param persistent: Whether the program should be persistent or not (Default: False)
389
398
:param volumes: Volumes to mount
399
+ :param environment_variables: Environment variables to pass to the program
390
400
: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")
392
404
"""
393
405
raise NotImplementedError (
394
406
"Did you mean to import `AuthenticatedAlephHttpClient`?"
@@ -400,9 +412,9 @@ async def create_instance(
400
412
rootfs : str ,
401
413
rootfs_size : int ,
402
414
payment : Optional [Payment ] = None ,
403
- environment_variables : Optional [Mapping [str , str ]] = None ,
415
+ environment_variables : Optional [dict [str , str ]] = None ,
404
416
storage_engine : StorageEnum = StorageEnum .storage ,
405
- channel : Optional [str ] = None ,
417
+ channel : Optional [str ] = settings . DEFAULT_CHANNEL ,
406
418
address : Optional [str ] = None ,
407
419
sync : bool = False ,
408
420
memory : Optional [int ] = None ,
@@ -416,7 +428,7 @@ async def create_instance(
416
428
volumes : Optional [List [Mapping ]] = None ,
417
429
volume_persistence : str = "host" ,
418
430
ssh_keys : Optional [List [str ]] = None ,
419
- metadata : Optional [Mapping [str , Any ]] = None ,
431
+ metadata : Optional [dict [str , Any ]] = None ,
420
432
requirements : Optional [HostRequirements ] = None ,
421
433
) -> Tuple [AlephMessage , MessageStatus ]:
422
434
"""
@@ -427,7 +439,7 @@ async def create_instance(
427
439
:param payment: Payment method used to pay for the instance
428
440
:param environment_variables: Environment variables to pass to the program
429
441
: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 ")
431
443
:param address: Address to use (Default: account.get_address())
432
444
:param sync: If true, waits for the message to be processed by the API server
433
445
:param memory: Memory in MB for the VM to be allocated (Default: 2048)
@@ -455,7 +467,7 @@ async def forget(
455
467
hashes : List [ItemHash ],
456
468
reason : Optional [str ],
457
469
storage_engine : StorageEnum = StorageEnum .storage ,
458
- channel : Optional [str ] = None ,
470
+ channel : Optional [str ] = settings . DEFAULT_CHANNEL ,
459
471
address : Optional [str ] = None ,
460
472
sync : bool = False ,
461
473
) -> Tuple [AlephMessage , MessageStatus ]:
@@ -468,7 +480,7 @@ async def forget(
468
480
:param hashes: Hashes of the messages to forget
469
481
:param reason: Reason for forgetting the messages
470
482
: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 ")
472
484
:param address: Address to use (Default: account.get_address())
473
485
:param sync: If true, waits for the message to be processed by the API server (Default: False)
474
486
"""
@@ -490,7 +502,7 @@ async def generate_signed_message(
490
502
491
503
:param message_type: Type of the message (PostMessage, ...)
492
504
: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 ")
494
506
:param allow_inlining: Whether to allow inlining the content of the message (Default: True)
495
507
:param storage_engine: Storage engine to use (Default: "storage")
496
508
"""
@@ -537,7 +549,7 @@ async def submit(
537
549
self ,
538
550
content : Dict [str , Any ],
539
551
message_type : MessageType ,
540
- channel : Optional [str ] = None ,
552
+ channel : Optional [str ] = settings . DEFAULT_CHANNEL ,
541
553
storage_engine : StorageEnum = StorageEnum .storage ,
542
554
allow_inlining : bool = True ,
543
555
sync : bool = False ,
@@ -549,7 +561,7 @@ async def submit(
549
561
550
562
:param content: Content of the message
551
563
:param message_type: Type of the message
552
- :param channel: Channel to use (Default: "TEST ")
564
+ :param channel: Channel to use (Default: "ALEPH-CLOUDSOLUTIONS ")
553
565
:param storage_engine: Storage engine to use (Default: "storage")
554
566
:param allow_inlining: Whether to allow inlining the content of the message (Default: True)
555
567
:param sync: If true, waits for the message to be processed by the API server (Default: False)
0 commit comments