Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion .github/scripts/js_examples/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,25 +72,33 @@
# 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.
#
# The list also holds both names of the extensions package, extras and
# extensions, for the same reason. A ref from before the rename in
# aws/aws-durable-execution-sdk-js#1266 has only extras. A ref from after it
# has only extensions.
JS_BUILD_WORKSPACES = (
"packages/aws-durable-execution-sdk-js",
"packages/aws-durable-execution-sdk-js-testing",
"packages/aws-durable-execution-sdk-js-otel",
"packages/aws-durable-execution-sdk-js-extras",
"packages/aws-durable-execution-sdk-js-extensions",
"packages/aws-durable-execution-sdk-js-microvm-worker",
"packages/aws-durable-execution-sdk-js-compute-worker",
"packages/aws-durable-execution-sdk-js-examples",
)
# 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.
# ref has at most one of the two worker names, and at most one of the two
# extensions names, because of the renames 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",
"packages/aws-durable-execution-sdk-js-extensions",
"packages/aws-durable-execution-sdk-js-microvm-worker",
"packages/aws-durable-execution-sdk-js-compute-worker",
}
Expand Down
19 changes: 14 additions & 5 deletions .github/scripts/tests/test_js_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -755,20 +755,28 @@ def test_source_fingerprint_changes_with_local_edits(tmp_path: Path) -> None:
assert run.source_fingerprint(tmp_path) != untracked


@pytest.mark.parametrize("has_microvm_packages", [False, True])
@pytest.mark.parametrize(
"extensions_package",
[
None,
"packages/aws-durable-execution-sdk-js-extras",
"packages/aws-durable-execution-sdk-js-extensions",
],
)
def test_build_produces_example_workspace_dependencies(
tmp_path: Path,
monkeypatch: pytest.MonkeyPatch,
has_microvm_packages: bool,
extensions_package: str | None,
) -> None:
has_microvm_packages = extensions_package is not None
core = "packages/aws-durable-execution-sdk-js"
testing = "packages/aws-durable-execution-sdk-js-testing"
otel = "packages/aws-durable-execution-sdk-js-otel"
extras = "packages/aws-durable-execution-sdk-js-extras"
extras = extensions_package
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:
if extras is not None:
packages.extend([extras, worker])
for package in packages:
directory = tmp_path / package
Expand All @@ -785,7 +793,8 @@ def execute(args: list[str], **_kwargs: Any) -> subprocess.CompletedProcess[str]
if workspace == worker:
assert testing in built
if workspace == examples_package and has_microvm_packages:
# The generator imports extras/microvm and typechecks the worker.
# The generator imports extensions/microvm and typechecks the
# worker.
# A successful examples build requires both artifacts to exist.
assert extras in built
assert worker in built
Expand Down
4 changes: 2 additions & 2 deletions .github/scripts/type-checks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ mypy --install-types --non-interactive \
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 \
packages/aws-durable-execution-sdk-python-extras/tests
packages/aws-durable-execution-sdk-python-extensions/src/aws_durable_execution_sdk_python_extensions \
packages/aws-durable-execution-sdk-python-extensions/tests

# comment out this for now as there are many type check errors in this package
#mypy --install-types --non-interactive \
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/pypi-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ jobs:
path: packages/aws-durable-execution-sdk-python-testing
- name: aws-durable-execution-sdk-python-telemetry-exporter
path: packages/aws-durable-execution-sdk-python-telemetry-exporter
- name: aws-durable-execution-sdk-python-extras
path: packages/aws-durable-execution-sdk-python-extras
- name: aws-durable-execution-sdk-python-extensions
path: packages/aws-durable-execution-sdk-python-extensions
- name: aws-durable-execution-sdk-python-compute-worker
path: packages/aws-durable-execution-sdk-python-compute-worker

Expand Down Expand Up @@ -71,7 +71,7 @@ jobs:
- name: aws-durable-execution-sdk-python-otel
- name: aws-durable-execution-sdk-python-testing
- name: aws-durable-execution-sdk-python-telemetry-exporter
- name: aws-durable-execution-sdk-python-extras
- name: aws-durable-execution-sdk-python-extensions
- name: aws-durable-execution-sdk-python-compute-worker
permissions:
id-token: write
Expand Down
4 changes: 2 additions & 2 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ Do NOT add or modify **conformance tests** without coordinating with the team. C
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
extensions package with custom operations such as `microvm`
(`aws-durable-execution-sdk-python-extensions`), and examples
(`aws-durable-execution-sdk-python-examples`).
- Read [CONTRIBUTING.md](CONTRIBUTING.md) before making changes, and
follow its [rules for every change](CONTRIBUTING.md#rules-for-every-change).
Expand Down
12 changes: 6 additions & 6 deletions RELEASING.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ This monorepo contains the following packages:
| `aws-durable-execution-sdk-python-otel` | `packages/aws-durable-execution-sdk-python-otel` | `otel` |
| `aws-durable-execution-sdk-python-testing` | `packages/aws-durable-execution-sdk-python-testing` | `testing` |
| `aws-durable-execution-sdk-python-telemetry-exporter` | `packages/aws-durable-execution-sdk-python-telemetry-exporter` | `telemetry-exporter` |
| `aws-durable-execution-sdk-python-extras` | `packages/aws-durable-execution-sdk-python-extras` | `extras` |
| `aws-durable-execution-sdk-python-extensions` | `packages/aws-durable-execution-sdk-python-extensions` | `extensions` |
| `aws-durable-execution-sdk-python-compute-worker` | `packages/aws-durable-execution-sdk-python-compute-worker` | `compute-worker` |

## Versioning
Expand All @@ -23,7 +23,7 @@ Each package maintains its own version in its respective `__about__.py` file:
- OTel: `packages/aws-durable-execution-sdk-python-otel/src/aws_durable_execution_sdk_python_otel/__about__.py`
- Testing: `packages/aws-durable-execution-sdk-python-testing/src/aws_durable_execution_sdk_python_testing/__about__.py`
- Telemetry Exporter: `packages/aws-durable-execution-sdk-python-telemetry-exporter/src/aws_durable_execution_sdk_python_telemetry_exporter/__about__.py`
- Extras: `packages/aws-durable-execution-sdk-python-extras/src/aws_durable_execution_sdk_python_extras/__about__.py`
- Extensions: `packages/aws-durable-execution-sdk-python-extensions/src/aws_durable_execution_sdk_python_extensions/__about__.py`
- Compute Worker: `packages/aws-durable-execution-sdk-python-compute-worker/src/aws_durable_execution_sdk_python_compute_worker/__about__.py`

Set the release version in the appropriate `__about__.py` file(s) and merge to
Expand All @@ -38,7 +38,7 @@ The GitHub `pypi` environment permits deployments only from **tags** matching:
- `otel-v*`
- `testing-v*`
- `telemetry-exporter-v*`
- `extras-v*`
- `extensions-v*`
- `compute-worker-v*`

Branches, including `main` and temporary publishing branches, are not allowed.
Expand Down Expand Up @@ -190,7 +190,7 @@ The tag should be the version of the package being bumped, prepended with a desc
- **OTel only:** `otel-v<version>` (e.g., `otel-v0.3.0`)
- **Testing only:** `testing-v<version>` (e.g., `testing-v1.2.1`)
- **Telemetry Exporter only:** `telemetry-exporter-v<version>` (e.g., `telemetry-exporter-v1.0.0`)
- **Extras only:** `extras-v<version>` (e.g., `extras-v0.1.0`)
- **Extensions only:** `extensions-v<version>` (e.g., `extensions-v0.1.0`)
- **Compute Worker only:** `compute-worker-v<version>` (e.g., `compute-worker-v0.0.1`)
- **Multiple packages in a single release:** comma-separate the sub-tags (e.g., `sdk-v1.6.0,otel-v0.3.0`)

Expand All @@ -201,7 +201,7 @@ sdk-v1.6.0
otel-v0.3.0
testing-v1.2.1
telemetry-exporter-v1.0.0
extras-v0.1.0
extensions-v0.1.0
compute-worker-v0.0.1
sdk-v1.6.0,otel-v0.3.0
```
Expand Down Expand Up @@ -370,7 +370,7 @@ Before publishing a release:
ruleset
- [ ] Release notes written with separate sections per package
- [ ] Tag follows the naming convention (`sdk-vX.Y.Z`, `otel-vX.Y.Z`, `testing-vX.Y.Z`,
`telemetry-exporter-vX.Y.Z`, `extras-vX.Y.Z`, `compute-worker-vX.Y.Z`,
`telemetry-exporter-vX.Y.Z`, `extensions-vX.Y.Z`, `compute-worker-vX.Y.Z`,
or comma-separated)

After publishing a release:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ if __name__ == "__main__":
start_agentcore_worker(handler=review).wait()
```

The durable function sends the job with the `agentcore` operation of the [extras](https://github.com/aws/aws-durable-execution-sdk-python/tree/main/packages/aws-durable-execution-sdk-python-extras#run-a-job-in-agentcore-runtime) package:
The durable function sends the job with the `agentcore` operation of the [extensions](https://github.com/aws/aws-durable-execution-sdk-python/tree/main/packages/aws-durable-execution-sdk-python-extensions#run-a-job-in-agentcore-runtime) package:

```python
review = agentcore(context, "review", job_input={"pr": 7}, config=AGENT)
Expand Down Expand Up @@ -217,7 +217,7 @@ The agent runtime's execution role needs `lambda:SendDurableExecutionCallbackSuc
## Reference

- [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.
- [extensions](https://github.com/aws/aws-durable-execution-sdk-python/tree/main/packages/aws-durable-execution-sdk-python-extensions): 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-compute-worker/src/aws_durable_execution_sdk_python_compute_worker/microvm): lower-level building blocks such as `MicrovmWorkerListener` and `CallbackReporter`.

## License
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ A second delivery of a job is answered like the first and ignored, while the job

The worker creates a Lambda client for each job, after the job arrives, not at image build. A client created before the snapshot would carry build-time state into every MicroVM. A client kept across jobs would keep connections that a suspend of the MicroVM can leave dead. The worker closes each job's default client when the job ends. It never closes a client from `create_client`.

A document that does not match the contract gets HTTP 400 with the validation message. If the document named a callback, the worker also fails that callback, so the durable function fails at once instead of at its timeout. A request whose body cannot be read gets HTTP 400 with a generic message, and the error is logged. The worker accepts a `run` hook body of at most 64 KiB and a job request body of at most 6 MiB, with a `Content-Length` or with chunked transfer encoding. In a chunked body, the chunk-size lines, their extensions, and the trailers have a limit of their own, of the same size. A larger body gets HTTP 400. The worker sends it without reading the body, and then closes the connection. The unread bytes make the kernel send a TCP reset in place of a normal close. So a client that is still sending can get the reset before it reads the 400. A request with `Expect: 100-continue` first gets `100 Continue`, as `http.server` sends it. The client then sends the body, and gets the 400 or the reset in the same way. The MicroVM operations of both SDK extras packages, JS (`@aws/durable-execution-sdk-js-extras`) and Python (`aws-durable-execution-sdk-python-extras`), reject a job input that does not fit before they send the job. So only another sender can get the reset. Other lifecycle hooks get HTTP 200. Other paths get HTTP 404.
A document that does not match the contract gets HTTP 400 with the validation message. If the document named a callback, the worker also fails that callback, so the durable function fails at once instead of at its timeout. A request whose body cannot be read gets HTTP 400 with a generic message, and the error is logged. The worker accepts a `run` hook body of at most 64 KiB and a job request body of at most 6 MiB, with a `Content-Length` or with chunked transfer encoding. In a chunked body, the chunk-size lines, their extensions, and the trailers have a limit of their own, of the same size. A larger body gets HTTP 400. The worker sends it without reading the body, and then closes the connection. The unread bytes make the kernel send a TCP reset in place of a normal close. So a client that is still sending can get the reset before it reads the 400. A request with `Expect: 100-continue` first gets `100 Continue`, as `http.server` sends it. The client then sends the body, and gets the 400 or the reset in the same way. The MicroVM operations of the JS package (`@aws/durable-execution-sdk-js-extras`) and the Python package (`aws-durable-execution-sdk-python-extensions`) reject a job input that does not fit before they send the job. So only another sender can get the reset. Other lifecycle hooks get HTTP 200. Other paths get HTTP 404.

`worker.idle(timeout)` waits until every job started so far has ended, and a running `SuspendMicrovm` call has returned. It returns `False` when the timeout ends first. `worker.close()` stops the server and the idle time. Running jobs continue, so call `idle()` first to let them report their outcome.

Expand Down Expand Up @@ -96,7 +96,7 @@ The worker creates a `lambda-microvms` client for each suspend, and closes it af

The durable function suspends a session's MicroVM after a job. `vm.invoke` with `suspend_after=True` calls `SuspendMicrovm` itself, from the durable function, after the job's result arrives. The job request carries no field for it, and the worker does nothing for it.

So the MicroVM's execution role needs no `lambda:SuspendMicrovm` for this case. The durable function's role needs it. See the [extras README](../../aws-durable-execution-sdk-python-extras/docs/microvm.md#suspending-after-a-job).
So the MicroVM's execution role needs no `lambda:SuspendMicrovm` for this case. The durable function's role needs it. See the [extensions README](../../aws-durable-execution-sdk-python-extensions/docs/microvm.md#suspending-after-a-job).

Enable the `suspend` and `resume` hooks in the image. The worker answers the `suspend` hook, refuses jobs while the MicroVM freezes, and accepts them again on the `resume` hook. Without the `resume` hook, the worker refuses the next job with HTTP 503 until 30 seconds after the `suspend` hook. The next job's heartbeat timeout counts that time.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2207,9 +2207,9 @@ def _too_large(
4. A client that is still sending can get the reset before it reads
the 400.

The MicroVM operations of both SDK extras packages, JS
(``@aws/durable-execution-sdk-js-extras``) and Python
(``aws-durable-execution-sdk-python-extras``), reject a job input that
The MicroVM operations of the JS package
(``@aws/durable-execution-sdk-js-extras``) and the Python package
(``aws-durable-execution-sdk-python-extensions``) reject a job input that
does not fit before they send the job. So only another sender can get
the reset.
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ def build_examples() -> None:

runtime_packages = [
packages_dir / "aws-durable-execution-sdk-python",
# The MicroVM and AgentCore examples import the extras. The examples
# package does not depend on the extras, so pip installs the extras
# The MicroVM and AgentCore examples import the extensions. The examples
# package does not depend on the extensions, so pip installs the extensions
# only from here.
packages_dir / "aws-durable-execution-sdk-python-extras",
packages_dir / "aws-durable-execution-sdk-python-extensions",
packages_dir / "aws-durable-execution-sdk-python-otel",
packages_dir / "aws-durable-execution-sdk-python-testing",
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from aws_durable_execution_sdk_python.config import Duration
from aws_durable_execution_sdk_python.context import DurableContext
from aws_durable_execution_sdk_python.execution import durable_execution
from aws_durable_execution_sdk_python_extras.compute.agentcore import (
from aws_durable_execution_sdk_python_extensions.compute.agentcore import (
AgentcoreConfig,
agentcore,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from aws_durable_execution_sdk_python.config import Duration
from aws_durable_execution_sdk_python.context import DurableContext
from aws_durable_execution_sdk_python.execution import durable_execution
from aws_durable_execution_sdk_python_extras.compute.microvm import (
from aws_durable_execution_sdk_python_extensions.compute.microvm import (
MicrovmConfig,
microvm,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from aws_durable_execution_sdk_python.config import Duration
from aws_durable_execution_sdk_python.context import DurableContext
from aws_durable_execution_sdk_python.execution import durable_execution
from aws_durable_execution_sdk_python_extras.compute.microvm import (
from aws_durable_execution_sdk_python_extensions.compute.microvm import (
MicrovmInvokeOptions,
MicrovmSession,
MicrovmSessionConfig,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from aws_durable_execution_sdk_python.config import CallbackConfig, Duration
from aws_durable_execution_sdk_python.context import DurableContext
from aws_durable_execution_sdk_python.execution import durable_execution
from aws_durable_execution_sdk_python_extras.compute.microvm import (
from aws_durable_execution_sdk_python_extensions.compute.microvm import (
MicrovmInvokeOptions,
MicrovmSession,
MicrovmSessionConfig,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
from aws_durable_execution_sdk_python.config import CallbackConfig, Duration
from aws_durable_execution_sdk_python.context import DurableContext
from aws_durable_execution_sdk_python.execution import durable_execution
from aws_durable_execution_sdk_python_extras.compute.microvm import (
from aws_durable_execution_sdk_python_extensions.compute.microvm import (
MicrovmInvokeOptions,
MicrovmSession,
MicrovmSessionConfig,
Expand Down
Loading
Loading