From 84c7affe834f807702100d4a7f10e92142aa313c Mon Sep 17 00:00:00 2001 From: Olivier Le Thanh Duong Date: Wed, 8 Nov 2023 15:24:12 +0100 Subject: [PATCH 1/5] wip allow qemu backend --- aleph_message/models/execution/abstract.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/aleph_message/models/execution/abstract.py b/aleph_message/models/execution/abstract.py index d4e8ee1..8c7945e 100644 --- a/aleph_message/models/execution/abstract.py +++ b/aleph_message/models/execution/abstract.py @@ -17,6 +17,10 @@ class BaseExecutableContent(HashableModel, BaseContent, ABC): """Abstract content for execution messages (Instances, Programs).""" + # TODO : Discuss how to communicate we want a firecracker backend + backend: str = Field( + description="Qemu or firecracker backend" + ) allow_amend: bool = Field(description="Allow amends to update this function") metadata: Optional[Dict[str, Any]] = Field(description="Metadata of the VM") authorized_keys: Optional[List[str]] = Field( From 8547c52a560e88dbd803bae5fda94e8ba33fdce0 Mon Sep 17 00:00:00 2001 From: Olivier Le Thanh Duong Date: Wed, 8 Nov 2023 15:28:13 +0100 Subject: [PATCH 2/5] switch format for qemu message --- aleph_message/models/__init__.py | 5 +++++ aleph_message/models/execution/abstract.py | 4 ---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/aleph_message/models/__init__.py b/aleph_message/models/__init__.py index 9306012..49242b7 100644 --- a/aleph_message/models/__init__.py +++ b/aleph_message/models/__init__.py @@ -52,6 +52,7 @@ class MessageType(str, Enum): store = "STORE" program = "PROGRAM" instance = "INSTANCE" + qemu_instance = "QEMU_INSTANCE" forget = "FORGET" @@ -324,6 +325,10 @@ class InstanceMessage(BaseMessage): type: Literal[MessageType.instance] content: InstanceContent +class QemuMessage(BaseMessage): + type: Literal[MessageType.instance] + content: InstanceContent + AlephMessage: TypeAlias = Union[ PostMessage, diff --git a/aleph_message/models/execution/abstract.py b/aleph_message/models/execution/abstract.py index 8c7945e..d4e8ee1 100644 --- a/aleph_message/models/execution/abstract.py +++ b/aleph_message/models/execution/abstract.py @@ -17,10 +17,6 @@ class BaseExecutableContent(HashableModel, BaseContent, ABC): """Abstract content for execution messages (Instances, Programs).""" - # TODO : Discuss how to communicate we want a firecracker backend - backend: str = Field( - description="Qemu or firecracker backend" - ) allow_amend: bool = Field(description="Allow amends to update this function") metadata: Optional[Dict[str, Any]] = Field(description="Metadata of the VM") authorized_keys: Optional[List[str]] = Field( From c84144aef8ec7096136c8cac062509ca23c9a795 Mon Sep 17 00:00:00 2001 From: Olivier Le Thanh Duong Date: Fri, 17 Nov 2023 13:33:57 +0100 Subject: [PATCH 3/5] iteration on format --- aleph_message/models/execution/qemu.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 aleph_message/models/execution/qemu.py diff --git a/aleph_message/models/execution/qemu.py b/aleph_message/models/execution/qemu.py new file mode 100644 index 0000000..dd88e08 --- /dev/null +++ b/aleph_message/models/execution/qemu.py @@ -0,0 +1,14 @@ +from pydantic import Field + +from aleph_message.models.execution.instance import RootfsVolume + +from aleph_message.models.execution import BaseExecutableContent + + +class QemuContent(BaseExecutableContent): + """Message content for scheduling a VM instance on the network.""" + + rootfs: RootfsVolume = Field( + description="Base image for the kernel, as qcow2" + ) + From d43153445e18ee7e298a717cbc8f54f781141fca Mon Sep 17 00:00:00 2001 From: Olivier Le Thanh Duong Date: Fri, 17 Nov 2023 16:09:53 +0100 Subject: [PATCH 4/5] iteration v3 --- aleph_message/models/__init__.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/aleph_message/models/__init__.py b/aleph_message/models/__init__.py index 49242b7..5d8dcdb 100644 --- a/aleph_message/models/__init__.py +++ b/aleph_message/models/__init__.py @@ -20,6 +20,7 @@ from .abstract import BaseContent from .execution.instance import InstanceContent from .execution.program import ProgramContent +from .execution.qemu import QemuContent from .item_hash import ItemHash, ItemType @@ -325,9 +326,13 @@ class InstanceMessage(BaseMessage): type: Literal[MessageType.instance] content: InstanceContent + + + class QemuMessage(BaseMessage): - type: Literal[MessageType.instance] - content: InstanceContent + type: Literal[MessageType.qemu_instance] + content: QemuContent + AlephMessage: TypeAlias = Union[ @@ -337,6 +342,7 @@ class QemuMessage(BaseMessage): ProgramMessage, InstanceMessage, ForgetMessage, + QemuMessage, ] AlephMessageType: TypeAlias = Union[ @@ -354,11 +360,12 @@ class QemuMessage(BaseMessage): StoreMessage, ProgramMessage, InstanceMessage, + QemuMessage, ForgetMessage, ] -ExecutableContent: TypeAlias = Union[InstanceContent, ProgramContent] -ExecutableMessage: TypeAlias = Union[InstanceMessage, ProgramMessage] +ExecutableContent: TypeAlias = Union[InstanceContent, ProgramContent, QemuContent] +ExecutableMessage: TypeAlias = Union[InstanceMessage, ProgramMessage, QemuMessage] def parse_message(message_dict: Dict) -> AlephMessage: From 175da3d9f7b0d5735ce4d8da816f738089beab3c Mon Sep 17 00:00:00 2001 From: Olivier Le Thanh Duong Date: Tue, 21 Nov 2023 12:29:33 +0100 Subject: [PATCH 5/5] v4 iteration of the format --- aleph_message/models/__init__.py | 16 ++-------------- aleph_message/models/execution/environment.py | 6 ++++++ aleph_message/models/execution/qemu.py | 14 -------------- 3 files changed, 8 insertions(+), 28 deletions(-) delete mode 100644 aleph_message/models/execution/qemu.py diff --git a/aleph_message/models/__init__.py b/aleph_message/models/__init__.py index 5d8dcdb..9306012 100644 --- a/aleph_message/models/__init__.py +++ b/aleph_message/models/__init__.py @@ -20,7 +20,6 @@ from .abstract import BaseContent from .execution.instance import InstanceContent from .execution.program import ProgramContent -from .execution.qemu import QemuContent from .item_hash import ItemHash, ItemType @@ -53,7 +52,6 @@ class MessageType(str, Enum): store = "STORE" program = "PROGRAM" instance = "INSTANCE" - qemu_instance = "QEMU_INSTANCE" forget = "FORGET" @@ -327,14 +325,6 @@ class InstanceMessage(BaseMessage): content: InstanceContent - - -class QemuMessage(BaseMessage): - type: Literal[MessageType.qemu_instance] - content: QemuContent - - - AlephMessage: TypeAlias = Union[ PostMessage, AggregateMessage, @@ -342,7 +332,6 @@ class QemuMessage(BaseMessage): ProgramMessage, InstanceMessage, ForgetMessage, - QemuMessage, ] AlephMessageType: TypeAlias = Union[ @@ -360,12 +349,11 @@ class QemuMessage(BaseMessage): StoreMessage, ProgramMessage, InstanceMessage, - QemuMessage, ForgetMessage, ] -ExecutableContent: TypeAlias = Union[InstanceContent, ProgramContent, QemuContent] -ExecutableMessage: TypeAlias = Union[InstanceMessage, ProgramMessage, QemuMessage] +ExecutableContent: TypeAlias = Union[InstanceContent, ProgramContent] +ExecutableMessage: TypeAlias = Union[InstanceMessage, ProgramMessage] def parse_message(message_dict: Dict) -> AlephMessage: diff --git a/aleph_message/models/execution/environment.py b/aleph_message/models/execution/environment.py index 863d5d1..93372e7 100644 --- a/aleph_message/models/execution/environment.py +++ b/aleph_message/models/execution/environment.py @@ -81,12 +81,18 @@ class CpuProperties(HashableModel): class Config: extra = Extra.forbid +class HypervisorType(str, Enum): + qemu = 'qemu' + firecracker = 'firecracker' + + class FunctionEnvironment(HashableModel): reproducible: bool = False internet: bool = False aleph_api: bool = False shared_cache: bool = False + hypervisor: Optional[HypervisorType] class NodeRequirements(HashableModel): diff --git a/aleph_message/models/execution/qemu.py b/aleph_message/models/execution/qemu.py deleted file mode 100644 index dd88e08..0000000 --- a/aleph_message/models/execution/qemu.py +++ /dev/null @@ -1,14 +0,0 @@ -from pydantic import Field - -from aleph_message.models.execution.instance import RootfsVolume - -from aleph_message.models.execution import BaseExecutableContent - - -class QemuContent(BaseExecutableContent): - """Message content for scheduling a VM instance on the network.""" - - rootfs: RootfsVolume = Field( - description="Base image for the kernel, as qcow2" - ) -