How to force agents to enter a pre-made virtual enviroment before executing a task?

Hello,

Obligatory, this is related: Run Flow in venv - #5 by anna_geller
I am not sure it answers my question though, or if I am just failing to understand.

In short, I have created 1 flow named “reporting-pipeline”. I also have a virtual environment stored in the same directory as the flow, called “reporting_env”. reporting_env was made with the following command:
python -m venv reporting_env
Then I installed all necessary packages for the “reporting-pipeline” flow in that virtual environment.

I want any agent that runs “reporting-pipeline” to enter “reporting_env” before doing so.
Similarly, I want to be able to define other venv->flow relationships with future flows. In essence, each flow will have a respective venv, and the agent just goes into the respective environment before executing the flow.

In other posts concerning this topic, I see code like this:

  command:
  - '"C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python39_64\pyvenv\prefectenv\Scripts\python.exe"'
  - -m 
  - prefect.engine

I’m not really sure what that’s doing though. The only way I know of to enter a virtual environment is to run the activate script at ./bin/scripts/activate. I’m not sure if I need to reference the prefect.engine or why.

Can someone help me clear this up? Thanks

Edit: I’m not sure if it’s work mentioning, but I am running in Docker on Windows. This is only for development though, and I’ll be moving it over to a Docker instance on CentOS for production.