Skip to content

Commit 7ffeccc

Browse files
committed
Fix: Changed create_instance method signature to be similar to aleph-message schema.
1 parent dd886f4 commit 7ffeccc

File tree

3 files changed

+14
-18
lines changed

3 files changed

+14
-18
lines changed

src/aleph/sdk/client/abstract.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,11 @@
2727
PostMessage,
2828
parse_message,
2929
)
30-
from aleph_message.models.execution.environment import HostRequirements, HypervisorType
30+
from aleph_message.models.execution.environment import (
31+
HostRequirements,
32+
HypervisorType,
33+
TrustedExecutionEnvironment,
34+
)
3135
from aleph_message.models.execution.program import Encoding
3236
from aleph_message.status import MessageStatus
3337

@@ -395,8 +399,7 @@ async def create_instance(
395399
internet: bool = True,
396400
aleph_api: bool = True,
397401
hypervisor: Optional[HypervisorType] = None,
398-
confidential_firmware: Optional[ItemHash] = None,
399-
confidential_policy: Optional[int] = None,
402+
trusted_execution: Optional[TrustedExecutionEnvironment] = None,
400403
volumes: Optional[List[Mapping]] = None,
401404
volume_persistence: str = "host",
402405
ssh_keys: Optional[List[str]] = None,
@@ -421,8 +424,7 @@ async def create_instance(
421424
:param internet: Whether the VM should have internet connectivity. (Default: True)
422425
:param aleph_api: Whether the VM needs access to Aleph messages API (Default: True)
423426
:param hypervisor: Whether the VM should use as Hypervisor, like QEmu or Firecracker (Default: Qemu)
424-
:param confidential_firmware: Whether the VM firmware to use for Confidential computing (Default: None)
425-
:param confidential_policy: Whether the VM firmware policy to use for Confidential computing (Default: None)
427+
:param trusted_execution: Whether the VM configuration (firmware and policy) to use for Confidential computing (Default: None)
426428
:param encoding: Encoding to use (Default: Encoding.zip)
427429
:param volumes: Volumes to mount
428430
:param volume_persistence: Where volumes are persisted, can be "host" or "store", meaning distributed across Aleph.im (Default: "host")

src/aleph/sdk/client/authenticated_http.py

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -524,8 +524,7 @@ async def create_instance(
524524
internet: bool = True,
525525
aleph_api: bool = True,
526526
hypervisor: Optional[HypervisorType] = None,
527-
confidential_firmware: Optional[ItemHash] = None,
528-
confidential_policy: Optional[int] = None,
527+
trusted_execution: Optional[TrustedExecutionEnvironment] = None,
529528
volumes: Optional[List[Mapping]] = None,
530529
volume_persistence: str = "host",
531530
ssh_keys: Optional[List[str]] = None,
@@ -541,14 +540,6 @@ async def create_instance(
541540

542541
payment = payment or Payment(chain=Chain.ETH, type=PaymentType.hold)
543542

544-
if confidential_firmware or confidential_policy:
545-
confidential_options = TrustedExecutionEnvironment(
546-
firmware=confidential_firmware,
547-
policy=confidential_policy,
548-
)
549-
else:
550-
confidential_options = None
551-
552543
# Default to the QEMU hypervisor for instances.
553544
selected_hypervisor: HypervisorType = hypervisor or HypervisorType.qemu
554545

@@ -559,7 +550,7 @@ async def create_instance(
559550
internet=internet,
560551
aleph_api=aleph_api,
561552
hypervisor=selected_hypervisor,
562-
trusted_execution=confidential_options,
553+
trusted_execution=trusted_execution,
563554
),
564555
variables=environment_variables,
565556
resources=MachineResources(

tests/unit/test_asynchronous.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
HypervisorType,
2020
MachineResources,
2121
NodeRequirements,
22+
TrustedExecutionEnvironment,
2223
)
2324
from aleph_message.status import MessageStatus
2425

@@ -182,8 +183,10 @@ async def test_create_confidential_instance(mock_session_with_post_success):
182183
type=PaymentType.superfluid,
183184
),
184185
hypervisor=HypervisorType.qemu,
185-
confidential_firmware="cafecafecafecafecafecafecafecafecafecafecafecafecafecafecafecafe",
186-
confidential_policy=0b1,
186+
trusted_execution=TrustedExecutionEnvironment(
187+
firmware="cafecafecafecafecafecafecafecafecafecafecafecafecafecafecafecafe",
188+
policy=0b1,
189+
),
187190
requirements=HostRequirements(
188191
node=NodeRequirements(
189192
node_hash="cafecafecafecafecafecafecafecafecafecafecafecafecafecafecafecafe",

0 commit comments

Comments
 (0)