Skip to content

[Webservice] add environment bin/ to PATH if not already there

Thomas Kluyver requested to merge webservice-venv-path into master

Description

The webservice launches calibration with a python -m command, from its config file. It expects that this will run in the same Python environment that it is running from itself. So the environment bin directory should be on $PATH.

At present, we ensure this by activating the virtualenv before launching the webservice, via code in the deployment tools. However, this is not really the concern of the deployment tools - it's up to the application itself how it starts subprocesses. And doing this creates an extra layer of bash processes between supervisor and the real Python processes we're interested in.

The aim of this is to take responsibility for PATH in the webservice, so we can simplify the service management.

How Has This Been Tested?

Deployed on max-exfl-cal002, and launched manually:

cd ~/pycalibration/current/
.venv/bin/python -m webservice.webservice --mode prod

The first line of the logs shows:

2024-01-09 15:53:55,062 - root - INFO - [webservice.py:1530] Adding /home/xcaltst/deployments/development/git.xfel.eu/detectors/pycalibration/pycalibration-2024-01-09-webservice-venv-path-ddcb2ca/.venv/bin to PATH

Triggered a calibration; its calibration_metadata.yaml shows:

python-environment:
  path: /home/xcaltst/deployments/development/git.xfel.eu/detectors/pycalibration/pycalibration-2024-01-09-webservice-venv-path-ddcb2ca/.venv/bin/python

Types of changes

  • New feature (non-breaking change which adds functionality)

Checklist:

  • My code follows the code style of this project.

Reviewers

@roscar @ahmedk

Merge request reports