feat(framework): Add runtime dependency installation option#6741
feat(framework): Add runtime dependency installation option#6741
Conversation
…t, and ability to limit to a local pypi repo with --index-url argument. Creates an ephemeral virtual environment for each run, and cleans it up after execution Signed-off-by: Patrick Foley <patrick@flower.ai>
Signed-off-by: Patrick Foley <patrick@flower.ai>
Signed-off-by: Patrick Foley <patrick@flower.ai>
There was a problem hiding this comment.
Pull request overview
Adds an opt-in mechanism for installing application dependencies at runtime (via uv sync) and threads the corresponding CLI/config options through SuperNode/SuperExec and the various flwr-* app processes.
Changes:
- Introduces
--allow-runtime-dependency-installationand propagates it through SuperLink/SuperNode/SuperExec process launching. - Adds a new
dependency_installerutility to create/activate a per-run/per-launch runtime environment and install dependencies viauv. - Updates ClientApp/ServerApp/Simulation processes to optionally install dependencies and clean up the runtime environment on exit.
Reviewed changes
Copilot reviewed 15 out of 15 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| framework/py/flwr/supernode/start_client_internal.py | Forwards runtime dependency install flags to the flower-superexec subprocess. |
| framework/py/flwr/supernode/runtime/run_clientapp.py | Optionally installs app dependencies before loading/running the ClientApp and cleans up on exit. |
| framework/py/flwr/supernode/cli/flwr_clientapp.py | Passes new runtime dependency install parameters into run_clientapp/superexec wrapper. |
| framework/py/flwr/supernode/cli/flower_supernode.py | Adds parsing/forwarding of runtime dependency installation CLI args for SuperNode. |
| framework/py/flwr/supercore/superexec/run_superexec.py | Plumbs index_url/runtime_dependency_install into plugin construction and deprecation log output. |
| framework/py/flwr/supercore/superexec/plugin/exec_plugin.py | Extends ExecPlugin to store index_url and runtime install toggle. |
| framework/py/flwr/supercore/superexec/plugin/base_exec_plugin.py | Adds forwarding of runtime install flags when launching app subprocesses. |
| framework/py/flwr/supercore/superexec/dependency_installer.py | New module implementing uv installation, dependency sync, env activation, and cleanup. |
| framework/py/flwr/supercore/cli/flower_superexec.py | Adds runtime dependency installation CLI args to flower-superexec. |
| framework/py/flwr/simulation/app.py | Optionally installs simulation app dependencies and cleans up runtime env on exit. |
| framework/py/flwr/server/serverapp/app.py | Optionally installs server app dependencies and cleans up runtime env on exit. |
| framework/py/flwr/server/app.py | Forwards runtime dependency install flags when spawning flower-superexec in subprocess isolation mode. |
| framework/py/flwr/common/constant.py | Adds RUNTIME_DEPENDENCY_INSTALL default toggle constant. |
| framework/py/flwr/common/args.py | Introduces shared CLI arg helper add_args_runtime_dependency_install and includes it in common app args. |
| framework/py/flwr/cli/log.py | Changes log streaming loop behavior (notably error handling wrapper removal). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
Signed-off-by: Patrick Foley <patrick@flower.ai>
Signed-off-by: Patrick Foley <patrick@flower.ai>
Signed-off-by: Patrick Foley <patrick@flower.ai>
| INFO, | ||
| "`uv` is not available in the current environment, installing it now.", | ||
| ) | ||
| pip_install_uv_cmd: list[str] = [ |
There was a problem hiding this comment.
Note: uv is installed in the case that it is not available already in the user's virtual environment. This is done here because uv is not needed in unless --allow-runtime-dependency-installation is set to true. There may be other context that necessitates making this global dependency now, but my preference would be to keep it here because users will already be operating under the expectation that additional packages will be installed if they've enabled this flag
Signed-off-by: Patrick Foley <patrick@flower.ai>
No description provided.