A set of microservices implementating the CAEN management architecture
The scheme of microservices interaction looks like (the arrows display requests directions):
Provides a web interface to the user and defines REST API. Contains web frontend and web backend.
/
: frontend webpage for CAEN management/docs
(/redoc
): contains a complete list of available API endpointsExecutes commands from other microservices on the CAEN device itself
caen_setup
python package for the CAEN device interactionStores device parameters in the database and sends to Online DataBase (ODB)
A service cyclically running scenarios of interaction with other microservices (so called scripts) that inspect the device parameters, send the availability status to MChS, transfer parameters from DeviceBackend to MonitorService, maintain the target voltage and interlock following (if needed)
As shown in the figure above, the current version of the system is running on a single machine (dq11), but all the services are located in their own docker containers and connected using docker compose.
The complete environment setup instructions can be found in the separate environment
repository.
There are several advices to quickly start the development process of this project.
1) Prerequests:
python>=3.11.2
npm
(optional, to build frontend webpage)2) Clone the repository with submodules (it will be frontend in this case)
git clone --recursive https://github.com/caenHV/caen_tools.git
3) Prepare and run virtual environment
cd caen_tools
python -m venv ./venv
source venv/bin/activate
4) Install development version of the caen_tools
pip install -e .[webservice]
create an empty directory to prevent crash of the webservice (until you build frontend)
mkdir -p caen_tools/WebService/frontend/build/static
5) Now it's possible to run microservices that you need by the following commands:
caen_webserver
- runs webservice (now without main frontend webpage but already with http://localhost:8000/docs
containing all available endpoints)caen_device_backend
- runs DeviceBackend microsericecaen_monitor
- runs MonitorServicecaen_system_check
- runs SystemCheck4) Optional: build frontend
cd caen_tools/caen_tools/WebService/frontend/
npm install package.json
export REACT_APP_CAEN=production && npm run build
if all is ok, you'll see the build folder in current directory and when you start the web server, you will see the main frontend page http://localhost:8000
if you want to build your own whl
locally, you can do that.
pyproject.toml
python3 -m pip install --upgrade build
python3 -m build
If you work with github repository, it supports automatic build on push of the tag.
Suppose, that you already pushed all your commits into the remote github repository and want to get build whl
file, so:
git fetch origin --tags # fetch tags from remote origin repo
git tag v2.2.7-experimental # create your own tag of the current commit
git push origin --tags
caen_tools.zip
whl
to quickly try this module you need download .whl
file from latest release and then
python -m venv ./venv # create virtual environment
source venv/bin/activate # activate it
pip install "<filename>.whl[webservice]" # install this package
Run all of the microservices
caen_device_backend &
caen_monitor &
caen_system_check &
caen_webservice &
Go to http://localhost:8000
To simply close all of these microservices, run the following command in the other console window (this command will kill all processes whose name starting with caen_)
pkill -f caen_