Skip to content

Commit 197b720

Browse files
authored
Merge pull request #870 from danielballan/avoid-sqlalchemy-dep
Avoid sqlalchemy dep
2 parents a5d0040 + 8b52f5b commit 197b720

File tree

2 files changed

+29
-8
lines changed

2 files changed

+29
-8
lines changed

bluesky-tiled-plugins/bluesky_tiled_plugins/catalog_of_bluesky_runs.py

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
import functools
44
import numbers
55
import operator
6+
from typing import Any
67

7-
from tiled.adapters.utils import IndexCallable
88
from tiled.client.container import Container
99
from tiled.client.utils import handle_error
1010
from tiled.queries import Comparison, Eq, Like
@@ -33,7 +33,7 @@ def __init__(self, *args, **kwargs):
3333

3434
def __repr__(self):
3535
# This is a copy/paste of the general-purpose implementation
36-
# tiled.adapters.utils.tree_repr
36+
# tiled.utils.node_repr
3737
# with some modifications to extract scan_id from the metadata.
3838
sample = self.items()[:10]
3939
# Use scan_id (int) if defined; otherwise fall back to uid.
@@ -209,3 +209,28 @@ def post_document(self, name, doc):
209209
link = self.item["links"]["self"].replace("/metadata", "/documents", 1)
210210
response = self.context.http_client.post(link, content=safe_json_dump({"name": name, "doc": doc}))
211211
handle_error(response)
212+
213+
214+
class IndexCallable:
215+
"""
216+
DEPRECATED and no longer used internally
217+
218+
Provide getitem syntax for functions
219+
220+
>>> def inc(x):
221+
... return x + 1
222+
223+
>>> I = IndexCallable(inc)
224+
>>> I[3]
225+
4
226+
227+
Vendored from dask
228+
"""
229+
230+
__slots__ = ("fn",)
231+
232+
def __init__(self, fn: Any) -> None:
233+
self.fn = fn
234+
235+
def __getitem__(self, key: str) -> Any:
236+
return self.fn(key)

databroker/mongo_normalized.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,8 @@
3636
from tiled.iterviews import KeysView, ItemsView, ValuesView
3737
from tiled.query_registration import QueryTranslationRegistry
3838
from tiled.queries import AccessBlobFilter, Contains, Comparison, Eq, FullText, In, NotEq, NotIn, Regex
39-
from tiled.adapters.utils import (
40-
tree_repr,
41-
IndexersMixin,
42-
)
4339
from tiled.structures.core import Spec, StructureFamily
44-
from tiled.utils import import_object, OneShotCachedMap, UNCHANGED
40+
from tiled.utils import UNCHANGED, IndexersMixin, OneShotCachedMap, import_object, node_repr
4541

4642
from .query_impl import (
4743
BlueskyMapAdapter,
@@ -1470,7 +1466,7 @@ def __repr__(self):
14701466
# Display up to the first N keys to avoid making a giant service
14711467
# request. Use _keys_slicer because it is unauthenticated.
14721468
N = 10
1473-
return tree_repr(self, self._keys_slice(0, N, direction=1))
1469+
return node_repr(self, self._keys_slice(0, N, direction=1))
14741470

14751471
def _get_run(self, run_start_doc):
14761472
"Get a BlueskyRun, either from a cache or by making one if needed."

0 commit comments

Comments
 (0)