Skip to main content

Client library for the Rubin Observatory Squarebot

Project description

Squarebot

Squarebot is the nexus service for ChatOps and event-driven bots for Rubin Observatory. As a Slack app, Squarebot receives events from Slack and publishes them into specific Square Events Kafka topics in the Roundtable Kubernetes cluster. Other applications on Roundtable can consume these events and act on them, such as by posting messages back to Slack or by performing some other background automation.

flowchart LR
    subgraph Slack
    message[Slack message]
    interaction[Slack interaction]
    end
    subgraph sqrbot ["Squarebot"]
    eventapi["/slack/event"]
    interactionapi["/slack/interaction"]
    message -->|HTTP POST| eventapi
    interaction -->|HTTP POST| interactionapi
    end
    subgraph kafka ["Kafka Topics"]
    topicmention["lsst.square-events.squarebot.slack.app.mention"]
    topicchannel["lsst.square-events.squarebot.slack.message.channel"]
    topicgroup["lsst.square-events.squarebot.slack.message.group"]
    topicim["lsst.square-events.squarebot.slack.message.im"]
    topicmpim["lsst.square-events.squarebot.slack.message.mpim"]
    topicinteraction["lsst.square-events.squarebot.slack.interaction"]
    end
    eventapi --> topicmention
    eventapi --> topicchannel
    eventapi --> topicgroup
    eventapi --> topicim
    eventapi --> topicmpim
    interactionapi --> topicinteraction
    subgraph backends ["Backends"]
    backend1["Backend 1"]
    backend2["Backend 2"]
    end
    topicchannel --> backend1
    topicgroup --> backend1
    topicmention --> backend2
    topicinteraction --> backend2

Slack integration is implemented at the time. We plan to add support for other event sources, such as GitHub, in the future.

Squarebot is built on top of FastAPI, a modern Python web framework, with the Rubin/SQuaRE Safir library. Squarebot uses FastStream to publish messages to Kafka with the aiokafka library.

Development set up

Squarebot uses Python 3.12 or later.

You'll need nox to run the development environment:

pip install nox

Then you can set up a virtual environment with the development dependencies:

nox -s venv-init`

(If you already have a virtual environment, you can activate it and run nox -s init instead).

The tests require a local Kafka broker. If you have Docker, you can deploy a Kafka broker with Docker Compose:

docker-compose -f kafka-compose.yaml up

To run all linters, type checking, and tests, run:

nox

While developing and running tests, you can inspect messages produced to Kafka with Kafdrop at http://localhost:9000.

You can run individual sessions with nox -s <session-name>. See nox -l for a list of available sessions.

To tear down the Kafka broker, run:

docker-compose -f kafka-compose.yaml down

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

rubin-squarebot-0.8.0.tar.gz (9.0 kB view details)

Uploaded Source

Built Distribution

rubin_squarebot-0.8.0-py3-none-any.whl (7.8 kB view details)

Uploaded Python 3

File details

Details for the file rubin-squarebot-0.8.0.tar.gz.

File metadata

  • Download URL: rubin-squarebot-0.8.0.tar.gz
  • Upload date:
  • Size: 9.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/4.0.2 CPython/3.11.8

File hashes

Hashes for rubin-squarebot-0.8.0.tar.gz
Algorithm Hash digest
SHA256 c05de27b886d47324bf258f5db4876312bebea09bcdf17b795387017ab1bd1a4
MD5 b2e6be16dab5d95ffc1542648d1caddd
BLAKE2b-256 4b9ab7df52b99d037b6e976a2fb0c8d309f18bc870c536fdc099a746437734e1

See more details on using hashes here.

File details

Details for the file rubin_squarebot-0.8.0-py3-none-any.whl.

File metadata

File hashes

Hashes for rubin_squarebot-0.8.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a8a671cc8cb6eb59af923bd42eb2dd0bbb145f6b7aaf9c27f9fa554fee28299c
MD5 b4ef3f26eb0a89f047cdefa890bbaa79
BLAKE2b-256 89e5235f42298eb529ba5dc6d9ea55a6568dbbfd35aded4736715f9f9c8c8df5

See more details on using hashes here.

Supported by

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