Skip to content

Allow finalize hooks to be installed on awslambdaric 4.x - #43

Merged
xaviergmail merged 4 commits into
developfrom
chore/support-lambdaric-4x
Sep 3, 2026
Merged

xaviergmail merged 4 commits into
developfrom
chore/support-lambdaric-4x

Conversation

@xaviergmail

Copy link
Copy Markdown
Contributor

Summary

  • Adds support for awslambdaric 4.x in xoto3.lam.finalize, mirroring Allow xoto3.lam.finalize to run on awslambdaric 3.x #37 (which did the same for 3.x).
  • 4.x ships Lambda Managed Instances (LMI) / multi-concurrent support (aws/aws-lambda-python-runtime-interface-client#200). That refactor relocated post_invocation_result/post_invocation_error off LambdaRuntimeClient onto a new shared BaseLambdaRuntimeClient.
  • Two concrete clients now inherit that base: LambdaRuntimeClient (standard mode) and LambdaMultiConcurrentRuntimeClient (multi-concurrent mode). Patching the base class for 4.x makes the finalize hooks fire in both runtime paths — patching only LambdaRuntimeClient would silently skip multi-concurrent workers.
  • The runtime interface finalize relies on is otherwise unchanged; 4.x adds an invocation_id positional to the post-invocation methods, which the existing *args, **kwargs wrapper already absorbs.
  • 2.x/3.x behavior is untouched; unsupported majors still log the existing "Unimplemented" error.

Changes

xoto3/lam/finalize.py

  • Generalize __install_post_invocation_hooks to take the target client class instead of the bootstrap module.
  • Version branch: 2.x/3.x → patch bootstrap.LambdaRuntimeClient; 4.x → patch lambda_runtime_client.BaseLambdaRuntimeClient; else log unimplemented.

tests/xoto3/lam/finalize_test.py (new; finalize previously had no coverage)

  • Each version runs in a fresh interpreter against a synthetic awslambdaric package (sidesteps import-time hook-install state).
  • Asserts hooks fire for 2.x, 3.x, 4.x standard and multi-concurrent clients, and that an unsupported major logs an error without patching.

pyproject.toml / CHANGES.md

  • Version 2.1.0 → 2.2.0 + changelog entry. (Dev-dep bound awslambdaric = ">=2.0.0" already permits 4.x — unchanged.)

Testing

  • poetry run pytest tests → 125 passed (new finalize tests included).
  • poetry run mypy xoto3 → clean (also clean on the new test file).
  • black / isort applied per the pinned pre-commit revs.

awslambdaric 4.x (Lambda Managed Instances / multi-concurrent support)
relocated post_invocation_result/post_invocation_error off
LambdaRuntimeClient onto a shared BaseLambdaRuntimeClient, subclassed by
both the standard LambdaRuntimeClient and the new
LambdaMultiConcurrentRuntimeClient. Patch that base class for 4.x so the
finalize hooks fire in both standard and multi-concurrent runtime paths.

Add version-branch tests covering 2.x/3.x, 4.x (standard + multi-concurrent)
and the unsupported-version error path.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@gitstream-cm

gitstream-cm Bot commented Aug 4, 2026

Copy link
Copy Markdown

This PR is missing a Jira ticket reference in the title or description.
Please add a Jira ticket reference to the title or description of this PR.

@gitstream-cm gitstream-cm Bot added the S label Aug 4, 2026
@gitstream-cm

gitstream-cm Bot commented Aug 4, 2026 •

Copy link
Copy Markdown

🥷 Code experts: jpogozelski-xoi

jpogozelski-xoi has most 👩‍💻 activity in the files.
jpogozelski-xoi has most 🧠 knowledge in the files.

See details

.github/workflows/unit-test.yml

Activity based on git-commit:

jpogozelski-xoi
AUG
JUL
JUN
MAY
APR
MAR 67 additions & 0 deletions

Knowledge based on git-blame:
jpogozelski-xoi: 100%

CHANGES.md

Activity based on git-commit:

jpogozelski-xoi
AUG
JUL
JUN
MAY
APR
MAR 264 additions & 0 deletions

Knowledge based on git-blame:
jpogozelski-xoi: 100%

pyproject.toml

Activity based on git-commit:

jpogozelski-xoi
AUG
JUL
JUN
MAY
APR
MAR 32 additions & 0 deletions

Knowledge based on git-blame:
jpogozelski-xoi: 100%

xoto3/lam/finalize.py

Activity based on git-commit:

jpogozelski-xoi
AUG
JUL
JUN
MAY
APR
MAR 88 additions & 0 deletions

Knowledge based on git-blame:
jpogozelski-xoi: 100%

✨ Comment /gs review for LinearB AI review. Learn how to automate it here.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Extends xoto3.lam.finalize to support awslambdaric 4.x by installing post-invocation finalize hooks on the new shared runtime client base class, ensuring hooks run in both standard and multi-concurrent (LMI) execution paths.

Changes:

  • Update finalize hook installation to patch a target runtime client class (2.x/3.x: bootstrap.LambdaRuntimeClient; 4.x: lambda_runtime_client.BaseLambdaRuntimeClient).
  • Add isolated subprocess-based tests that validate hook behavior across awslambdaric 2.x, 3.x, 4.x (standard + multi-concurrent), and unsupported majors.
  • Bump project version to 2.2.0 and document the awslambdaric 4.x support in CHANGES.md.

Reviewed changes

Copilot reviewed 4 out of 5 changed files in this pull request and generated no comments.

File Description
xoto3/lam/finalize.py Add awslambdaric 4.x-aware hook installation by patching BaseLambdaRuntimeClient.
tests/xoto3/lam/finalize_test.py New coverage validating finalize hooks across awslambdaric majors using synthetic packages in fresh interpreters.
pyproject.toml Version bump to 2.2.0.
CHANGES.md Changelog entry for 2.2.0 noting awslambdaric 4.x finalize support.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Add a second matrix axis to the unit-test job covering awslambdaric 2.x,
3.x and 4.x. Wheel availability is ragged (2.x stops at cp312, 3.x at
cp314, 4.x at cp315), so the axis is an explicit include list of only
installable (python, awslambdaric) pairs rather than a full cross-product.
The 3.15 x 4.x cell is marked experimental (allow-prereleases +
continue-on-error) for future-proofing. The mypy job is unchanged since it
does not depend on the awslambdaric version.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@gitstream-cm gitstream-cm Bot added M and removed S labels Aug 4, 2026
Add a weekly (and manually dispatchable) workflow that installs the latest
awslambdaric unconstrained and asserts xoto3.lam.finalize still installs its
post-invocation hook onto the real runtime client. A future major that
finalize does not yet handle leaves the hook uninstalled, so the canary fails
and flags that a new supported code path is needed -- the check that would
have caught 4.0 automatically.

scripts/canary_check.py exercises the real awslambdaric wheel, complementing
the hermetic synthetic-package unit tests.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@danielxoi
danielxoi self-requested a review August 4, 2026 23:16
@xaviergmail
xaviergmail merged commit 25acd23 into develop Sep 3, 2026
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

3 participants