Setup your databroker catalog configuration#
The bluesky instrument uses a YAML file which describes the connection with some location where data is stored, typically a MongoDB collection. This is called a catalog configuration file.
The catalog configuration file must be placed in a directory where databroker expects to find it. Run this snippet to find the list of paths where it looks on your system:
$ python -c "import databroker; print(databroker.catalog_search_path())" ('/home/user/.local/share/intake', '/home/user/.conda/envs/bluesky_2023_3/share/intake')
Create a YAML file in one of these directories. (The actual file name does not
matter. Only that it ends with .yml
. Also, amongst all the .yml
files
found on the search path, any catalog names defined only appear once.) Since
you might recreate the environment, it is suggested not to install into any
environment directory (such as
/home/user/.conda/envs/bluesky_2023_3/share/intake
listed above).
Here is an example used with the Bluesky training demonstration:
# file: training.yml
# purpose: Configuration file to connect Bluesky databroker with MongoDB
# For Bluesky Python Training at APS
# Copy to: ~/.local/share/intake/training.yml
# Create subdirectories as needed
sources:
training:
args:
asset_registry_db: mongodb://localhost:27017/training-bluesky
metadatastore_db: mongodb://localhost:27017/training-bluesky
driver: bluesky-mongo-normalized-catalog
Let’s assume (for example purposes) this catalog assignment (BCDA instruction to create an assignment):
name:
45ida_abcd
MongoDB server:
mongoserver.xray.aps.anl.gov
MongoDB collection:
45ida_abcd-bluesky
Create any missing directories as needed:
mkdir -p ~/.local/share/intake
Create file
~/.local/share/intake/databroker_catalogs.yml
Open in an editor and copy/paste the content above.
Change
training:
to your catalog’s name, such as45ida_abcd:
Change both lines with
mongodb://...
tomongodb://mongoserver.xray.aps.anl.gov:27017/45ida_abcd-bluesky
.Change the comments accordingly.
Confirm that databroker can find this catalog configuration file:
$ python -c "import databroker; print(list(databroker.catalog))" ['45ida_abcd']