Repository navigation
Description
Remote Git Repository as Source for Plans and Devices
Background
We introduced a scratch area in #313 so that plan/device code could be loaded from external files on startup. Typically we check out these files on a shared filesystem for prototyping. We have found several issues with this approach:
- Longer startup times as the code is loaded in
- Blueapi is difficult to hot-reload (hopefully fixed with Run worker in subprocess #317)
- The shared files may get conflicting edits by multiple people
- Especially confusing if one person left uncomitted changes
- May also lead to permissions issues if someone creates, and owns, a new file
- It can be hard to restore blueapi to a known state without deleting WIP code in the scratch area
We are therefore looking for a more flexible, long-term solution that will enable more robust deployments at the facility level.
Proposed Solution
Outline
Add the option to configure blueapi to pull down and install git repositories into its environment on startup. Define a "workspace" i.e. a group of remote git repositories that blueapi uses. On startup/reload, it will pull these as-configured (latest main, latest tag, some specific branch or hash). It can be configured via REST endpoints. It will also cache what it pulls in case the remote goes down.
Example Workflow for Prototyping Changes
An example workflow for prototyping changes to plans/devices is therefore:
- Checkout the relevent repo
- Make a new branch
- Make some experimental changes and push
- Point blueapi at the new branch
This adds some extra overhead to get experimental changes in, however they can be addressed outside of blueapi. For example, we have considered an auto-commit program for less advanced users. From their perspective they click "save" and a few seconds later the changes are live.
Benefits
- We can track ongoing changes to deployments at the facility level
- No shared checkouts are being edited
- There is always the option of easily restoring to a working state (
mainbranch) - Caching reduces startup times most of the time
Outstanding Concerns
- Is this too complex?
- It's risky to depend on remote github/gitlab repositories for runtime operation (solvable by hosting an intermediate git server, but that adds yet more complexity)
- Are we just using git as a database?

Activity
stan-dot commentedon Mar 27, 2024
re: 'point blueapi at the new branch'
how would this be done? with a config value? there is no 'config' area in the current CLI.
re: risk
an intermediate server could be on the local gitlab with bidirectional mirroring. an opinion from the cloud team would be necessary. Definitely relying on github only without redundancy would be bad.
re: Are we just using git as a database?
is there something wrong with that?
re: self hosted vscode
we should spin a container there with devcontainers with the auto commit extension
https://marketplace.visualstudio.com/items?itemName=vsls-contrib.gitdoc
re: making own editor from scratch
I had a brief discussion about this. Main conclusion - it's very difficult.
intellisense would be a huge block and there is no spare capacity to make it a good product. there are some libraries like
https://editorjs.io/
or
https://github.com/tinymce/tinymce
but those are not well-suited for code. Even still we could manage file updates - https://fastapi.tiangolo.com/tutorial/request-files/ .
stan-dot commentedon Mar 27, 2024
re: self-hosted but diff than vscode
I hope each of those could be pulled up with a simple helm chart.
The one for redhat doesn't seem the best as the beamline workstations have windows not redhat.
then the search for a self-hosted solution starts with awesome-selfhosted README.
there we find coder
eclipse Theia
https://theia-ide.org/
gitpod
https://www.gitpod.io/
code-server
https://docs.linuxserver.io/images/docker-code-server/#usage
https://code.visualstudio.com/docs/remote/vscode-server
and also some more niche projects for comparison, that are likely not mature enough for our use case:
stan-dot commentedon Mar 27, 2024
action recommendation:
outline a brief plan to get a devcontainer setup for a specific beamline - like
i20-1- define a set of extensions, and create a github repo with a gitlab mirror. Then take this to the cloud team to get the thing running and then add 'read from repo' endpoint refresh into blueapi config.this proof of concept is not an MVP yet but every day that the scripts aren't version-controlled is a risk.
Expected outcome:
in 2 weeks the proof of concept is built and then the effort and cloud resources to create an MVP can be estimated, and subsequent migration can be propagated throughout the beamlines.
Once deployed presumably this would require little maintainance. One shared repository for all the plans across beamlines could be added as a nice feature.
callumforrester commentedon Mar 28, 2024
A few thoughts:
A couple of other things to consider:
stan-dot commentedon Mar 28, 2024
I mean our local gitlab instance maintained by the cloud team.
that seems easier that making another mirror from scratch
https://docs.gitlab.com/ee/user/project/repository/mirror/bidirectional.html
I mean for 1 beamline as an MVP, to try out there their specific plans. limiting the scope.
messy git history is better than no history.
why would we want to track history of each plan? that's a wild requirement. arguably we could cache a git ref or text snapshot in the plan metadata instead of just plan name. not sure what is the use case here
stan-dot commentedon Apr 2, 2024
testing the linuxserver /code-server image now https://hub.docker.com/r/linuxserver/code-server
stan-dot commentedon Apr 2, 2024
let's consider for a moment what if the experimental plans lived at the head, people just pushing to production all the time. of course the more long-lived plans would be in a different directory
stan-dot commentedon Apr 2, 2024
with that of course to not get stuck in the event of github coing down
stan-dot commentedon Apr 2, 2024
and the workspace dir could be mounted in
/dlsso that it's always available locally if neededstan-dot commentedon Apr 2, 2024
gitdocs seems to work fine. next I'll try to commit a new ophyd device from there
12 remaining items
callumforrester commentedon Jun 19, 2024
Continued in #509
stan-dot commentedon Jun 19, 2024
@callumforrester this could still be kept here as part of the epic afaik
callumforrester commentedon Jun 19, 2024
@stan-dot Good point!
abbiemery commentedon Feb 25, 2026
Scratch area now contains git repos that can be committed to as normal.