From 2a2ddb3bbbee7c76e54d8ef7f80282ac3c1f2b86 Mon Sep 17 00:00:00 2001 From: Pooya Paridel Date: Mon, 9 Nov 2026 23:06:11 +0000 Subject: [PATCH 1/2] refactor(worker): rename to compute-worker The worker package is renamed from microvm-worker to compute-worker. The MicroVM code moves to the microvm subpackage. The new import is aws_durable_execution_sdk_python_compute_worker.microvm. It exports the same names as the old top-level package. A later worker for another compute type can then be a sibling subpackage. The extras package uses the same compute.microvm layout. The worker is not on PyPI yet. So no published import breaks. The PyPI publish workflow is unchanged. --- .github/scripts/js_examples/run.py | 5 +++++ .github/scripts/tests/test_js_examples.py | 2 +- .github/scripts/type-checks.sh | 4 ++-- AGENTS.md | 5 +++-- .../README.md | 20 ++++++++++--------- .../docs/worker.md | 2 +- .../pyproject.toml | 16 +++++++-------- .../__about__.py | 0 .../__init__.py | 16 +++++++++++++++ .../microvm}/__init__.py | 10 +++++----- .../microvm}/callback_reporter.py | 2 +- .../microvm}/heartbeats.py | 8 +++++--- .../microvm}/logger.py | 2 +- .../microvm}/payload.py | 2 +- .../microvm}/self_suspend.py | 4 ++-- .../microvm}/worker.py | 12 +++++------ .../py.typed | 0 .../tests/conftest.py | 0 .../tests/microvm}/callback_reporter_test.py | 4 ++-- .../tests/microvm}/heartbeats_test.py | 4 ++-- .../tests/microvm}/lifecycle_hooks_test.py | 8 +++++--- .../tests/microvm}/logger_test.py | 2 +- .../tests/microvm}/payload_test.py | 2 +- .../tests/microvm}/self_suspend_test.py | 2 +- .../tests/microvm}/worker_test.py | 12 ++++++----- .../microvm-image/app.py | 2 +- .../scripts/ensure_microvm_image.py | 2 +- .../test/README.md | 2 +- .../test/test_microvm_image_app.py | 4 ++-- .../README.md | 4 ++-- .../docs/microvm.md | 6 +++--- .../compute/microvm/config.py | 6 +++--- .../compute/microvm/job.py | 4 ++-- .../compute/microvm/request.py | 2 +- .../tests/compute/microvm/job_test.py | 2 +- .../tests/compute/microvm/request_test.py | 2 +- .../compute/microvm/worker_composed_test.py | 8 +++++--- pyproject.toml | 18 ++++++++--------- 38 files changed, 119 insertions(+), 87 deletions(-) rename packages/{aws-durable-execution-sdk-python-microvm-worker => aws-durable-execution-sdk-python-compute-worker}/README.md (83%) rename packages/{aws-durable-execution-sdk-python-microvm-worker => aws-durable-execution-sdk-python-compute-worker}/docs/worker.md (98%) rename packages/{aws-durable-execution-sdk-python-microvm-worker => aws-durable-execution-sdk-python-compute-worker}/pyproject.toml (81%) rename packages/{aws-durable-execution-sdk-python-microvm-worker/src/aws_durable_execution_sdk_python_microvm_worker => aws-durable-execution-sdk-python-compute-worker/src/aws_durable_execution_sdk_python_compute_worker}/__about__.py (100%) create mode 100644 packages/aws-durable-execution-sdk-python-compute-worker/src/aws_durable_execution_sdk_python_compute_worker/__init__.py rename packages/{aws-durable-execution-sdk-python-microvm-worker/src/aws_durable_execution_sdk_python_microvm_worker => aws-durable-execution-sdk-python-compute-worker/src/aws_durable_execution_sdk_python_compute_worker/microvm}/__init__.py (81%) rename packages/{aws-durable-execution-sdk-python-microvm-worker/src/aws_durable_execution_sdk_python_microvm_worker => aws-durable-execution-sdk-python-compute-worker/src/aws_durable_execution_sdk_python_compute_worker/microvm}/callback_reporter.py (99%) rename packages/{aws-durable-execution-sdk-python-microvm-worker/src/aws_durable_execution_sdk_python_microvm_worker => aws-durable-execution-sdk-python-compute-worker/src/aws_durable_execution_sdk_python_compute_worker/microvm}/heartbeats.py (98%) rename packages/{aws-durable-execution-sdk-python-microvm-worker/src/aws_durable_execution_sdk_python_microvm_worker => aws-durable-execution-sdk-python-compute-worker/src/aws_durable_execution_sdk_python_compute_worker/microvm}/logger.py (97%) rename packages/{aws-durable-execution-sdk-python-microvm-worker/src/aws_durable_execution_sdk_python_microvm_worker => aws-durable-execution-sdk-python-compute-worker/src/aws_durable_execution_sdk_python_compute_worker/microvm}/payload.py (99%) rename packages/{aws-durable-execution-sdk-python-microvm-worker/src/aws_durable_execution_sdk_python_microvm_worker => aws-durable-execution-sdk-python-compute-worker/src/aws_durable_execution_sdk_python_compute_worker/microvm}/self_suspend.py (98%) rename packages/{aws-durable-execution-sdk-python-microvm-worker/src/aws_durable_execution_sdk_python_microvm_worker => aws-durable-execution-sdk-python-compute-worker/src/aws_durable_execution_sdk_python_compute_worker/microvm}/worker.py (99%) rename packages/{aws-durable-execution-sdk-python-microvm-worker/src/aws_durable_execution_sdk_python_microvm_worker => aws-durable-execution-sdk-python-compute-worker/src/aws_durable_execution_sdk_python_compute_worker}/py.typed (100%) rename packages/{aws-durable-execution-sdk-python-microvm-worker => aws-durable-execution-sdk-python-compute-worker}/tests/conftest.py (100%) rename packages/{aws-durable-execution-sdk-python-microvm-worker/tests => aws-durable-execution-sdk-python-compute-worker/tests/microvm}/callback_reporter_test.py (98%) rename packages/{aws-durable-execution-sdk-python-microvm-worker/tests => aws-durable-execution-sdk-python-compute-worker/tests/microvm}/heartbeats_test.py (98%) rename packages/{aws-durable-execution-sdk-python-microvm-worker/tests => aws-durable-execution-sdk-python-compute-worker/tests/microvm}/lifecycle_hooks_test.py (99%) rename packages/{aws-durable-execution-sdk-python-microvm-worker/tests => aws-durable-execution-sdk-python-compute-worker/tests/microvm}/logger_test.py (96%) rename packages/{aws-durable-execution-sdk-python-microvm-worker/tests => aws-durable-execution-sdk-python-compute-worker/tests/microvm}/payload_test.py (99%) rename packages/{aws-durable-execution-sdk-python-microvm-worker/tests => aws-durable-execution-sdk-python-compute-worker/tests/microvm}/self_suspend_test.py (99%) rename packages/{aws-durable-execution-sdk-python-microvm-worker/tests => aws-durable-execution-sdk-python-compute-worker/tests/microvm}/worker_test.py (99%) diff --git a/.github/scripts/js_examples/run.py b/.github/scripts/js_examples/run.py index 396d8a643..5f540b5e9 100755 --- a/.github/scripts/js_examples/run.py +++ b/.github/scripts/js_examples/run.py @@ -70,13 +70,18 @@ "packages/aws-durable-execution-sdk-js-otel", "packages/aws-durable-execution-sdk-js-extras", "packages/aws-durable-execution-sdk-js-microvm-worker", + "packages/aws-durable-execution-sdk-js-compute-worker", "packages/aws-durable-execution-sdk-js-examples", ) # Older JS refs predate these packages; their examples do not need them. +# The worker package was renamed from microvm-worker to compute-worker. A JS +# ref has at most one of the two. So both are listed, and the build skips the +# one that the ref does not have. OPTIONAL_JS_BUILD_WORKSPACES = frozenset( { "packages/aws-durable-execution-sdk-js-extras", "packages/aws-durable-execution-sdk-js-microvm-worker", + "packages/aws-durable-execution-sdk-js-compute-worker", } ) # otel examples export spans to an OpenTelemetry collector. The harness does diff --git a/.github/scripts/tests/test_js_examples.py b/.github/scripts/tests/test_js_examples.py index dd56d143e..1d29d8aa6 100644 --- a/.github/scripts/tests/test_js_examples.py +++ b/.github/scripts/tests/test_js_examples.py @@ -633,7 +633,7 @@ def test_build_produces_example_workspace_dependencies( testing = "packages/aws-durable-execution-sdk-js-testing" otel = "packages/aws-durable-execution-sdk-js-otel" extras = "packages/aws-durable-execution-sdk-js-extras" - worker = "packages/aws-durable-execution-sdk-js-microvm-worker" + worker = "packages/aws-durable-execution-sdk-js-compute-worker" examples_package = "packages/aws-durable-execution-sdk-js-examples" packages = [core, testing, otel, examples_package] if has_microvm_packages: diff --git a/.github/scripts/type-checks.sh b/.github/scripts/type-checks.sh index 372bd2339..ac7e95c07 100644 --- a/.github/scripts/type-checks.sh +++ b/.github/scripts/type-checks.sh @@ -18,8 +18,8 @@ mypy --install-types --non-interactive \ packages/aws-durable-execution-sdk-python-telemetry-exporter/tests mypy --install-types --non-interactive \ - packages/aws-durable-execution-sdk-python-microvm-worker/src/aws_durable_execution_sdk_python_microvm_worker \ - packages/aws-durable-execution-sdk-python-microvm-worker/tests + packages/aws-durable-execution-sdk-python-compute-worker/src/aws_durable_execution_sdk_python_compute_worker \ + packages/aws-durable-execution-sdk-python-compute-worker/tests mypy --install-types --non-interactive \ packages/aws-durable-execution-sdk-python-extras/src/aws_durable_execution_sdk_python_extras \ diff --git a/AGENTS.md b/AGENTS.md index 859018632..a4fc7bdea 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -83,8 +83,9 @@ Do NOT add or modify **conformance tests** without coordinating with the team. C (`aws-durable-execution-sdk-python`), the testing library (`aws-durable-execution-sdk-python-testing`), the OpenTelemetry plugin (`aws-durable-execution-sdk-python-otel`), the Durable Execution Telemetry - Exporter (`aws-durable-execution-sdk-python-telemetry-exporter`), the Lambda - MicroVM worker (`aws-durable-execution-sdk-python-microvm-worker`), the + Exporter (`aws-durable-execution-sdk-python-telemetry-exporter`), the compute + worker with the Lambda MicroVM worker in its `microvm` subpackage + (`aws-durable-execution-sdk-python-compute-worker`), the extras package with custom operations such as `microvm` (`aws-durable-execution-sdk-python-extras`), and examples (`aws-durable-execution-sdk-python-examples`). diff --git a/packages/aws-durable-execution-sdk-python-microvm-worker/README.md b/packages/aws-durable-execution-sdk-python-compute-worker/README.md similarity index 83% rename from packages/aws-durable-execution-sdk-python-microvm-worker/README.md rename to packages/aws-durable-execution-sdk-python-compute-worker/README.md index c4e159fef..b9e5c1e36 100644 --- a/packages/aws-durable-execution-sdk-python-microvm-worker/README.md +++ b/packages/aws-durable-execution-sdk-python-compute-worker/README.md @@ -1,7 +1,9 @@ -# AWS Durable Execution SDK for Python: MicroVM worker +# AWS Durable Execution SDK for Python: compute worker > This package is experimental. Its API can change in any release. +The compute worker runs jobs from durable functions on compute that is defined outside the durable function. Each compute type has its own subpackage. Today the package has one subpackage: `aws_durable_execution_sdk_python_compute_worker.microvm`, the worker for AWS Lambda MicroVMs. The rest of this README describes the MicroVM worker. + Run jobs from a durable function inside an AWS Lambda MicroVM, and report each job's result to the durable function. The worker runs in the MicroVM image, not in the durable function. It does not depend on the durable execution SDK. The job document is the same in every SDK language. So a durable function in any language can send jobs to this worker. @@ -9,7 +11,7 @@ The worker runs in the MicroVM image, not in the durable function. It does not d ## Install ```console -pip install aws-durable-execution-sdk-python-microvm-worker +pip install aws-durable-execution-sdk-python-compute-worker ``` ## Quick start @@ -17,7 +19,7 @@ pip install aws-durable-execution-sdk-python-microvm-worker ```python import logging -from aws_durable_execution_sdk_python_microvm_worker import ( +from aws_durable_execution_sdk_python_compute_worker.microvm import ( MicrovmJobContext, start_microvm_worker, ) @@ -42,7 +44,7 @@ The handler's return value becomes the durable function's result. An exception f ### Serve named routes ```python -from aws_durable_execution_sdk_python_microvm_worker import ( +from aws_durable_execution_sdk_python_compute_worker.microvm import ( MicrovmJobContext, start_microvm_worker, ) @@ -73,7 +75,7 @@ The durable function sends a job to a route with `MicrovmRequestConfig(path=...) ```python import subprocess -from aws_durable_execution_sdk_python_microvm_worker import MicrovmJobContext +from aws_durable_execution_sdk_python_compute_worker.microvm import MicrovmJobContext def run_build(job_input: dict, context: MicrovmJobContext) -> dict: @@ -91,7 +93,7 @@ A handler must be a plain function. An `async def` handler raises `TypeError`. C ```python import asyncio -from aws_durable_execution_sdk_python_microvm_worker import MicrovmJobContext +from aws_durable_execution_sdk_python_compute_worker.microvm import MicrovmJobContext async def build(job_input: dict) -> dict: @@ -149,7 +151,7 @@ With `suspend_after`, the durable function suspends the MicroVM itself. The work ### Logging -The worker logs to the standard library logger `aws_durable_execution_sdk_python_microvm_worker`. Pass `logger=` to replace it. Configure `logging` in the image to see its INFO lines. +The worker logs to the standard library logger `aws_durable_execution_sdk_python_compute_worker.microvm`. Pass `logger=` to replace it. Configure `logging` in the image to see its INFO lines. ### Permissions @@ -161,9 +163,9 @@ The worker needs boto3 1.43.35 or later. ## Reference -- [docs/worker.md](https://github.com/aws/aws-durable-execution-sdk-python/blob/main/packages/aws-durable-execution-sdk-python-microvm-worker/docs/worker.md): the request flow, the lifecycle hooks, idle suspend outcomes, the job documents, reporting, heartbeats, logging fields, and best practices. +- [docs/worker.md](https://github.com/aws/aws-durable-execution-sdk-python/blob/main/packages/aws-durable-execution-sdk-python-compute-worker/docs/worker.md): the request flow, the lifecycle hooks, idle suspend outcomes, the job documents, reporting, heartbeats, logging fields, and best practices. - [extras](https://github.com/aws/aws-durable-execution-sdk-python/tree/main/packages/aws-durable-execution-sdk-python-extras): the `microvm` and `microvm_session` operations that send jobs. -- [Source](https://github.com/aws/aws-durable-execution-sdk-python/tree/main/packages/aws-durable-execution-sdk-python-microvm-worker/src/aws_durable_execution_sdk_python_microvm_worker): lower-level building blocks such as `MicrovmWorkerListener` and `CallbackReporter`. +- [Source](https://github.com/aws/aws-durable-execution-sdk-python/tree/main/packages/aws-durable-execution-sdk-python-compute-worker/src/aws_durable_execution_sdk_python_compute_worker/microvm): lower-level building blocks such as `MicrovmWorkerListener` and `CallbackReporter`. ## License diff --git a/packages/aws-durable-execution-sdk-python-microvm-worker/docs/worker.md b/packages/aws-durable-execution-sdk-python-compute-worker/docs/worker.md similarity index 98% rename from packages/aws-durable-execution-sdk-python-microvm-worker/docs/worker.md rename to packages/aws-durable-execution-sdk-python-compute-worker/docs/worker.md index 375b99bbe..da7bd01ea 100644 --- a/packages/aws-durable-execution-sdk-python-microvm-worker/docs/worker.md +++ b/packages/aws-durable-execution-sdk-python-compute-worker/docs/worker.md @@ -177,7 +177,7 @@ An explicit `heartbeat_interval_seconds` must be above 0 and at most 900, and it ## Logging -The worker logs to the standard library logger `aws_durable_execution_sdk_python_microvm_worker`, and passes its structured fields in `extra`. Every line about a job carries its `callbackId`. `CallbackReporter.create` and the heartbeats take the same `logger` argument. Configure `logging` in the image to see its INFO lines, for example with `logging.basicConfig(level=logging.INFO)`. Any object with the `logging.Logger` signatures for `info`, `warning`, and `error` can replace it. A logger that raises does not stop the worker: the line is dropped. +The worker logs to the standard library logger `aws_durable_execution_sdk_python_compute_worker.microvm`, and passes its structured fields in `extra`. Every line about a job carries its `callbackId`. `CallbackReporter.create` and the heartbeats take the same `logger` argument. Configure `logging` in the image to see its INFO lines, for example with `logging.basicConfig(level=logging.INFO)`. Any object with the `logging.Logger` signatures for `info`, `warning`, and `error` can replace it. A logger that raises does not stop the worker: the line is dropped. ## Permissions diff --git a/packages/aws-durable-execution-sdk-python-microvm-worker/pyproject.toml b/packages/aws-durable-execution-sdk-python-compute-worker/pyproject.toml similarity index 81% rename from packages/aws-durable-execution-sdk-python-microvm-worker/pyproject.toml rename to packages/aws-durable-execution-sdk-python-compute-worker/pyproject.toml index 64190f4e7..60f4ea4b4 100644 --- a/packages/aws-durable-execution-sdk-python-microvm-worker/pyproject.toml +++ b/packages/aws-durable-execution-sdk-python-compute-worker/pyproject.toml @@ -3,7 +3,7 @@ requires = ["hatchling!=1.32.1,<1.33"] build-backend = "hatchling.build" [project] -name = "aws-durable-execution-sdk-python-microvm-worker" +name = "aws-durable-execution-sdk-python-compute-worker" dynamic = ["version"] description = 'Runs jobs from AWS Lambda durable functions inside an AWS Lambda MicroVM' readme = "README.md" @@ -39,23 +39,23 @@ Source = "https://github.com/aws/aws-durable-execution-sdk-python" "../../NOTICE" = "NOTICE" [tool.hatch.build.targets.wheel] -packages = ["src/aws_durable_execution_sdk_python_microvm_worker"] +packages = ["src/aws_durable_execution_sdk_python_compute_worker"] [tool.hatch.build.targets.wheel.force-include] -"../../LICENSE" = "aws_durable_execution_sdk_python_microvm_worker/LICENSE" -"../../NOTICE" = "aws_durable_execution_sdk_python_microvm_worker/NOTICE" +"../../LICENSE" = "aws_durable_execution_sdk_python_compute_worker/LICENSE" +"../../NOTICE" = "aws_durable_execution_sdk_python_compute_worker/NOTICE" [tool.hatch.version] -path = "src/aws_durable_execution_sdk_python_microvm_worker/__about__.py" +path = "src/aws_durable_execution_sdk_python_compute_worker/__about__.py" [tool.hatch.publish.index] disable = true [tool.coverage.run] -source_pkgs = ["aws_durable_execution_sdk_python_microvm_worker"] +source_pkgs = ["aws_durable_execution_sdk_python_compute_worker"] branch = true parallel = true -omit = ["src/aws_durable_execution_sdk_python_microvm_worker/__about__.py"] +omit = ["src/aws_durable_execution_sdk_python_compute_worker/__about__.py"] [tool.coverage.report] exclude_lines = ["no cov", "if __name__ == .__main__.:", "if TYPE_CHECKING:"] @@ -69,7 +69,7 @@ preview = true select = ["E4", "E7", "E9", "F", "TID252"] [tool.ruff.lint.isort] -known-first-party = ["aws_durable_execution_sdk_python_microvm_worker"] +known-first-party = ["aws_durable_execution_sdk_python_compute_worker"] force-single-line = false lines-after-imports = 2 diff --git a/packages/aws-durable-execution-sdk-python-microvm-worker/src/aws_durable_execution_sdk_python_microvm_worker/__about__.py b/packages/aws-durable-execution-sdk-python-compute-worker/src/aws_durable_execution_sdk_python_compute_worker/__about__.py similarity index 100% rename from packages/aws-durable-execution-sdk-python-microvm-worker/src/aws_durable_execution_sdk_python_microvm_worker/__about__.py rename to packages/aws-durable-execution-sdk-python-compute-worker/src/aws_durable_execution_sdk_python_compute_worker/__about__.py diff --git a/packages/aws-durable-execution-sdk-python-compute-worker/src/aws_durable_execution_sdk_python_compute_worker/__init__.py b/packages/aws-durable-execution-sdk-python-compute-worker/src/aws_durable_execution_sdk_python_compute_worker/__init__.py new file mode 100644 index 000000000..a81cf9547 --- /dev/null +++ b/packages/aws-durable-execution-sdk-python-compute-worker/src/aws_durable_execution_sdk_python_compute_worker/__init__.py @@ -0,0 +1,16 @@ +# SPDX-FileCopyrightText: 2026-present Amazon.com, Inc. or its affiliates. +# +# SPDX-License-Identifier: Apache-2.0 +"""Runs jobs from AWS Lambda durable functions on compute that is defined +outside the durable function. + +This package is experimental. Its API can change in any release. + +Each compute type has its own subpackage. The worker for AWS Lambda MicroVMs +is in :mod:`aws_durable_execution_sdk_python_compute_worker.microvm`. +""" + +from aws_durable_execution_sdk_python_compute_worker.__about__ import __version__ + + +__all__ = ["__version__"] diff --git a/packages/aws-durable-execution-sdk-python-microvm-worker/src/aws_durable_execution_sdk_python_microvm_worker/__init__.py b/packages/aws-durable-execution-sdk-python-compute-worker/src/aws_durable_execution_sdk_python_compute_worker/microvm/__init__.py similarity index 81% rename from packages/aws-durable-execution-sdk-python-microvm-worker/src/aws_durable_execution_sdk_python_microvm_worker/__init__.py rename to packages/aws-durable-execution-sdk-python-compute-worker/src/aws_durable_execution_sdk_python_compute_worker/microvm/__init__.py index 85772f14e..596abf8a6 100644 --- a/packages/aws-durable-execution-sdk-python-microvm-worker/src/aws_durable_execution_sdk_python_microvm_worker/__init__.py +++ b/packages/aws-durable-execution-sdk-python-compute-worker/src/aws_durable_execution_sdk_python_compute_worker/microvm/__init__.py @@ -11,8 +11,8 @@ has no ``AbortSignal``. """ -from aws_durable_execution_sdk_python_microvm_worker.__about__ import __version__ -from aws_durable_execution_sdk_python_microvm_worker.callback_reporter import ( +from aws_durable_execution_sdk_python_compute_worker.__about__ import __version__ +from aws_durable_execution_sdk_python_compute_worker.microvm.callback_reporter import ( MAX_CALLBACK_RESULT_BYTES, CallbackReporter, CallCancelledError, @@ -21,10 +21,10 @@ ResultTooLargeError, is_terminal_callback_error, ) -from aws_durable_execution_sdk_python_microvm_worker.logger import ( +from aws_durable_execution_sdk_python_compute_worker.microvm.logger import ( MicrovmWorkerLogger, ) -from aws_durable_execution_sdk_python_microvm_worker.payload import ( +from aws_durable_execution_sdk_python_compute_worker.microvm.payload import ( SUPPORTED_PAYLOAD_VERSION, InvalidRunHookPayloadError, MicrovmJobDocument, @@ -32,7 +32,7 @@ MicrovmRunHookPayload, RunHookRequest, ) -from aws_durable_execution_sdk_python_microvm_worker.worker import ( +from aws_durable_execution_sdk_python_compute_worker.microvm.worker import ( HOOK_PATH_PREFIX, MICROVM_JOB_PATH, MicrovmJobContext, diff --git a/packages/aws-durable-execution-sdk-python-microvm-worker/src/aws_durable_execution_sdk_python_microvm_worker/callback_reporter.py b/packages/aws-durable-execution-sdk-python-compute-worker/src/aws_durable_execution_sdk_python_compute_worker/microvm/callback_reporter.py similarity index 99% rename from packages/aws-durable-execution-sdk-python-microvm-worker/src/aws_durable_execution_sdk_python_microvm_worker/callback_reporter.py rename to packages/aws-durable-execution-sdk-python-compute-worker/src/aws_durable_execution_sdk_python_compute_worker/microvm/callback_reporter.py index 8c5291d60..1888fbddc 100644 --- a/packages/aws-durable-execution-sdk-python-microvm-worker/src/aws_durable_execution_sdk_python_microvm_worker/callback_reporter.py +++ b/packages/aws-durable-execution-sdk-python-compute-worker/src/aws_durable_execution_sdk_python_compute_worker/microvm/callback_reporter.py @@ -18,7 +18,7 @@ from botocore.exceptions import ClientError, NoCredentialsError -from aws_durable_execution_sdk_python_microvm_worker.logger import ( +from aws_durable_execution_sdk_python_compute_worker.microvm.logger import ( MicrovmWorkerLogger, safe_get, safe_logger, diff --git a/packages/aws-durable-execution-sdk-python-microvm-worker/src/aws_durable_execution_sdk_python_microvm_worker/heartbeats.py b/packages/aws-durable-execution-sdk-python-compute-worker/src/aws_durable_execution_sdk_python_compute_worker/microvm/heartbeats.py similarity index 98% rename from packages/aws-durable-execution-sdk-python-microvm-worker/src/aws_durable_execution_sdk_python_microvm_worker/heartbeats.py rename to packages/aws-durable-execution-sdk-python-compute-worker/src/aws_durable_execution_sdk_python_compute_worker/microvm/heartbeats.py index 01e82b987..5ef350e66 100644 --- a/packages/aws-durable-execution-sdk-python-microvm-worker/src/aws_durable_execution_sdk_python_microvm_worker/heartbeats.py +++ b/packages/aws-durable-execution-sdk-python-compute-worker/src/aws_durable_execution_sdk_python_compute_worker/microvm/heartbeats.py @@ -14,7 +14,7 @@ import threading from collections.abc import Callable -from aws_durable_execution_sdk_python_microvm_worker.callback_reporter import ( +from aws_durable_execution_sdk_python_compute_worker.microvm.callback_reporter import ( CLOSED_CALLBACK_CODE, CallbackReporter, CancelScope, @@ -22,12 +22,14 @@ is_permanent_error, is_terminal_callback_error, ) -from aws_durable_execution_sdk_python_microvm_worker.logger import ( +from aws_durable_execution_sdk_python_compute_worker.microvm.logger import ( MicrovmWorkerLogger, describe, safe_logger, ) -from aws_durable_execution_sdk_python_microvm_worker.payload import is_finite_number +from aws_durable_execution_sdk_python_compute_worker.microvm.payload import ( + is_finite_number, +) MAX_HEARTBEAT_INTERVAL_SECONDS = 15 * 60.0 diff --git a/packages/aws-durable-execution-sdk-python-microvm-worker/src/aws_durable_execution_sdk_python_microvm_worker/logger.py b/packages/aws-durable-execution-sdk-python-compute-worker/src/aws_durable_execution_sdk_python_compute_worker/microvm/logger.py similarity index 97% rename from packages/aws-durable-execution-sdk-python-microvm-worker/src/aws_durable_execution_sdk_python_microvm_worker/logger.py rename to packages/aws-durable-execution-sdk-python-compute-worker/src/aws_durable_execution_sdk_python_compute_worker/microvm/logger.py index 2bd1127a1..18268f132 100644 --- a/packages/aws-durable-execution-sdk-python-microvm-worker/src/aws_durable_execution_sdk_python_microvm_worker/logger.py +++ b/packages/aws-durable-execution-sdk-python-compute-worker/src/aws_durable_execution_sdk_python_compute_worker/microvm/logger.py @@ -12,7 +12,7 @@ T = TypeVar("T") -DEFAULT_LOGGER_NAME = "aws_durable_execution_sdk_python_microvm_worker" +DEFAULT_LOGGER_NAME = "aws_durable_execution_sdk_python_compute_worker.microvm" """The name of the standard library logger that the worker uses by default.""" diff --git a/packages/aws-durable-execution-sdk-python-microvm-worker/src/aws_durable_execution_sdk_python_microvm_worker/payload.py b/packages/aws-durable-execution-sdk-python-compute-worker/src/aws_durable_execution_sdk_python_compute_worker/microvm/payload.py similarity index 99% rename from packages/aws-durable-execution-sdk-python-microvm-worker/src/aws_durable_execution_sdk_python_microvm_worker/payload.py rename to packages/aws-durable-execution-sdk-python-compute-worker/src/aws_durable_execution_sdk_python_compute_worker/microvm/payload.py index 18e047ced..d6d628e03 100644 --- a/packages/aws-durable-execution-sdk-python-microvm-worker/src/aws_durable_execution_sdk_python_microvm_worker/payload.py +++ b/packages/aws-durable-execution-sdk-python-compute-worker/src/aws_durable_execution_sdk_python_compute_worker/microvm/payload.py @@ -11,7 +11,7 @@ Both carry the same job fields. The contract is the same for every SDK language, so a durable function in one language can drive a worker in -another. The JavaScript worker in ``@aws/durable-execution-sdk-js-microvm-worker`` +another. The JavaScript worker in ``@aws/durable-execution-sdk-js-compute-worker`` defines the same documents. A change to the contract must be made in every language. """ diff --git a/packages/aws-durable-execution-sdk-python-microvm-worker/src/aws_durable_execution_sdk_python_microvm_worker/self_suspend.py b/packages/aws-durable-execution-sdk-python-compute-worker/src/aws_durable_execution_sdk_python_compute_worker/microvm/self_suspend.py similarity index 98% rename from packages/aws-durable-execution-sdk-python-microvm-worker/src/aws_durable_execution_sdk_python_microvm_worker/self_suspend.py rename to packages/aws-durable-execution-sdk-python-compute-worker/src/aws_durable_execution_sdk_python_compute_worker/microvm/self_suspend.py index f6c3ed385..7a12b4560 100644 --- a/packages/aws-durable-execution-sdk-python-microvm-worker/src/aws_durable_execution_sdk_python_microvm_worker/self_suspend.py +++ b/packages/aws-durable-execution-sdk-python-compute-worker/src/aws_durable_execution_sdk_python_compute_worker/microvm/self_suspend.py @@ -24,11 +24,11 @@ from botocore.config import Config from botocore.exceptions import ClientError, NoCredentialsError -from aws_durable_execution_sdk_python_microvm_worker.callback_reporter import ( +from aws_durable_execution_sdk_python_compute_worker.microvm.callback_reporter import ( TRANSIENT_4XX_CODES, error_code, ) -from aws_durable_execution_sdk_python_microvm_worker.logger import safe_get +from aws_durable_execution_sdk_python_compute_worker.microvm.logger import safe_get if TYPE_CHECKING: diff --git a/packages/aws-durable-execution-sdk-python-microvm-worker/src/aws_durable_execution_sdk_python_microvm_worker/worker.py b/packages/aws-durable-execution-sdk-python-compute-worker/src/aws_durable_execution_sdk_python_compute_worker/microvm/worker.py similarity index 99% rename from packages/aws-durable-execution-sdk-python-microvm-worker/src/aws_durable_execution_sdk_python_microvm_worker/worker.py rename to packages/aws-durable-execution-sdk-python-compute-worker/src/aws_durable_execution_sdk_python_compute_worker/microvm/worker.py index 6d8152345..00ec72fe5 100644 --- a/packages/aws-durable-execution-sdk-python-microvm-worker/src/aws_durable_execution_sdk_python_microvm_worker/worker.py +++ b/packages/aws-durable-execution-sdk-python-compute-worker/src/aws_durable_execution_sdk_python_compute_worker/microvm/worker.py @@ -27,29 +27,29 @@ from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer from typing import TYPE_CHECKING, Any -from aws_durable_execution_sdk_python_microvm_worker.callback_reporter import ( +from aws_durable_execution_sdk_python_compute_worker.microvm.callback_reporter import ( CallbackReporter, ResultSerializationError, ResultTooLargeError, is_terminal_callback_error, ) -from aws_durable_execution_sdk_python_microvm_worker.heartbeats import ( +from aws_durable_execution_sdk_python_compute_worker.microvm.heartbeats import ( Heartbeats, validate_heartbeat_interval, ) -from aws_durable_execution_sdk_python_microvm_worker.logger import ( +from aws_durable_execution_sdk_python_compute_worker.microvm.logger import ( MicrovmWorkerLogger, describe, safe_logger, ) -from aws_durable_execution_sdk_python_microvm_worker.payload import ( +from aws_durable_execution_sdk_python_compute_worker.microvm.payload import ( InvalidRunHookPayloadError, MicrovmJobDocument, MicrovmJobRequest, RunHookRequest, loads_strict, ) -from aws_durable_execution_sdk_python_microvm_worker.self_suspend import ( +from aws_durable_execution_sdk_python_compute_worker.microvm.self_suspend import ( SUSPEND_CALL_TIMEOUT_SECONDS, SUSPEND_GRACE_SECONDS, SuspendOutcome, @@ -2064,7 +2064,7 @@ def version_string(self) -> str: # The base class names the exact Python version in the Server header. # Every caller of the MicroVM endpoint would learn it, and no caller # needs it. - return "aws-durable-execution-sdk-python-microvm-worker" + return "aws-durable-execution-sdk-python-compute-worker" class _Exchange: diff --git a/packages/aws-durable-execution-sdk-python-microvm-worker/src/aws_durable_execution_sdk_python_microvm_worker/py.typed b/packages/aws-durable-execution-sdk-python-compute-worker/src/aws_durable_execution_sdk_python_compute_worker/py.typed similarity index 100% rename from packages/aws-durable-execution-sdk-python-microvm-worker/src/aws_durable_execution_sdk_python_microvm_worker/py.typed rename to packages/aws-durable-execution-sdk-python-compute-worker/src/aws_durable_execution_sdk_python_compute_worker/py.typed diff --git a/packages/aws-durable-execution-sdk-python-microvm-worker/tests/conftest.py b/packages/aws-durable-execution-sdk-python-compute-worker/tests/conftest.py similarity index 100% rename from packages/aws-durable-execution-sdk-python-microvm-worker/tests/conftest.py rename to packages/aws-durable-execution-sdk-python-compute-worker/tests/conftest.py diff --git a/packages/aws-durable-execution-sdk-python-microvm-worker/tests/callback_reporter_test.py b/packages/aws-durable-execution-sdk-python-compute-worker/tests/microvm/callback_reporter_test.py similarity index 98% rename from packages/aws-durable-execution-sdk-python-microvm-worker/tests/callback_reporter_test.py rename to packages/aws-durable-execution-sdk-python-compute-worker/tests/microvm/callback_reporter_test.py index ae3a32c94..656287ec7 100644 --- a/packages/aws-durable-execution-sdk-python-microvm-worker/tests/callback_reporter_test.py +++ b/packages/aws-durable-execution-sdk-python-compute-worker/tests/microvm/callback_reporter_test.py @@ -16,8 +16,8 @@ from botocore.exceptions import BotoCoreError, NoCredentialsError from botocore.stub import Stubber -from aws_durable_execution_sdk_python_microvm_worker import callback_reporter -from aws_durable_execution_sdk_python_microvm_worker.callback_reporter import ( +from aws_durable_execution_sdk_python_compute_worker.microvm import callback_reporter +from aws_durable_execution_sdk_python_compute_worker.microvm.callback_reporter import ( CLOSED_CALLBACK_CODE, MAX_CALLBACK_RESULT_BYTES, CallbackReporter, diff --git a/packages/aws-durable-execution-sdk-python-microvm-worker/tests/heartbeats_test.py b/packages/aws-durable-execution-sdk-python-compute-worker/tests/microvm/heartbeats_test.py similarity index 98% rename from packages/aws-durable-execution-sdk-python-microvm-worker/tests/heartbeats_test.py rename to packages/aws-durable-execution-sdk-python-compute-worker/tests/microvm/heartbeats_test.py index 86983c1c2..45cf9cd5b 100644 --- a/packages/aws-durable-execution-sdk-python-microvm-worker/tests/heartbeats_test.py +++ b/packages/aws-durable-execution-sdk-python-compute-worker/tests/microvm/heartbeats_test.py @@ -12,10 +12,10 @@ import pytest -from aws_durable_execution_sdk_python_microvm_worker.callback_reporter import ( +from aws_durable_execution_sdk_python_compute_worker.microvm.callback_reporter import ( CallbackReporter, ) -from aws_durable_execution_sdk_python_microvm_worker.heartbeats import ( +from aws_durable_execution_sdk_python_compute_worker.microvm.heartbeats import ( MAX_HEARTBEAT_INTERVAL_SECONDS, MAX_QUICK_HEARTBEAT_RETRIES, Heartbeats, diff --git a/packages/aws-durable-execution-sdk-python-microvm-worker/tests/lifecycle_hooks_test.py b/packages/aws-durable-execution-sdk-python-compute-worker/tests/microvm/lifecycle_hooks_test.py similarity index 99% rename from packages/aws-durable-execution-sdk-python-microvm-worker/tests/lifecycle_hooks_test.py rename to packages/aws-durable-execution-sdk-python-compute-worker/tests/microvm/lifecycle_hooks_test.py index 7c9214155..5b21e3b20 100644 --- a/packages/aws-durable-execution-sdk-python-microvm-worker/tests/lifecycle_hooks_test.py +++ b/packages/aws-durable-execution-sdk-python-compute-worker/tests/microvm/lifecycle_hooks_test.py @@ -27,7 +27,7 @@ from botocore.exceptions import ClientError, ConnectionClosedError, NoCredentialsError from botocore.retries.standard import ExponentialBackoff -from aws_durable_execution_sdk_python_microvm_worker import ( +from aws_durable_execution_sdk_python_compute_worker.microvm import ( HOOK_PATH_PREFIX, MicrovmJobContext, MicrovmTerminatedError, @@ -35,7 +35,9 @@ MicrovmWorkerListener, start_microvm_worker, ) -from aws_durable_execution_sdk_python_microvm_worker import worker as worker_module +from aws_durable_execution_sdk_python_compute_worker.microvm import ( + worker as worker_module, +) WAIT = 10.0 @@ -178,7 +180,7 @@ def reaches_worker(worker: MicrovmWorker) -> bool: return False finally: connection.close() - return server.startswith("aws-durable-execution-sdk-python-microvm-worker") + return server.startswith("aws-durable-execution-sdk-python-compute-worker") def start_reachable_worker(start: Callable[[], MicrovmWorker]) -> MicrovmWorker: diff --git a/packages/aws-durable-execution-sdk-python-microvm-worker/tests/logger_test.py b/packages/aws-durable-execution-sdk-python-compute-worker/tests/microvm/logger_test.py similarity index 96% rename from packages/aws-durable-execution-sdk-python-microvm-worker/tests/logger_test.py rename to packages/aws-durable-execution-sdk-python-compute-worker/tests/microvm/logger_test.py index 7e95b09e1..1def65ae3 100644 --- a/packages/aws-durable-execution-sdk-python-microvm-worker/tests/logger_test.py +++ b/packages/aws-durable-execution-sdk-python-compute-worker/tests/microvm/logger_test.py @@ -7,7 +7,7 @@ import logging -from aws_durable_execution_sdk_python_microvm_worker.logger import ( +from aws_durable_execution_sdk_python_compute_worker.microvm.logger import ( DEFAULT_LOGGER_NAME, default_logger, describe, diff --git a/packages/aws-durable-execution-sdk-python-microvm-worker/tests/payload_test.py b/packages/aws-durable-execution-sdk-python-compute-worker/tests/microvm/payload_test.py similarity index 99% rename from packages/aws-durable-execution-sdk-python-microvm-worker/tests/payload_test.py rename to packages/aws-durable-execution-sdk-python-compute-worker/tests/microvm/payload_test.py index 2192fd220..a806ec48f 100644 --- a/packages/aws-durable-execution-sdk-python-microvm-worker/tests/payload_test.py +++ b/packages/aws-durable-execution-sdk-python-compute-worker/tests/microvm/payload_test.py @@ -11,7 +11,7 @@ import pytest -from aws_durable_execution_sdk_python_microvm_worker.payload import ( +from aws_durable_execution_sdk_python_compute_worker.microvm.payload import ( InvalidRunHookPayloadError, MicrovmJobDocument, MicrovmJobRequest, diff --git a/packages/aws-durable-execution-sdk-python-microvm-worker/tests/self_suspend_test.py b/packages/aws-durable-execution-sdk-python-compute-worker/tests/microvm/self_suspend_test.py similarity index 99% rename from packages/aws-durable-execution-sdk-python-microvm-worker/tests/self_suspend_test.py rename to packages/aws-durable-execution-sdk-python-compute-worker/tests/microvm/self_suspend_test.py index 71dc12b3b..a7240c073 100644 --- a/packages/aws-durable-execution-sdk-python-microvm-worker/tests/self_suspend_test.py +++ b/packages/aws-durable-execution-sdk-python-compute-worker/tests/microvm/self_suspend_test.py @@ -26,7 +26,7 @@ ) from botocore.retries.standard import ExponentialBackoff -from aws_durable_execution_sdk_python_microvm_worker.self_suspend import ( +from aws_durable_execution_sdk_python_compute_worker.microvm.self_suspend import ( SUSPEND_CALL_TIMEOUT_SECONDS, SuspendDeadlineError, SuspendOutcome, diff --git a/packages/aws-durable-execution-sdk-python-microvm-worker/tests/worker_test.py b/packages/aws-durable-execution-sdk-python-compute-worker/tests/microvm/worker_test.py similarity index 99% rename from packages/aws-durable-execution-sdk-python-microvm-worker/tests/worker_test.py rename to packages/aws-durable-execution-sdk-python-compute-worker/tests/microvm/worker_test.py index 4e0cd2605..c40ae8bdd 100644 --- a/packages/aws-durable-execution-sdk-python-microvm-worker/tests/worker_test.py +++ b/packages/aws-durable-execution-sdk-python-compute-worker/tests/microvm/worker_test.py @@ -20,7 +20,7 @@ import pytest -from aws_durable_execution_sdk_python_microvm_worker import ( +from aws_durable_execution_sdk_python_compute_worker.microvm import ( HOOK_PATH_PREFIX, MICROVM_JOB_PATH, MicrovmJobContext, @@ -28,7 +28,9 @@ MicrovmWorkerListener, start_microvm_worker, ) -from aws_durable_execution_sdk_python_microvm_worker import worker as worker_module +from aws_durable_execution_sdk_python_compute_worker.microvm import ( + worker as worker_module, +) RUN = f"{HOOK_PATH_PREFIX}run" @@ -87,7 +89,7 @@ def reaches_worker(worker: MicrovmWorker) -> bool: return False finally: connection.close() - return server.startswith("aws-durable-execution-sdk-python-microvm-worker") + return server.startswith("aws-durable-execution-sdk-python-compute-worker") def start_reachable_worker(start: Callable[[], MicrovmWorker]) -> MicrovmWorker: @@ -575,7 +577,7 @@ def create_client(region: str) -> Any: return client monkeypatch.setattr( - "aws_durable_execution_sdk_python_microvm_worker.callback_reporter._create_client", + "aws_durable_execution_sdk_python_compute_worker.microvm.callback_reporter._create_client", create_client, ) worker = start_microvm_worker(handler=lambda job_input, context: "ok", port=0) @@ -1053,7 +1055,7 @@ def test_names_no_python_version_in_the_server_header(start: Any) -> None: "Content-Length: 2\r\n\r\n{}".encode(), ) - assert b"Server: aws-durable-execution-sdk-python-microvm-worker\r\n" in answer + assert b"Server: aws-durable-execution-sdk-python-compute-worker\r\n" in answer assert b"Python/" not in answer diff --git a/packages/aws-durable-execution-sdk-python-examples/microvm-image/app.py b/packages/aws-durable-execution-sdk-python-examples/microvm-image/app.py index 4b1ccbf04..76e411ad4 100644 --- a/packages/aws-durable-execution-sdk-python-examples/microvm-image/app.py +++ b/packages/aws-durable-execution-sdk-python-examples/microvm-image/app.py @@ -14,7 +14,7 @@ from pathlib import Path from typing import Any -from aws_durable_execution_sdk_python_microvm_worker import ( +from aws_durable_execution_sdk_python_compute_worker.microvm import ( MicrovmJobContext, start_microvm_worker, ) diff --git a/packages/aws-durable-execution-sdk-python-examples/scripts/ensure_microvm_image.py b/packages/aws-durable-execution-sdk-python-examples/scripts/ensure_microvm_image.py index dc9cfc601..9ee8ddaab 100644 --- a/packages/aws-durable-execution-sdk-python-examples/scripts/ensure_microvm_image.py +++ b/packages/aws-durable-execution-sdk-python-examples/scripts/ensure_microvm_image.py @@ -52,7 +52,7 @@ EXAMPLES_DIR = Path(__file__).resolve().parent.parent IMAGE_DIR = EXAMPLES_DIR / "microvm-image" OUT_DIR = EXAMPLES_DIR / ".microvm-image-build" -WORKER_DIR = EXAMPLES_DIR.parent / "aws-durable-execution-sdk-python-microvm-worker" +WORKER_DIR = EXAMPLES_DIR.parent / "aws-durable-execution-sdk-python-compute-worker" IMAGE_FILES = ("Dockerfile", "app.py", "constraints.txt") IMAGE_NAME_PREFIX = "sdk-python-examples" HASH_LENGTH = 12 diff --git a/packages/aws-durable-execution-sdk-python-examples/test/README.md b/packages/aws-durable-execution-sdk-python-examples/test/README.md index 98af91890..cce0928a7 100644 --- a/packages/aws-durable-execution-sdk-python-examples/test/README.md +++ b/packages/aws-durable-execution-sdk-python-examples/test/README.md @@ -143,7 +143,7 @@ def test_my_example(durable_runner): ### MicroVM Image `microvm-image/` holds the app, the Dockerfile, and the dependency pins of the MicroVM image that the MicroVM examples run. `hatch run examples:ensure-microvm-image --output image.json` builds the image or reuses it. It needs `TEST_ACCOUNT_ID`, `AWS_REGION`, and AWS credentials for the test account. -1. The script builds the worker wheel from `packages/aws-durable-execution-sdk-python-microvm-worker`, and zips it with the files in `microvm-image/`. +1. The script builds the worker wheel from `packages/aws-durable-execution-sdk-python-compute-worker`, and zips it with the files in `microvm-image/`. 2. The image name is `sdk-python-examples-`. The hash covers the worker's source and `pyproject.toml`, the files in `microvm-image/`, and the `CreateMicrovmImage` settings. 3. So a run with unchanged inputs reuses the image. A change to any input builds a new image. 4. The script writes `{"imageArn": ..., "executionRoleArn": ...}` to `--output`. CI passes both to `sam deploy` as `MicrovmImageArn` and `MicrovmExecutionRoleArn`, in the Python 3.13 job only. diff --git a/packages/aws-durable-execution-sdk-python-examples/test/test_microvm_image_app.py b/packages/aws-durable-execution-sdk-python-examples/test/test_microvm_image_app.py index e07dec3a1..f1c5431b3 100644 --- a/packages/aws-durable-execution-sdk-python-examples/test/test_microvm_image_app.py +++ b/packages/aws-durable-execution-sdk-python-examples/test/test_microvm_image_app.py @@ -13,7 +13,7 @@ import pytest -pytest.importorskip("aws_durable_execution_sdk_python_microvm_worker") +pytest.importorskip("aws_durable_execution_sdk_python_compute_worker.microvm") APP_PATH = Path(__file__).resolve().parents[1] / "microvm-image" / "app.py" SPEC = importlib.util.spec_from_file_location("microvm_image_app", APP_PATH) @@ -58,7 +58,7 @@ def test_rejects_a_key_that_is_not_a_plain_file_name(monkeypatch, tmp_path, key) def test_the_worker_accepts_the_handlers(): # The worker rejects an async handler when it starts. This builds the # listener with the app's handlers, without a server. - from aws_durable_execution_sdk_python_microvm_worker import ( + from aws_durable_execution_sdk_python_compute_worker.microvm import ( MicrovmWorkerListener, ) diff --git a/packages/aws-durable-execution-sdk-python-extras/README.md b/packages/aws-durable-execution-sdk-python-extras/README.md index 14c849b5d..b1f45c239 100644 --- a/packages/aws-durable-execution-sdk-python-extras/README.md +++ b/packages/aws-durable-execution-sdk-python-extras/README.md @@ -37,7 +37,7 @@ def handler(event: dict, context: DurableContext) -> dict: `job_input` and `config` are keyword-only. Inside a child context or a `map` item, pass that context as the first argument. -The image runs the [MicroVM worker](https://github.com/aws/aws-durable-execution-sdk-python/tree/main/packages/aws-durable-execution-sdk-python-microvm-worker). The worker receives the job and reports its result. +The image runs the [MicroVM worker](https://github.com/aws/aws-durable-execution-sdk-python/tree/main/packages/aws-durable-execution-sdk-python-compute-worker). The worker receives the job and reports its result. ## Common uses @@ -224,7 +224,7 @@ The MicroVM's execution role needs `lambda:SendDurableExecutionCallbackSuccess`, ## Reference - [docs/microvm.md](https://github.com/aws/aws-durable-execution-sdk-python/blob/main/packages/aws-durable-execution-sdk-python-extras/docs/microvm.md): job delivery, the durable operations each call records, all errors, the retry tiers, the state check, every permission, and best practices. -- [MicroVM worker](https://github.com/aws/aws-durable-execution-sdk-python/tree/main/packages/aws-durable-execution-sdk-python-microvm-worker): the code that runs in the MicroVM. +- [MicroVM worker](https://github.com/aws/aws-durable-execution-sdk-python/tree/main/packages/aws-durable-execution-sdk-python-compute-worker): the code that runs in the MicroVM. - [Source](https://github.com/aws/aws-durable-execution-sdk-python/tree/main/packages/aws-durable-execution-sdk-python-extras/src/aws_durable_execution_sdk_python_extras/compute/microvm): config fields and docstrings. - [`@aws/durable-execution-sdk-js-extras`](https://github.com/aws/aws-durable-execution-sdk-js/tree/main/packages/aws-durable-execution-sdk-js-extras): the JavaScript counterpart. - [Lambda MicroVMs guide](https://docs.aws.amazon.com/lambda/latest/dg/lambda-microvms-guide.html). diff --git a/packages/aws-durable-execution-sdk-python-extras/docs/microvm.md b/packages/aws-durable-execution-sdk-python-extras/docs/microvm.md index fa637eefe..1cfa324f8 100644 --- a/packages/aws-durable-execution-sdk-python-extras/docs/microvm.md +++ b/packages/aws-durable-execution-sdk-python-extras/docs/microvm.md @@ -30,7 +30,7 @@ def handler(event: dict, context: DurableContext) -> dict: The first argument is the context that the call runs in. Inside a child context or a `map` item, pass that context, so the operation's steps belong to it. `job_input` and `config` are keyword-only. A job can be a string, and so is the name. So positional arguments in the wrong order would pass validation and run the wrong job. -The code in the MicroVM receives the job and reports its result. The worker package [`aws-durable-execution-sdk-python-microvm-worker`](../../aws-durable-execution-sdk-python-microvm-worker) does this, and so does the JavaScript worker. The job document is the same in every SDK language. +The code in the MicroVM receives the job and reports its result. The worker package [`aws-durable-execution-sdk-python-compute-worker`](../../aws-durable-execution-sdk-python-compute-worker) does this, and so does the JavaScript worker. The job document is the same in every SDK language. ### How the job reaches the MicroVM @@ -297,7 +297,7 @@ Suspending is off by default, because it needs more settings and changes what th - With `auto_suspend_on_idle`, the MicroVM's role needs `lambda:SuspendMicrovm` on the image. That permission lets code in any MicroVM of the image suspend any other. So use one image per trust boundary. - Background processes that an earlier job started stop while the MicroVM is suspended. The worker counts only its running jobs. -The worker must support `auto_suspend_on_idle`. The JavaScript worker [`@aws/durable-execution-sdk-js-microvm-worker`](https://github.com/aws/aws-durable-execution-sdk-js/tree/main/packages/aws-durable-execution-sdk-js-microvm-worker) and the Python worker [`aws-durable-execution-sdk-python-microvm-worker`](../../aws-durable-execution-sdk-python-microvm-worker) both do. Enable the `suspend` and `resume` hooks in the image. The worker then refuses jobs while the MicroVM freezes, and accepts them again as soon as it resumes. Without the `resume` hook, the first job after a resume can wait a little over 30 seconds, until the worker's refusal ends and the request step delivers again. +The worker must support `auto_suspend_on_idle`. The JavaScript worker [`@aws/durable-execution-sdk-js-compute-worker`](https://github.com/aws/aws-durable-execution-sdk-js/tree/main/packages/aws-durable-execution-sdk-js-compute-worker) and the Python worker [`aws-durable-execution-sdk-python-compute-worker`](../../aws-durable-execution-sdk-python-compute-worker) both do. Enable the `suspend` and `resume` hooks in the image. The worker then refuses jobs while the MicroVM freezes, and accepts them again as soon as it resumes. Without the `resume` hook, the first job after a resume can wait a little over 30 seconds, until the worker's refusal ends and the request step delivers again. ### Suspending after a job @@ -419,7 +419,7 @@ The MicroVM operations handle the network, the service, and the worker lifecycle ### Job handlers -1. Follow [Best practices for job handlers](../../aws-durable-execution-sdk-python-microvm-worker/docs/worker.md#best-practices-for-job-handlers) in the worker README for the code that runs each job in the MicroVM. +1. Follow [Best practices for job handlers](../../aws-durable-execution-sdk-python-compute-worker/docs/worker.md#best-practices-for-job-handlers) in the worker README for the code that runs each job in the MicroVM. 2. Make the side effects of a job safe to repeat. - The worker ignores a second delivery of a callback ID. It remembers the callback IDs of its last 1,000 finished jobs, and it forgets them when its process restarts. - Each `microvm` call and each `vm.invoke` creates a new callback ID. So when your code runs a job again after a failure, the worker runs it again, also in the same MicroVM. diff --git a/packages/aws-durable-execution-sdk-python-extras/src/aws_durable_execution_sdk_python_extras/compute/microvm/config.py b/packages/aws-durable-execution-sdk-python-extras/src/aws_durable_execution_sdk_python_extras/compute/microvm/config.py index fee7c0b44..84dc1b6c9 100644 --- a/packages/aws-durable-execution-sdk-python-extras/src/aws_durable_execution_sdk_python_extras/compute/microvm/config.py +++ b/packages/aws-durable-execution-sdk-python-extras/src/aws_durable_execution_sdk_python_extras/compute/microvm/config.py @@ -88,7 +88,7 @@ class MicrovmBaseConfig: The image must enable the ``run`` lifecycle hook. The service then also requires the ``ready`` image hook. The worker package - ``aws-durable-execution-sdk-python-microvm-worker`` answers both. + ``aws-durable-execution-sdk-python-compute-worker`` answers both. """ execution_role_arn: str @@ -323,8 +323,8 @@ class MicrovmSessionConfig(MicrovmBaseConfig): not extend the MicroVM's lifetime. The worker must be a version that supports the setting. The JavaScript - worker ``@aws/durable-execution-sdk-js-microvm-worker`` and the Python - worker ``aws-durable-execution-sdk-python-microvm-worker`` in this + worker ``@aws/durable-execution-sdk-js-compute-worker`` and the Python + worker ``aws-durable-execution-sdk-python-compute-worker`` in this repository both do. """ diff --git a/packages/aws-durable-execution-sdk-python-extras/src/aws_durable_execution_sdk_python_extras/compute/microvm/job.py b/packages/aws-durable-execution-sdk-python-extras/src/aws_durable_execution_sdk_python_extras/compute/microvm/job.py index 1a9bcfaa6..aa3bc271e 100644 --- a/packages/aws-durable-execution-sdk-python-extras/src/aws_durable_execution_sdk_python_extras/compute/microvm/job.py +++ b/packages/aws-durable-execution-sdk-python-extras/src/aws_durable_execution_sdk_python_extras/compute/microvm/job.py @@ -4,8 +4,8 @@ """The job document that the operation sends to the MicroVM. The worker in the MicroVM reads the same document in every SDK language. The -Python worker in ``aws-durable-execution-sdk-python-microvm-worker`` and the -JavaScript worker in ``@aws/durable-execution-sdk-js-microvm-worker`` parse +Python worker in ``aws-durable-execution-sdk-python-compute-worker`` and the +JavaScript worker in ``@aws/durable-execution-sdk-js-compute-worker`` parse it. A change to the document must be made in every language. """ diff --git a/packages/aws-durable-execution-sdk-python-extras/src/aws_durable_execution_sdk_python_extras/compute/microvm/request.py b/packages/aws-durable-execution-sdk-python-extras/src/aws_durable_execution_sdk_python_extras/compute/microvm/request.py index ee95d2b54..de41cdb75 100644 --- a/packages/aws-durable-execution-sdk-python-extras/src/aws_durable_execution_sdk_python_extras/compute/microvm/request.py +++ b/packages/aws-durable-execution-sdk-python-extras/src/aws_durable_execution_sdk_python_extras/compute/microvm/request.py @@ -44,7 +44,7 @@ The worker package serves this path with its ``handler``. So the same handler receives a job whether it arrives in the ``run`` hook or over HTTP. The value -must equal ``MICROVM_JOB_PATH`` in ``aws-durable-execution-sdk-python-microvm-worker`` +must equal ``MICROVM_JOB_PATH`` in ``aws-durable-execution-sdk-python-compute-worker`` and ``DEFAULT_MICROVM_JOB_PATH`` in the JavaScript SDK. """ diff --git a/packages/aws-durable-execution-sdk-python-extras/tests/compute/microvm/job_test.py b/packages/aws-durable-execution-sdk-python-extras/tests/compute/microvm/job_test.py index 227b38c9b..c8e529da1 100644 --- a/packages/aws-durable-execution-sdk-python-extras/tests/compute/microvm/job_test.py +++ b/packages/aws-durable-execution-sdk-python-extras/tests/compute/microvm/job_test.py @@ -9,7 +9,7 @@ import math import pytest -from aws_durable_execution_sdk_python_microvm_worker import ( +from aws_durable_execution_sdk_python_compute_worker.microvm import ( MicrovmJobRequest, RunHookRequest, ) diff --git a/packages/aws-durable-execution-sdk-python-extras/tests/compute/microvm/request_test.py b/packages/aws-durable-execution-sdk-python-extras/tests/compute/microvm/request_test.py index 8d722ce42..7210af2cb 100644 --- a/packages/aws-durable-execution-sdk-python-extras/tests/compute/microvm/request_test.py +++ b/packages/aws-durable-execution-sdk-python-extras/tests/compute/microvm/request_test.py @@ -14,7 +14,7 @@ from typing import Any import pytest -from aws_durable_execution_sdk_python_microvm_worker import MICROVM_JOB_PATH +from aws_durable_execution_sdk_python_compute_worker.microvm import MICROVM_JOB_PATH from aws_durable_execution_sdk_python_extras.compute.microvm import ( DEFAULT_MICROVM_JOB_PATH, diff --git a/packages/aws-durable-execution-sdk-python-extras/tests/compute/microvm/worker_composed_test.py b/packages/aws-durable-execution-sdk-python-extras/tests/compute/microvm/worker_composed_test.py index 8c2ba2d35..2e49d2dc3 100644 --- a/packages/aws-durable-execution-sdk-python-extras/tests/compute/microvm/worker_composed_test.py +++ b/packages/aws-durable-execution-sdk-python-extras/tests/compute/microvm/worker_composed_test.py @@ -36,13 +36,15 @@ durable_execution, ) from aws_durable_execution_sdk_python.lambda_service import ErrorObject -from aws_durable_execution_sdk_python_microvm_worker import ( +from aws_durable_execution_sdk_python_compute_worker.microvm import ( HOOK_PATH_PREFIX, MicrovmJobContext, MicrovmWorker, start_microvm_worker, ) -from aws_durable_execution_sdk_python_microvm_worker import worker as worker_module +from aws_durable_execution_sdk_python_compute_worker.microvm import ( + worker as worker_module, +) from aws_durable_execution_sdk_python_testing.runner import DurableFunctionTestRunner from aws_durable_execution_sdk_python_extras.compute.microvm import ( @@ -114,7 +116,7 @@ def reaches_worker(worker: MicrovmWorker) -> bool: return False finally: connection.close() - return server.startswith("aws-durable-execution-sdk-python-microvm-worker") + return server.startswith("aws-durable-execution-sdk-python-compute-worker") def start_reachable_worker(start: Callable[[], MicrovmWorker]) -> MicrovmWorker: diff --git a/pyproject.toml b/pyproject.toml index d86a1e8d0..2011407cb 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -32,7 +32,7 @@ testpaths = [ "packages/aws-durable-execution-sdk-python/tests", "packages/aws-durable-execution-sdk-python-extras/tests", "packages/aws-durable-execution-sdk-python-telemetry-exporter/tests", - "packages/aws-durable-execution-sdk-python-microvm-worker/tests", + "packages/aws-durable-execution-sdk-python-compute-worker/tests", "packages/aws-durable-execution-sdk-python-otel/tests", "packages/aws-durable-execution-sdk-python-testing/tests", "packages/aws-durable-execution-sdk-python-examples/test", @@ -104,7 +104,7 @@ typecheck = "mypy --install-types --non-interactive packages/aws-durable-executi workspace.members = [ "packages/aws-durable-execution-sdk-python", "packages/aws-durable-execution-sdk-python-extras", - "packages/aws-durable-execution-sdk-python-microvm-worker", + "packages/aws-durable-execution-sdk-python-compute-worker", "packages/aws-durable-execution-sdk-python-testing", ] dependencies = [ @@ -120,8 +120,8 @@ test = "pytest packages/aws-durable-execution-sdk-python-extras/tests {args}" cov = "pytest --cov-report=term-missing --cov-config=packages/aws-durable-execution-sdk-python-extras/pyproject.toml --cov=packages/aws-durable-execution-sdk-python-extras/src/aws_durable_execution_sdk_python_extras packages/aws-durable-execution-sdk-python-extras/tests {args}" typecheck = "mypy --install-types --non-interactive packages/aws-durable-execution-sdk-python-extras/src/aws_durable_execution_sdk_python_extras packages/aws-durable-execution-sdk-python-extras/tests" -[tool.hatch.envs.dev-microvm-worker] -workspace.members = ["packages/aws-durable-execution-sdk-python-microvm-worker"] +[tool.hatch.envs.dev-compute-worker] +workspace.members = ["packages/aws-durable-execution-sdk-python-compute-worker"] dependencies = [ "pytest", "pytest-cov", @@ -130,10 +130,10 @@ dependencies = [ "boto3-stubs[lambda,lambda-microvms]", ] -[tool.hatch.envs.dev-microvm-worker.scripts] -test = "pytest packages/aws-durable-execution-sdk-python-microvm-worker/tests {args}" -cov = "pytest --cov-report=term-missing --cov-config=packages/aws-durable-execution-sdk-python-microvm-worker/pyproject.toml --cov=packages/aws-durable-execution-sdk-python-microvm-worker/src/aws_durable_execution_sdk_python_microvm_worker packages/aws-durable-execution-sdk-python-microvm-worker/tests {args}" -typecheck = "mypy --install-types --non-interactive packages/aws-durable-execution-sdk-python-microvm-worker/src/aws_durable_execution_sdk_python_microvm_worker packages/aws-durable-execution-sdk-python-microvm-worker/tests" +[tool.hatch.envs.dev-compute-worker.scripts] +test = "pytest packages/aws-durable-execution-sdk-python-compute-worker/tests {args}" +cov = "pytest --cov-report=term-missing --cov-config=packages/aws-durable-execution-sdk-python-compute-worker/pyproject.toml --cov=packages/aws-durable-execution-sdk-python-compute-worker/src/aws_durable_execution_sdk_python_compute_worker packages/aws-durable-execution-sdk-python-compute-worker/tests {args}" +typecheck = "mypy --install-types --non-interactive packages/aws-durable-execution-sdk-python-compute-worker/src/aws_durable_execution_sdk_python_compute_worker packages/aws-durable-execution-sdk-python-compute-worker/tests" [tool.hatch.envs.dev-testing] workspace.members = [ @@ -268,7 +268,7 @@ known-first-party = [ "aws_durable_execution_sdk_python", "aws_durable_execution_sdk_python_extras", "aws_durable_execution_sdk_python_telemetry_exporter", - "aws_durable_execution_sdk_python_microvm_worker", + "aws_durable_execution_sdk_python_compute_worker", "aws_durable_execution_sdk_python_otel", "aws_durable_execution_sdk_python_testing", ] From d2312ebfe7a8a820eea427bfffcd7ac30d801e61 Mon Sep 17 00:00:00 2001 From: Pooya Paridel Date: Tue, 10 Nov 2026 01:01:37 +0000 Subject: [PATCH 2/2] docs(ci): explain both worker names in js_examples The js_examples harness builds a checkout of any JS ref. A ref from before the worker rename has only microvm-worker, and a ref from after it has only compute-worker. The comments now say so, and say why microvm-worker stays after the JS rename merges. --- .github/scripts/js_examples/run.py | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/.github/scripts/js_examples/run.py b/.github/scripts/js_examples/run.py index 5f540b5e9..421312e6f 100755 --- a/.github/scripts/js_examples/run.py +++ b/.github/scripts/js_examples/run.py @@ -64,6 +64,14 @@ # The examples depend on these local workspaces. The root "npm run build" # also builds the telemetry tools and the VS Code extension, which the harness # does not need, so the script builds only these, in dependency order. +# +# The list holds both names of the worker package, microvm-worker and +# compute-worker. The harness builds a checkout of any JS ref: main by +# default, or the js_ref input of the workflow. A ref from before the rename +# in aws/aws-durable-execution-sdk-js#1204 has only microvm-worker, and the +# examples of that ref import it. A ref from after the rename has only +# compute-worker. So the list names both, and the build skips the one that +# the checkout does not have. See OPTIONAL_JS_BUILD_WORKSPACES. JS_BUILD_WORKSPACES = ( "packages/aws-durable-execution-sdk-js", "packages/aws-durable-execution-sdk-js-testing", @@ -73,10 +81,13 @@ "packages/aws-durable-execution-sdk-js-compute-worker", "packages/aws-durable-execution-sdk-js-examples", ) -# Older JS refs predate these packages; their examples do not need them. -# The worker package was renamed from microvm-worker to compute-worker. A JS -# ref has at most one of the two. So both are listed, and the build skips the -# one that the ref does not have. +# The build skips a workspace in this set when the JS checkout does not have +# it. Older JS refs predate extras, and their examples do not need it. A JS +# ref has at most one of the two worker names, because of the rename above. +# Until aws/aws-durable-execution-sdk-js#1204 merges, JS main still has +# microvm-worker. So removing microvm-worker now would break the default run +# against main. After the merge, it stays so that a run with an older js_ref +# still builds. OPTIONAL_JS_BUILD_WORKSPACES = frozenset( { "packages/aws-durable-execution-sdk-js-extras",