Skip to content

Commit

Permalink
Stream into a different key
Browse files Browse the repository at this point in the history
  • Loading branch information
DominicOram committed Sep 26, 2024
1 parent 5697330 commit 7540a31
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/mx_bluesky/beamlines/i04/callbacks/murko_callback.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import copy
import json
from datetime import timedelta

from bluesky.callbacks import CallbackBase
from dodal.log import LOGGER
Expand All @@ -8,6 +9,8 @@


class MurkoCallback(CallbackBase):
DATA_EXPIRY_DAYS = 7

def __init__(self, redis_host: str, redis_password: str, redis_db: int = 0):
self.redis_client = StrictRedis(
host=redis_host, password=redis_password, db=redis_db
Expand Down Expand Up @@ -40,6 +43,8 @@ def call_murko(self, uuid: str, omega: float):
metadata["uuid"] = uuid

# Send metadata to REDIS and trigger murko
self.redis_client.hset("test-metadata", uuid, json.dumps(metadata))
redis_key = f"murko:{metadata['sample_id']}:metadata"
self.redis_client.hset(redis_key, uuid, json.dumps(metadata))
self.redis_client.expire(redis_key, timedelta(days=self.DATA_EXPIRY_DAYS))
self.redis_client.publish("murko", json.dumps(metadata))
LOGGER.info("Metadata sent to redis")

0 comments on commit 7540a31

Please sign in to comment.