Run BlueAPI and connect to services locally#
For development purposes, it can be useful to run BlueAPI and adjacent services (Numtracker, Tiled, OPA etc.) locally, i.e. not in a devcontainer. Following the steps in this page will allow you to launch an instance of NumTracker, RabbitMQ, Keycloak, Tiled, OPA and a number of IOCs, in detached mode. This can be useful for learning about the stack, running system tests checking if changes during development propagate as expected etc.
Before starting, ensure you have followed the Installation instructions.
Before starting, run:
module load uv just docker-compose/5.4.0in the terminal. This will ensure you have the required packages.The default command
justinto the terminal will do the following:A. initialise the example-services repo
B. launch an instance of NumTracker, RabbitMQ, Keycloak, Tiled, OPA and a number of IOCs in detached mode
C. set required EPICS environmental variables
D. start the BlueAPI server using the the config in
tests/system_tests/config.yaml
To run the above separately use the following commands:
2A and 2B:
just compose2C and 2D:
just serve
In a new terminal window, to run unit and system tests respectively:
just unitandjust systemOther commands available (use
just --listto see them)just run PLAN PARAMS: provide session, plan and parameter details to run a planjust lint: will run all the precommit checks, update the BlueAPI schema, run pyrightjust coverage: generate code coverage reportjust repl: will give you a repl with pre-configured and logged in clientjust compose down: tear down adjacent services
Channel Access
To log in through the BlueAPI CLI:
Run
blueapi login(if you want to run a plan with stomp config, add the-c tests/system_tests/config.yamlparameter)Follow the login prompted to Keycloak, then log in with the username
adminand passwordadminWhen prompted by Keycloak, grant BlueAPI access to the listed privileges
Run
blueapi controller plansto check that the log in has succeeded
By default the BlueAPI instance will be available via the OAuth2 proxy at localhost:4180, and Tiled through its OAuth2 proxy at localhost:4181.