bluesky / databroker

Unified API pulling data from multiple sources
https://blueskyproject.io/databroker
BSD 3-Clause "New" or "Revised" License
33 stars 45 forks source link

Support updating metadata from Tiled client 🧱 #795

Closed Kezzsim closed 7 months ago

Kezzsim commented 7 months ago

This adds the ability for the raw blueskyRun and BlueskyEventStream objects to update their metadata, putting the onus on clients that invoke it to preserve existing metadata. Currently behaves like a PUT request, overwriting the existing data unless the client performs a copy.deepcopy() of the extant metadata dict.

Here is the code for performing such an update, keep in mind that the client should now be refactored with friendlier facilities for performing this action including HTTP PATCH requests like rfc6902. Potentially this would manifest as

import tiled
import copy
from tiled.client import from_uri
c = from_uri("http://localhost:8000",api_key="secret")
metadata = copy.deepcopy(dict(c[154705].metadata))
metadata["start"]["num_points"] = 2
c[154705].update_metadata(metadata=metadata)

Fix #792