usnistgov / PyHyperScattering

Tools for hyperspectral x-ray and neutron scattering data loading, reduction, slicing, and visualization.
Other
7 stars 9 forks source link

SST1RSoXSDB: Loader Instantiation fails with latest Tiled,DataBroker #76

Closed BijalBPatel closed 1 year ago

BijalBPatel commented 1 year ago

When using versions databroker-2.0.0b17, tiled-0.1.0a89, attempting to instantiate the loader as:

phsDataLoader = phs.load.SST1RSoXSDB(corr_mode='none')

results in an error:

---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
Cell In[3], line 3
      1 # Pulls scattering data and metadata into x-array format
      2 # From the Jupyterhub, to directly access NSLS2 BlueSky data
----> 3 phsDataLoader = phs.load.SST1RSoXSDB(corr_mode='none')
      5 # Note: the loader initializes with access to databroker catalog
      6 # Direct access to the catalog can be achieved by:
      7 # db_Catalog = tiled.client.from_profile("rsoxs")

File [~/BP_LocalCodeBase/PyHyperScattering/src/PyHyperScattering/SST1RSoXSDB.py:79](...~/BP_LocalCodeBase/PyHyperScattering/src/PyHyperScattering/SST1RSoXSDB.py:79), in SST1RSoXSDB.__init__(self, corr_mode, user_corr_fun, dark_subtract, dark_pedestal, exposure_offset, catalog, catalog_kwargs, use_precise_positions, use_chunked_loading)
     77 self.use_chunked_loading = use_chunked_loading
     78 if catalog is None:
---> 79     self.c = from_profile("rsoxs", **catalog_kwargs)
     80 else:
     81     self.c = catalog

File [~/.conda/envs/BP_PyHyperStable/lib/python3.9/site-packages/tiled/client/constructors.py:257](.../.conda/envs/BP_PyHyperStable/lib/python3.9/site-packages/tiled/client/constructors.py:257), in from_profile(name, structure_clients, **kwargs)
    253             merged["structure_clients"] = result
    254 if "direct" in merged:
    255     # The profile specifies the server in-line.
    256     # Create an app and use it directly via ASGI.
--> 257     from ..server import build_app_from_config
    259     config = merged.pop("direct", None)
    260     context = Context.from_app(build_app_from_config(config), **merged)

ImportError: cannot import name 'build_app_from_config' from 'tiled.server' (/nsls2/users/bpatel/.conda/envs/BP_PyHyperStable/lib/python3.9/site-packages/tiled/server/__init__.py)

Reverting to tiled==0.1.0a74 databroker==2.0.0b10 and making sure to have the latest pyOpenSSL and cryptography appears to work.

!pip install tiled==0.1.0a74 databroker==2.0.0b10 pyOpenSSL cryptography

BijalBPatel commented 1 year ago

Not really sure if it's a 'bug' per se, since these are all in development packages.

I don't really know where the fix would be programmatically. Since these aren't in requirements.txt ( I assume b/c they only are used for a subset of the code/functionality?)

pbeaucage commented 1 year ago

These are actually all in requirements.txt (well, requirements-bluesky.txt): like many packages in the BlueSky ecosystem, PyHyper uses Requirement Specifiers to allow optional dependencies without making the core dependency footprint massive.

That said, I think this is an upstream problem with either tiled, databroker, or the NSLS-II scipy-binder repo build. I'm not sure there is anything we can do to fix it from our end. Hopefully anyone else who encounters this can find this issue.