feat: SLS-360 import shipped local modules before executing user code#100
feat: SLS-360 import shipped local modules before executing user code#100deanq wants to merge 3 commits into
Conversation
There was a problem hiding this comment.
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 inmaterialized_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.
dcc01cb to
3941454
Compare
- 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.
|
CI was red because the published Fixed in f3ce8e7 by temporarily pinning Before merge: revert the pin to a released constraint (e.g. |
Summary
Worker-side half of local (non-pip) module support for Flash serverless endpoints. Makes modules shipped inline in
FunctionRequest.modulesimportable 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.modulesfield introduced there.What changed
src/function_executor.py: wrap the function-execution region ofFunctionExecutor.executeinmaterialized_modules(request.modules or {})(fromrunpod_flash.runtime.module_loader), so shipped modules are written to a temp dir onsys.pathand remain importable through the function call — not just theexecthat 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
tests/unit/test_function_executor.py): a request whosefunction_codedoesimport utils; return utils.x()withmodules={"utils.py": ...}executes successfully and returns the expected value (without the change,import utilsraisesModuleNotFoundErrorand the response is a failure); a request with nomodulesstill works unchanged.make quality-checkgreen (unit + handler JSON tests, 35%+ coverage).Backward compatibility
Additive and safe: an absent or empty
modulesmap is a no-op — behavior is identical to today for all existing requests.