Jefferson Lab Alarm Warning System API
Project description
jaws-libp
Reusable Python classes for JAWS plus admin scripts to setup and manage a deployment.
Quick Start with Compose
- Grab project
git clone https://github.com/JeffersonLab/jaws-libp
cd jaws-libp
- Launch Compose
docker compose up
- Monitor active alarms
docker exec -it jaws list_activations --monitor
- Trip an alarm
docker exec jaws set_activation alarm1
Note: The docker-compose services require significant system resources - tested with 4 CPUs and 4GB memory.
Install
Requires Python 3.9+
pip install jaws-libp
Note: Using newer versions of Python may be problematic because the dependency confluent-kafka
uses librdkafka, which often does not have a wheel file prepared for later versions of Python, meaning setuptools will attempt to compile it for you, and that often doesn't work (especially on Windows). Python 3.9 does have a wheel file for confluent-kafka so that's your safest bet. Wheel files also generally only are prepared for Windows, MacOS, and Linux. Plus only for architectures x86_64 and arm64, also only for glibc. If you use with musl libc or linux-aarch64 then you'll likely have to compile librdkafka yourself from source.
API
Configure
Environment variables are used to configure jaws-libp:
Name | Description |
---|---|
BOOTSTRAP_SERVER | Host and port pair pointing to a Kafka server to bootstrap the client connection to a Kafka Cluster; example: kafka:9092 |
SCHEMA_REGISTRY | URL to Confluent Schema Registry; example: http://registry:8081 |
The Docker container can optionally handle the following environment variables as well:
Name | Description |
---|---|
ALARM_LOCATIONS | Path to an alarm locations file to import (example file), else an https URL to a file, else a comma separated list of location definitions with fields separated by the pipe symbol. Example Inline CSV: name|parent |
ALARM_CATEGORIES | Path to an alarm categories file to import (example file), else an https URL to a file, else a comma separated list of catgory definitions with fields. Example Inline CSV: name |
ALARM_CLASSES | Path to an alarm classes file to import (example file), else an https URL to a file, else a comma separated list of class definitions with fields separated by the pipe symbol. Example Inline CSV: name|category|priority|rationale|correctiveaction|pointofcontactusername|latching|filterable|ondelayseconds|offdelayseconds |
ALARM_INSTANCES | Path to an alarm instances file to import (example file), else an https URL to a file, else a comma separated list of instance definitions with fields separated by the pipe symbol. Leave epicspv field empty for SimpleProducer. Example Inline CSV: name|class|epicspv|location|maskedby|screencommand |
ALARM_INSTANCES_URL_CSV | If provided, is a comma separated list of file names to append to ALARM_INSTANCES; ignored if ALARM_INSTANCES doesn't start with https ; Example. |
ALARM_OVERRIDES | Path to an alarm overrides file to import (example file), else an https URL to a file. |
Build
This Python 3.9+ project is built with setuptools and may be run using the Python virtual environment feature to isolate dependencies. The pip tool can be used to download dependencies.
git clone https://github.com/JeffersonLab/jaws-libp
cd jaws-libp
python -m venv .venv_dev --upgrade-deps
Activate the virtual env using your shell specific command, then install in editable mode with dev deps and run build:
# Windows
.venv_dev\Scripts\activate.bat
# Linux (SH Shell)
source .venv_dev/bin/activate
#MacOS (CSH Shell)
source .venv_dev/bin/activate.csh
pip install -e .[dev]
python -m build
pylint src/jaws_libp
Note for JLab On-Site Users: Jefferson Lab has an intercepting proxy
Develop
Set up the build environment following the Build instructions.
In order to iterate rapidly when making changes it's often useful to run the Python scripts directly on the local workstation, perhaps leveraging an IDE. In this scenario run the service dependencies with Docker Compose:
docker compose -f deps.yml up
Note: The environment variable defaults work in this scenario and are defined as:
BOOTSTRAP_SERVERS=localhost:9094
and SCHEMA_REGISTRY=http://localhost:8081
Test
The integration tests depend on a running Kafka instance, generally in Docker. The tests run automatically via the CI GitHub Action on every commit (unless [no ci]
is included in the commit message). The tests can be run locally during development. Set up the development environment following the Develop instructions. Then with the deps.yml
Docker containers running and the build virtual environment activated run:
pytest
Release
- Bump the version number in pyproject.toml and commit and push to GitHub (using Semantic Versioning).
- Create a new release on the GitHub Releases page corresponding to same version in pyproject.toml (Enumerate changes and link issues).
- Publish to PyPi GitHub Action should run automatically.
- Publish to gh-pages GitHub Action should run automatically.
- Publish to DockerHub GitHub Action should run automatically.
- Bump and commit quick start image version after confirming new image works
See Also
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for jaws_libp-4.8.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 43b53850046fed8f2ef587cda596649df25fe23d485a48a30a408bb6229e46f7 |
|
MD5 | d6f1081e3796f75a7f46f6fda2a6ca3d |
|
BLAKE2b-256 | 5dfbdb1ca5512243c3b4447585720f35551a2332e8ac7f7b0958fc5dd65328d8 |