Skip to content

Instantly share code, notes, and snippets.

@danielballan
Last active March 6, 2024 19:12
Show Gist options
  • Save danielballan/31d408bd0506aa30173c4b0495279c0c to your computer and use it in GitHub Desktop.
Save danielballan/31d408bd0506aa30173c4b0495279c0c to your computer and use it in GitHub Desktop.
Demo Stream documents into Tiled
import json
from pathlib import Path
from bluesky.callbacks.tiled_writer import TiledWriter
from tiled.client import from_uri
documents = json.loads(Path("documents.json").read_text())
client = from_uri("http://localhost:8000", api_key="secret")
tw = TiledWriter(client)
for item in documents:
name = item["name"]
doc = item["doc"]
tw(name, doc)
[
{
"name": "start",
"doc": {
"uid": "617184e5-5e24-40b1-80f7-0056d51e44f8",
"time": 0
}
},
{
"name": "descriptor",
"doc": {
"uid": "8ff32942-9b21-4542-aee1-16c04291950d",
"data_keys": {
"image": {
"dtype": "array",
"shape": [5, 5],
"source": "test"
}
}
}
},
{
"name": "stream_resource",
"doc": {
"uid": "158167d9-796b-4e12-afff-5b3dd903815c",
"data_key": "waxs-sum",
"spec": "TEST",
"root": "/tmp/test/",
"resource_path": "data.h5",
"resource_kwargs": {
"path": "/test"
},
"path_semantics": "posix",
"run_start": "617184e5-5e24-40b1-80f7-0056d51e44f8"
}
},
{
"name": "stream_datum",
"doc": {
"stream_resource": "158167d9-796b-4e12-afff-5b3dd903815c",
"uid": "158167d9-796b-4e12-afff-5b3dd903815c/2",
"seq_nums": {
"start": 6,
"stop": 7
},
"indices": {
"start": 5,
"stop": 6
},
"descriptor": "8ff32942-9b21-4542-aee1-16c04291950d"
}
},
{
"name": "stop",
"doc": {
"run_start": "617184e5-5e24-40b1-80f7-0056d51e44f8",
"time": 1,
"exit_status": "success",
"reason": ""
}
}
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment