<@ULVA73B9P> hi, does pip_install_requirements eve...
# marvin-ai
м
@Marvin hi, does pip_install_requirements even work? I've checked the code, it installs requirements AFTER the process that will run the flow function was started, so it will not see any new dependencies, right?
n
hi i will fix marvin but yes it should because run_steps executes before the flow entrypoint is imported if you're seeing something unexpected, please share a repro and
prefect version
output
@Marvin please concisely explain, link relevant code
does pip_install_requirements even work? I've checked the code, it installs requirements AFTER the process that will run the flow function was started, so it will not see any new dependencies, right?
m
thought for 108.8 seconds
Concise answer: yes, a process has already started — but not the one that runs your flow function.
pip_install_requirements
runs in the workspace resolver subprocess, which prepares the run environment before Prefect starts the engine process that imports and executes the flow. So the flow process does see those installed dependencies. Relevant code: - Workspace starter spawns the resolver process first: https://github.com/PrefectHQ/prefect/blob/main/src/prefect/runner/_workspace_starter.py#L348-L365 - The resolver prepares the workspace and runs pull steps: https://github.com/PrefectHQ/prefect/blob/main/src/prefect/runner/_workspace_resolver.py#L290-L393 -
deployment.pull_steps
are executed here: https://github.com/PrefectHQ/prefect/blob/main/src/prefect/runner/_workspace_resolver.py#L362-L368 -
pip_install_requirements
itself does `python -m pip install -r ...`: https://github.com/PrefectHQ/prefect/blob/main/src/prefect/deployments/steps/utility.py#L278-L338 - Only after that does Prefect start the engine process that runs the flow: https://github.com/PrefectHQ/prefect/blob/main/src/prefect/runner/_starter_engine.py#L27-L150 So the accurate explanation is:
pip_install_requirements
runs after Prefect has started a prep/resolver subprocess, but before it starts the engine/flow subprocess. So newly installed dependencies are available to the flow run process.