BCDA-APS / apstools

various tools for use with Bluesky at the APS
https://bcda-aps.github.io/apstools/latest/
Other
16 stars 9 forks source link

databroker 2.0.0 compels changes in listruns #643

Open prjemian opened 2 years ago

prjemian commented 2 years ago

While testing databroker 2.0.0a22 today, the import failed due to older databroker internals. (attn @danielballan)

In [2]: from tiled.client import from_uri
   ...: c = from_uri("http://127.0.0.1:8000")

In [3]: from databroker.queries import TimeRange, RawMongo
   ...: c["9idc_usaxs"].search(TimeRange(since="2022-02-02", until="2022-02-05")).search(RawMongo(start={"esaf_id": "250815"}))
/share1/bluesky/conda_envs/db2.0/lib/python3.9/site-packages/databroker/queries.py:213: PytzUsageWarning: The zone attribute is specific to pytz's interface; please migrate to a new time zone provider. For more details on how to do so, see https://pytz-deprecation-shim.readthedocs.io/en/latest/migration.html
  timezone = lz.zone
Out[3]: <Catalog {26, 27, 32, 33, 34, 35, 36, 38, 39, 40, ...} ~1317 entries>

In [4]: from apstools.utils import listruns
---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
<ipython-input-4-15bbcece80f9> in <module>
----> 1 from apstools.utils import listruns

/share1/bluesky/conda_envs/db2.0/lib/python3.9/site-packages/apstools/utils/__init__.py in <module>
----> 1 from .catalog import copy_filtered_catalog
      2 from .catalog import findCatalogsInNamespace
      3 from .catalog import getCatalog
      4 from .catalog import getDatabase
      5 from .catalog import getDefaultCatalog

/share1/bluesky/conda_envs/db2.0/lib/python3.9/site-packages/apstools/utils/catalog.py in <module>
     17 import databroker
     18 import databroker.queries
---> 19 import databroker._drivers.mongo_normalized
     20 import databroker._drivers.msgpack
     21 import logging

ModuleNotFoundError: No module named 'databroker._drivers'

In [5]: databroker.__version__
---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-5-c874551783ae> in <module>
----> 1 databroker.__version__

NameError: name 'databroker' is not defined

In [6]: import databroker

In [7]: databroker.__version__
Out[7]: '2.0.0a22'

In [8]: 
prjemian commented 1 year ago

Look at this after April 2023

danielballan commented 1 year ago

The imports of the internal _drivers package are the problem. Fortunately, they are not used anywhere later in the module. I think these two lines can be removed:

import databroker._drivers.mongo_normalized
import databroker._drivers.msgpack
prjemian commented 1 year ago

Testing with newer code versions all around, same error but source point moved:

Successfully installed apstools-1.6.15 pyresttable-2020.0.8
Note: you may need to restart the kernel to use updated packages.

In [9]: from apstools.utils import listruns
---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
Cell In[9], line 1
----> 1 from apstools.utils import listruns

File ~/.conda/envs/databroker/lib/python3.9/site-packages/apstools/utils/__init__.py:1
----> 1 from ._core import TableStyle
      2 from .catalog import copy_filtered_catalog
      3 from .catalog import findCatalogsInNamespace

File ~/.conda/envs/databroker/lib/python3.9/site-packages/apstools/utils/_core.py:3
      1 from enum import Enum
----> 3 import databroker._drivers.mongo_normalized
      4 import databroker._drivers.msgpack
      5 import intake

ModuleNotFoundError: No module named 'databroker._drivers'
prjemian commented 1 year ago

Used here: https://github.com/BCDA-APS/apstools/blob/c8de7bbde083073d46b7201779fa89e98fcc8818/apstools/utils/_core.py#L12-L22

https://github.com/BCDA-APS/apstools/blob/c8de7bbde083073d46b7201779fa89e98fcc8818/apstools/utils/catalog.py#L206

https://github.com/BCDA-APS/apstools/blob/c8de7bbde083073d46b7201779fa89e98fcc8818/apstools/utils/list_runs.py#L388