feat: import shipped local modules before executing user code#100
Open
deanq wants to merge 1 commit into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.