Skip to content

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

Open
deanq wants to merge 1 commit into
mainfrom
deanquinanola/sls-360-local-module-bundling
Open

feat: import shipped local modules before executing user code#100
deanq wants to merge 1 commit 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.

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.

1 participant