Skip to main content

An API for small fast data analysis jobs at Diamond Light Source

Project description

CI Coverage PyPI License

heliotrapi

An API for small fast data analysis jobs at Diamond Light Source.

[HEE-LEE-OH-TRAY-PEE-EYE]

Helio - Like the sun, a very brilliannt light source Heliotrope - An pink-purple indigo-like colour HeliotrAPI - The API that comes after blue

heliotrapi exposes an HTTP API to submit analysis jobs, return queued results, and optionally consume messages from RabbitMQ.

Source https://github.com/DiamondLightSource/heliotrapi
PyPI pip install heliotrapi
Docker docker run ghcr.io/diamondlightsource/heliotrapi:latest
Releases https://github.com/DiamondLightSource/heliotrapi/releases

Example Python usage:

from heliotrapi import __version__

print(f"Hello heliotrapi {__version__}")

To start the api server in dev mode on local host:

uvicorn heliotrapi.main:start_api --reload --factory --host 127.0.0.1 --port 8000

or

heliotrapi serve

Overview

The app accepts analysis jobs via HTTP or the client and stores results in memory for a configurable time-to-live. Jobs can also be ingested from RabbitMQ if rabbitmq.enabled is set.

Sending/Recieving results using the python client

    from heliotrapi.client import AnalysisClient

    client = AnalysisClient("ixx-analysis.diamond.ac.uk")

    print(client.available_analyses()) #see available analyses

    client.submit("name_of_analysis", examplekwarg1=1, examplekwarg2=2) # <- if kawrgs are invalid it will raise

    result = client.get_result() #returns an AnalysisResult basemodel

    print(result)

Using the WebUI

You can also navigate to the url or the ip address to be met with:

Web UI

Request flow

  • AnalysisClient submits jobs to /analyse

  • Jobs are queued in QueueManager

  • Workers process jobs in FIFO order

  • Results are returned via /result/id/{request_id} or /result/latest

  • Optional RabbitMQ listener can enqueue jobs automatically

                   AnalysisClient ─────--────────────────
                      │ ▲                │              │
                      ▼ │                ▼              ▼
      Analysis <-── heliotrapi ──---►  RabbitMQ ──---► Results
         Job   ─---►    ▲                │
                        │                │
                        │                │   
                  RabbitListener <───────
    

Kubernetes deployment

This repository includes a Helm chart under ./helm/heliotrapi.

Config support

The service supports configuration from one of these sources:

  • CONFIG_PATH environment variable
  • mounted config file at /etc/config/config.yaml
  • local config.yaml file in the current working directory

In Kubernetes, the Helm chart mounts config.yaml from a ConfigMap and sets:

env:
  - name: CONFIG_PATH
    value: "/etc/config/config.yaml"

RabbitMQ config

The Helm values now expose RabbitMQ settings in the same shape as the app expects:

config:
  rabbitmq:
    enabled: true
    host: ixx-analysis.diamond.ac.uk
    username: guest
    password: guest
    port: 61613
    destinations:
      - "/topic/public.worker.event"
      - "/topic/gda.messages.scan"
      - "/topic/gda.messages.processing"
      - "/topic/public.analysis.trigger"

Helm usage

  1. Build and push your Docker image
podman build -t ghcr.io/diamondlightsource/heliotrapi:latest .
podman push ghcr.io/diamondlightsource/heliotrapi:latest
  1. Render the chart
helm template heliotrapi ./helm/helm/heliotrapi
  1. Dry-run validation
helm template heliotrapi ./helm/heliotrapi | kubectl apply --dry-run=client -f -
  1. Install the chart
helm install heliotrapi ./helm/heliotrapi
  1. Verify the deployment
kubectl get pods
kubectl get svc
  1. Test the API
kubectl port-forward svc/heliotrapi 8000:8000

Then open:

http://localhost:8000/docs

Notes

  • The chart name has been updated to heliotrapi.
  • The config file is mounted via a ConfigMap and loaded from /etc/config/config.yaml.
  • The Helm chart currently creates a Deployment, Service, and ConfigMap.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

heliotrapi-0.1.7.tar.gz (839.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

heliotrapi-0.1.7-py3-none-any.whl (38.5 kB view details)

Uploaded Python 3

File details

Details for the file heliotrapi-0.1.7.tar.gz.

File metadata

  • Download URL: heliotrapi-0.1.7.tar.gz
  • Upload date:
  • Size: 839.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for heliotrapi-0.1.7.tar.gz
Algorithm Hash digest
SHA256 4404ca04f206a6605b50c02664fac029fec583d71dad4212d12ba39cfb7f96ef
MD5 38f708fa62945d90147a9a71b8738c04
BLAKE2b-256 4180c3e5b985656e8de8f0b13a62ba2bf3160be73a7cbbf9a55fb23b70bd3c08

See more details on using hashes here.

File details

Details for the file heliotrapi-0.1.7-py3-none-any.whl.

File metadata

  • Download URL: heliotrapi-0.1.7-py3-none-any.whl
  • Upload date:
  • Size: 38.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for heliotrapi-0.1.7-py3-none-any.whl
Algorithm Hash digest
SHA256 5062520ca47ffdde13a156495adadcddd3d2eaf2210bbb3705b620a6a737e7d6
MD5 e1a32e135e2c42b3b2b3234e81a284d8
BLAKE2b-256 5f15d1b7a31b33d108181d1f7faa84e1fe89e86b288535c2664514d79e01d7fd

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page