Skip to content

Commit

Permalink
Merge pull request #774 from danielballan/rename-node-to-container
Browse files Browse the repository at this point in the history
Adjust for API change in Tiled
  • Loading branch information
danielballan authored Jul 9, 2023
2 parents 9959b39 + e3b0ae3 commit 6affee9
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 17 deletions.
20 changes: 10 additions & 10 deletions databroker/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import msgpack
from tiled.adapters.utils import IndexCallable
from tiled.client.node import DEFAULT_STRUCTURE_CLIENT_DISPATCH, Node
from tiled.client.container import DEFAULT_STRUCTURE_CLIENT_DISPATCH, Container
from tiled.client.utils import handle_error
from tiled.utils import safe_json_dump

Expand All @@ -28,11 +28,11 @@
_IPYTHON_METHODS = {"_ipython_canary_method_should_not_exist_", "_repr_mimebundle_"}


class BlueskyRun(BlueskyRunMixin, Node):
class BlueskyRun(BlueskyRunMixin, Container):
"""
This encapsulates the data and metadata for one Bluesky 'run'.
This adds for bluesky-specific conveniences to the standard client Node.
This adds for bluesky-specific conveniences to the standard client Container.
"""

@property
Expand Down Expand Up @@ -70,7 +70,7 @@ def documents(self, fill=False):
else:
fill = bool(fill)
link = self.item["links"]["self"].replace(
"/node/metadata", "/documents", 1
"/metadata", "/documents", 1
)
request = self.context.http_client.build_request(
"GET",
Expand Down Expand Up @@ -142,11 +142,11 @@ def read(self):
to_dask = read


class BlueskyEventStream(BlueskyEventStreamMixin, Node):
class BlueskyEventStream(BlueskyEventStreamMixin, Container):
"""
This encapsulates the data and metadata for one 'stream' in a Bluesky 'run'.
This adds for bluesky-specific conveniences to the standard client Node.
This adds for bluesky-specific conveniences to the standard client Container.
"""

@property
Expand Down Expand Up @@ -216,9 +216,9 @@ def to_dask(self):
).read()


class CatalogOfBlueskyRuns(CatalogOfBlueskyRunsMixin, Node):
class CatalogOfBlueskyRuns(CatalogOfBlueskyRunsMixin, Container):
"""
This adds some bluesky-specific conveniences to the standard client Node.
This adds some bluesky-specific conveniences to the standard client Container.
>>> catalog.scan_id[1234] # scan_id lookup
>>> catalog.uid["9acjef"] # (partial) uid lookup
Expand Down Expand Up @@ -317,10 +317,10 @@ def v1(self):

def post_document(self, name, doc):
link = self.item["links"]["self"].replace(
"/node/metadata", "/documents", 1
"/metadata", "/documents", 1
)
response = self.context.http_client.post(
link,
data=safe_json_dump({"name": name, "doc": doc})
content=safe_json_dump({"name": name, "doc": doc})
)
handle_error(response)
6 changes: 3 additions & 3 deletions databroker/mongo_normalized.py
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,7 @@ class DatasetFromDocuments:
An xarray.Dataset from a sub-dict of an Event stream
"""

structure_family = "node"
structure_family = StructureFamily.container
specs = [Spec("xarray_dataset")]

def __init__(
Expand Down Expand Up @@ -1033,7 +1033,7 @@ def build_config_xarray(


class MongoAdapter(collections.abc.Mapping, CatalogOfBlueskyRunsMixin, IndexersMixin):
structure_family = "node"
structure_family = StructureFamily.container
specs = [Spec("CatalogOfBlueskyRuns", version="1")]

# Define classmethods for managing what queries this MongoAdapter knows.
Expand Down Expand Up @@ -1664,7 +1664,7 @@ def get_distinct(self, metadata, structure_families, specs, counts):

if structure_families:
distinct_structure_families = {
"value": StructureFamily.node,
"value": StructureFamily.container,
"count": node_size,
}
data["structure_families"] = [distinct_structure_families]
Expand Down
2 changes: 1 addition & 1 deletion databroker/tests/test_queries.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ def test_distinct(c, RE, hw):
"metadata": {
"start.foo": [{"value": "a", "count": 1}, {"value": "b", "count": 1}]
},
"structure_families": [{"value": "node", "count": 2}],
"structure_families": [{"value": "container", "count": 2}],
"specs": [{"value": [{"name": "BlueskyRun", "version": "1"}], "count": 2}],
}

Expand Down
2 changes: 1 addition & 1 deletion requirements-client.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
mongoquery
msgpack >=1.0.0
orjson
tiled[client] >=0.1.0a89
tiled[client] >=0.1.0a98
2 changes: 1 addition & 1 deletion requirements-server.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ pytz
rich
starlette
suitcase-mongo
tiled[server] >=0.1.0a89
tiled[server] >=0.1.0a98
toolz
typer
tzlocal
Expand Down
2 changes: 1 addition & 1 deletion requirements-test.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ sphinx
suitcase-jsonl >=0.1.0b2
suitcase-mongo >=0.1.0
suitcase-msgpack >=0.2.2
tiled[all] >=0.1.0a89
tiled[all] >=0.1.0a98
ujson
vcrpy

0 comments on commit 6affee9

Please sign in to comment.