Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Explore how to keep local cache for beamline alignment #537

Open
stan-dot opened this issue Jul 3, 2024 · 16 comments
Open

Explore how to keep local cache for beamline alignment #537

stan-dot opened this issue Jul 3, 2024 · 16 comments
Labels
enhancement New feature or request python Pull requests that update Python code question Further information is requested

Comments

@stan-dot
Copy link
Collaborator

stan-dot commented Jul 3, 2024

We need to keep some cache lookup tables for the purposes of beamline alignment. That could be as a local pod-specific *.npy file, or REDIS in a different pod on a cluster. We certainly need some solution for this.

Potential options include:

@stan-dot stan-dot added enhancement New feature or request question Further information is requested python Pull requests that update Python code labels Jul 3, 2024
@callumforrester
Copy link
Collaborator

I would recommend that this not become a feature of blueapi, for the sake of keeping it simple and small-scoped. Previously there has been discussion of using databases for lookup tables, I believe MX have had some success with redis. They have also used shared files as a temporary solution until the database was ready.

@DiamondJoseph
Copy link
Collaborator

This equates to Redis in a different pod in the namespace, and the plan calls out to it as part of execution, without it being a part of blueapi. Just a pattern for an adaptive scan

plan_start -> fetch values from external -> plan_body -> store values in external -> plan_finish

@DiamondJoseph
Copy link
Collaborator

There's also a non-numpy redis python client https://redis.io/docs/latest/develop/connect/clients/python/ for when using it as just key-value storage and don't need the array support

@stan-dot
Copy link
Collaborator Author

stan-dot commented Jul 4, 2024

@callumforrester this is a necessary feature and the data captured would be cached directly after running the plan.

And we know it's not beamline specific.

Therefore this will be a centrally developed and maintained feature, whether it's a part of blueapi OR a microservice that wraps reddits that blueapi talks to directly is an architectural decision.

and the 'worse is better' style would be to nicely add this into blueapi runner, whether here or in the #504 engine service.

@callumforrester
Copy link
Collaborator

@stan-dot Yes, could have a microservice wrapping redis and then interact with it from you own plans, what functionality is needed in the core of blueapi?

@stan-dot
Copy link
Collaborator Author

stan-dot commented Jul 8, 2024

@callumforrester
Copy link
Collaborator

Of those, I'd be most interested in where you get with graphile

@keeble
Copy link

keeble commented Jul 8, 2024

Without trying to be that guy, is it worth stating the specific use(s) for this?

Are we talking things like "we want to change the focal length of the mirror to the sample position, what are the 16 voltages we need for the bimorphs"? (i.e. things which rarely change) or more like "make a note of this motor position, we'll probably want to come back to this position later"? (i.e. a short-term storage)?

@stan-dot
Copy link
Collaborator Author

stan-dot commented Jul 8, 2024

what I got from the beamline interview is to replace this

dls_sw/i18/scripts/beamlinestuff/i18scans/Lookuptabledcm_i0.py
and the file
"/dls_sw/i18/software/gda/config/lookupTables/Si111/lookuptable_harmonic7.txt"

@stan-dot
Copy link
Collaborator Author

stan-dot commented Jul 8, 2024

https://github.com/etcd-io/etcd

and

https://github.com/apache/ignite

look the most promising. the former for 46k stars the latter for being in the Apache ecosystem (but less stars)

@DiamondJoseph
Copy link
Collaborator

DiamondJoseph commented Jul 8, 2024

RE: chatting with Stan

We probably want some simple way of tying into a key-value store instance that can be configured per beamline and interacted with as though it was just a dict. This probably lives in dodal as it is generic enough to be useful across beamlines.

e.g.

lookuptables = PersistedStore()
harmonic_7 = lookuptables["harmonic_7"]

def beamline_stub():
    harmonic_7 = do_alignment()
    lookuptables["harmonic_7"] = harmonic_7

@stan-dot
Copy link
Collaborator Author

stan-dot commented Jul 8, 2024

if we do as much, what does 'harmonic 7' even mean?

also fwiw I think that the 'inspect alignment' could be a whole another screen in the GUI

@DiamondJoseph
Copy link
Collaborator

But what would that GUI call? Eventually, a plan and that plan calls whatever stubs it requires.

It doesn't matter what harmonic7 means, because it's equally applicable to any lookup table or stored beamline configuration.

Moving from storing this data in a lookup file on the filesystem to in a memory store lets us view timeseries and recover previous states, access control etc.

@stan-dot
Copy link
Collaborator Author

stan-dot commented Jul 8, 2024

beamline alignment is a behavior applied to all beamlines so we'd like to have consistent lookup tables, at least at the level of science groups.

also from the k8s perspective there is a well maintained bitnami chart for etcd so I'd go with that one

@DiamondJoseph
Copy link
Collaborator

Direct link to the etcd Helm Chart's ArtifactHub page

https://artifacthub.io/packages/helm/bitnami/etcd

@stan-dot
Copy link
Collaborator Author

dodal reads in from the filesystem:

from dodal.devices.util.lookup_tables import (
    linear_interpolation_lut,
)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request python Pull requests that update Python code question Further information is requested
Projects
None yet
Development

No branches or pull requests

4 participants