Add PIPELINES_ENV
Enhance the start.sh script to recognize and utilize the PIPELINES_ENV environment variable as follows:
-
Development Mode:
- If
PIPELINES_ENV=development, executeuvicornwith the--reloadoption. This will streamline the development process of Python pipelines by automatically reloading the server upon code changes.
- If
-
Production Mode:
- If
PIPELINES_ENV=productionor ifPIPELINES_ENVis unset or undefined, runuvicornin its standard mode without the--reloadoption.
- If
This change will accommodate both development and production environments seamlessly.
is it possible to add env for uvicorn options? It could be useful to increase the number of workers like this fastapi with workers
@sir3mat - yes... it should be possible... env like PIPELINES_WORKERS
based on docs - https://github.com/defunkt/unicorn/blob/master/README "unicorn can spawn and manage any number of worker processes you choose to scale to your backend." https://www.engineyard.com/blog/everything-you-need-to-know-about-unicorn/
it could be somthing like this...
if [ "$PIPELINES_ENV" = "production" ] || [ -z "$PIPELINES_ENV" ]; then
if [ "$PIPELINES_WORKERS" = "auto" ]; then
CPU_COUNT=$(nproc)
WORKERS=$((2 * CPU_COUNT + 1))
else
WORKERS="${PIPELINES_WORKERS:-1}"
fi
uvicorn main:app --host "$HOST" --port "$PORT" --workers "$WORKERS" --forwarded-allow-ips '*'
else
echo "INFO: Running in development mode"
# "workers" flag will be ignored when reloading is enabled.
uvicorn main:app --host "$HOST" --port "$PORT" --forwarded-allow-ips '*' --reload
fi
i will try to check that later... but now i need also support venv for requirments and that is on my top task list
New Environment Variables for start.sh
-
PIPELINES_ENV(string)-
Description: Specifies the environment mode in which the application should run. It typically toggles between configurations optimized for development or production. If set to any value other than
"production",uvicornwill be configured to run with1worker and the--reloadflag. Information about this flag can be found in theuvicorndevelopment documentation. -
Default Value:
production - Default Usage: Often not set, it defaults to production mode if not explicitly defined.
-
Description: Specifies the environment mode in which the application should run. It typically toggles between configurations optimized for development or production. If set to any value other than
-
PIPELINES_WORKERS(number|auto)- Description: Determines the number of worker processes to handle tasks. It helps in managing parallel processes to optimize resource usage.
-
Default Value:
uvicornstarts by default only with1worker. -
Default Usage: In some setups, this might switch to
auto, which calculates the ideal number of workers based on available CPU cores.
-
PIPELINES_VENV(boolean)- Description: Controls whether a virtual environment should be used for executing pipelines.
-
Default Value:
False -
Example Usage: Setting this to
Truewill ensure that the pipelines run within a specified virtual environment.
-
PIPELINES_VENV_AUTOUPGRADE(boolean)-
Description: Indicates if automatic upgrades should occur for pip and package dependencies defined in
requirements.txtwhen using a virtual environment. This parameter makes sense only if you are using a permanentvolumefor the venv folder. -
Default Value:
False -
Example Usage: Set to
Trueto enable the automatic pip and package upgrade process during start.
-
Description: Indicates if automatic upgrades should occur for pip and package dependencies defined in
-
PIPELINES_VENV_PATH(os path string)- Description: Defines the path where the virtual environment is stored or should be created.
-
Default Value: Typically set to
${PIPELINES_DIR}/venv, aligning with the directory structure of the pipelines. - Example Usage: Customizing this path allows for alternate locations of the virtual environment if needed.
Is it possible to enable also the "workers" params in openwebui interface?
@sir3mat Pipelines is a separate, dedicated container and project. The number of pipeline workers is a parameter set at the start of the pipelines container and needs to be predefined at startup. Settings such as env parameters SHOULD NOT be influenced or driven by other projects from the outside; instead, they should be defined by the administrator during the startup process, as these env parameters impact how the entire system behaves.
This is exactly the functionality I was looking for in Pipelines. It seems good practise to ensure that the pipeline dependencies are installed in a separate venv. Glad to see there is a PR, what is the status on this?