Skip to content

DiamondLightSource/pato-backend

Repository files navigation

PATo API

Code CI Apache License

Source code https://github.com/DiamondLightSource/pato-backend

Particle Analysis and Tomography Data API.

Configuration

The API supports a configuration file, that follows the example set in config.json, but most importantly, two environment variables need to be set:

  • SQL_DATABASE_URL: The URL for the database
  • CONFIG_PATH: Path for the configuration file

Additionally, the following environment variables can be set to enable message queue support:

  • MQ_USER: Message queue user
  • MQ_PASS: Message queue password

As for the JSON configuration file, details are as follows:

  • auth
    • endpoint: URL for the chosen auth method
    • read_all_perms: Permission groups that should be granted full read permissions
    • type: Authentication type. Can be micro or dummy
    • beamline_mapping: A map of permission groups and the beamlines that permission group should be allowed to viewing
  • mq
    • host: Message queue host
    • port: Mesasge queue port
    • queue: Queue name
    • vhost: Message queue virtual host
    • consumer_queue: Queue to consume messages from (for notifications)
  • ispyb
    • pool: Connection pool size
    • overflow: Connection pool overflow max size
  • facility
    • contact_email: Contact email to be used across the application
    • smtp_server: SMTP server host
    • smtp_port: SMTP port to be used for emailing reports
    • active_session_cutoff: Time, in weeks, to be used as a threshold for determining if a session is active or not, following the end of the first processing pipeline. For example, a session would be considered inactive if there were no new actions for the past 5 weeks, by default.
    • users_only_on_industrial: Hide industrial session details from staff, only display it to users/staff directly listed as part of that visit

Deployment

Running development server on your machine:

  1. Install the package with pip install . or pip install -e .
  2. Set the SQL_DATABASE_URL environment variable according to your database's location
  3. Run uvicorn with uvicorn pato.main:app --reload --port 8000 --host 0.0.0.0

Optional dependencies:

You might want to test out RabbitMQ integration. In order to do that, you need to point to a valid MQ instance. You can run one locally with podman run -d -e RABBITMQ_DEFAULT_USER=guest -e RABBITMQ_DEFAULT_PASS=guest -p 5672:5672 rabbitmq:3

Testing

  • Build the mock ISPyB database (in database, or from the built Docker image)
  • Run with podman run -p 3306:3306 --detach --name diamond-ispyb localhost/diamond-ispyb
    • You may change the port or where the container itself runs, just remember to update .test.env
  • Run tox -e pytest

About

Particle analysis and tomography data display application (backend)

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors 8