From 2ecf8e966da3838a7dae676c5b7d7eef4e7ab8cd Mon Sep 17 00:00:00 2001 From: Hugo Herter Date: Fri, 21 Jun 2024 12:40:19 +0200 Subject: [PATCH 1/3] Fix: Required an old version of `aleph-message` --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 8a70e9c8..bd4ce56c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -23,7 +23,7 @@ classifiers = [ ] dependencies = [ "aiohttp>=3.8.3", - "aleph-message~=0.4.4", + "aleph-message>=0.4.7", "coincurve; python_version<\"3.11\"", "coincurve>=19.0.0; python_version>=\"3.11\"", "eth_abi>=4.0.0; python_version>=\"3.11\"", From 33e6e922056460d3e67f599659116cf9e8e189a1 Mon Sep 17 00:00:00 2001 From: Hugo Herter Date: Fri, 21 Jun 2024 13:13:03 +0200 Subject: [PATCH 2/3] Fix: Newer aleph-message requires InstanceEnvironment Else tests were breaking. --- src/aleph/sdk/client/authenticated_http.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/aleph/sdk/client/authenticated_http.py b/src/aleph/sdk/client/authenticated_http.py index 60d42b2b..bf34e225 100644 --- a/src/aleph/sdk/client/authenticated_http.py +++ b/src/aleph/sdk/client/authenticated_http.py @@ -30,6 +30,7 @@ from aleph_message.models.execution.environment import ( FunctionEnvironment, HypervisorType, + InstanceEnvironment, MachineResources, ) from aleph_message.models.execution.instance import RootfsVolume @@ -539,8 +540,7 @@ async def create_instance( content = InstanceContent( address=address, allow_amend=allow_amend, - environment=FunctionEnvironment( - reproducible=False, + environment=InstanceEnvironment( internet=internet, aleph_api=aleph_api, hypervisor=hypervisor, From 9bda1d533b4ff8631bb9bd718ce689b1e918663b Mon Sep 17 00:00:00 2001 From: Hugo Herter Date: Fri, 21 Jun 2024 13:13:20 +0200 Subject: [PATCH 3/3] Fix: Qemu was not the default hypervisor for instances. --- src/aleph/sdk/client/authenticated_http.py | 6 ++++-- tests/unit/test_asynchronous.py | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/aleph/sdk/client/authenticated_http.py b/src/aleph/sdk/client/authenticated_http.py index bf34e225..6d44b526 100644 --- a/src/aleph/sdk/client/authenticated_http.py +++ b/src/aleph/sdk/client/authenticated_http.py @@ -535,7 +535,9 @@ async def create_instance( timeout_seconds = timeout_seconds or settings.DEFAULT_VM_TIMEOUT payment = payment or Payment(chain=Chain.ETH, type=PaymentType.hold) - hypervisor = hypervisor or HypervisorType.firecracker + + # Default to the QEMU hypervisor for instances. + selected_hypervisor: HypervisorType = hypervisor or HypervisorType.qemu content = InstanceContent( address=address, @@ -543,7 +545,7 @@ async def create_instance( environment=InstanceEnvironment( internet=internet, aleph_api=aleph_api, - hypervisor=hypervisor, + hypervisor=selected_hypervisor, ), variables=environment_variables, resources=MachineResources( diff --git a/tests/unit/test_asynchronous.py b/tests/unit/test_asynchronous.py index 0fa0df38..0f909408 100644 --- a/tests/unit/test_asynchronous.py +++ b/tests/unit/test_asynchronous.py @@ -157,7 +157,7 @@ async def test_create_instance_no_hypervisor(mock_session_with_post_success): hypervisor=None, ) - assert instance_message.content.environment.hypervisor == HypervisorType.firecracker + assert instance_message.content.environment.hypervisor == HypervisorType.qemu assert mock_session_with_post_success.http_session.post.assert_called_once assert isinstance(instance_message, InstanceMessage)