Skip to content

feat: SLS-360 import shipped local modules before executing user code#100

Open
deanq wants to merge 3 commits into
mainfrom
deanquinanola/sls-360-local-module-bundling
Open

feat: SLS-360 import shipped local modules before executing user code#100
deanq wants to merge 3 commits into
mainfrom
deanquinanola/sls-360-local-module-bundling

Conversation

@deanq

@deanq deanq commented Jul 6, 2026

Copy link
Copy Markdown
Collaborator

Summary

Worker-side half of local (non-pip) module support for Flash serverless endpoints. Makes modules shipped inline in FunctionRequest.modules importable while the user function executes.

Resolves SLS-360. Companion to runpod/flash#352 (SDK side) — these must be released together; this PR consumes the additive FunctionRequest.modules field introduced there.

What changed

  • src/function_executor.py: wrap the function-execution region of FunctionExecutor.execute in materialized_modules(request.modules or {}) (from runpod_flash.runtime.module_loader), so shipped modules are written to a temp dir on sys.path and remain importable through the function call — not just the exec that defines it. Endpoint code typically imports local modules inside the function body (call time), so the materialized path must stay live until the function has run.

Test plan

  • Unit (tests/unit/test_function_executor.py): a request whose function_code does import utils; return utils.x() with modules={"utils.py": ...} executes successfully and returns the expected value (without the change, import utils raises ModuleNotFoundError and the response is a failure); a request with no modules still works unchanged.
  • make quality-check green (unit + handler JSON tests, 35%+ coverage).

Backward compatibility

Additive and safe: an absent or empty modules map is a no-op — behavior is identical to today for all existing requests.

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

Enables Flash worker-side support for importing “shipped” local (non-pip) Python modules provided inline on FunctionRequest.modules by keeping the materialized module directory on sys.path for the full duration of user function execution (definition + call).

Changes:

  • Wrap FunctionExecutor.execute()’s exec + call region in materialized_modules(request.modules or {}) so shipped modules remain importable during the function call.
  • Add unit coverage for importing a shipped module during execution, plus a no-modules regression test.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
src/function_executor.py Keeps shipped module temp dir on sys.path across exec and the subsequent function call via materialized_modules(...).
tests/unit/test_function_executor.py Adds unit tests validating shipped-module import behavior and unchanged behavior when no modules are provided.

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

Comment thread src/function_executor.py Outdated
Comment thread tests/unit/test_function_executor.py Outdated
@deanq deanq changed the title feat: import shipped local modules before executing user code feat: SLS-360 import shipped local modules before executing user code Jul 10, 2026
@deanq deanq force-pushed the deanquinanola/sls-360-local-module-bundling branch from dcc01cb to 3941454 Compare July 10, 2026 22:33
deanq added 2 commits July 10, 2026 23:13
- Use getattr(request, "modules", {}) for older-request compatibility
- Rename test's shipped module to a unique name to avoid collision with
  installed/cached modules
Worker uses runpod_flash.runtime.module_loader, which is not in a published
runpod-flash yet. Temporary git pin so CI installs a flash with the module.
Revert to a released constraint once runpod/flash#352 ships.
@deanq

deanq commented Jul 11, 2026

Copy link
Copy Markdown
Collaborator Author

CI was red because the published runpod-flash (1.17.0) does not yet contain runpod_flash.runtime.module_loader, which this PR imports — every test / docker-test* job failed with ModuleNotFoundError: No module named 'runpod_flash.runtime.module_loader'. This is the coordinated-release ordering, not a defect in the change.

Fixed in f3ce8e7 by temporarily pinning runpod-flash to the flash SLS-360 branch (git+https://github.com/runpod/flash.git@deanquinanola/sls-360-local-module-bundling, commit 0c8c90ce) so CI installs a flash that has the module. All previously-failing jobs now pass.

Before merge: revert the pin to a released constraint (e.g. runpod-flash>=1.18.0) once runpod/flash#352 is merged and published, then re-lock. The bump-deps workflow is the normal mechanism for that bump.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants