Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mongo client for Lutz's custom sample database #13

Open
mrakitin opened this issue Jul 22, 2020 · 8 comments
Open

Mongo client for Lutz's custom sample database #13

mrakitin opened this issue Jul 22, 2020 · 8 comments

Comments

@mrakitin
Copy link
Member

This is the issue I observed while tried to run bsui with the new environment for this cycle:

[mrakitin@xf11id-dev ~]$ BS_ENV=collection-2020-2.0rc6 bsui

Versions of DAMA software:

    - Bluesky    : v1.6.4
    - Ophyd      : v1.5.2
    - Databroker : v1.0.6

Links to Bluesky and Databroker tutorials:

    - http://nsls-ii.github.io/bluesky/tutorial.html
    - http://nsls-ii.github.io/databroker/tutorial.html

If you get lost or confused, then we want to know! We have a friendly chat channel:

    https://gitter.im/NSLS-II/DAMA

or you can file a bug to let us know where our documentation could be made more clear:

    https://github.com/NSLS-II/Bug-Reports/issues

bsui is running these commands now to start an interactive computing environment for data acquisition:
    $ conda activate collection-2020-2.0rc6
    $ ipython --profile=collection --IPCompleter.use_jedi=False

Python 3.7.7 (default, Mar 26 2020, 15:48:22)
Type 'copyright', 'credits' or 'license' for more information
IPython 7.16.1 -- An enhanced Interactive Python. Type '?' for help.

IPython profile: collection
Loading metadata history from /home/mrakitin/.config/bluesky/bluesky_history.db
environment variable BLUESKY_LOG_FILE is not set, using default log file path '/home/mrakitin/.cache/bluesky/log/bluesky.log'
environment variable BLUESKY_IPYTHON_LOG_FILE is not set, using default file path '/home/mrakitin/.cache/bluesky/log/bluesky_ipython.log'
Activating auto-logging. Current session state plus future input saved.
Filename       : /home/mrakitin/.cache/bluesky/log/bluesky_ipython.log
Mode           : append
Output logging : True
Raw input log  : False
Timestamping   : True
State          : active
Exception reporting mode: Minimal
[TerminalIPythonApp] Running file in user namespace: /home/mrakitin/.ipython/profile_collection/startup/01-chxsetup.py
[TerminalIPythonApp] Running file in user namespace: /home/mrakitin/.ipython/profile_collection/startup/02-aliases.py
[TerminalIPythonApp] Running file in user namespace: /home/mrakitin/.ipython/profile_collection/startup/10-optics.py
[TerminalIPythonApp] Running file in user namespace: /home/mrakitin/.ipython/profile_collection/startup/15-machines.py
[TerminalIPythonApp] Running file in user namespace: /home/mrakitin/.ipython/profile_collection/startup/20-area-detectors.py
[TerminalIPythonApp] Running file in user namespace: /home/mrakitin/.ipython/profile_collection/startup/25-shutter.py
[TerminalIPythonApp] Running file in user namespace: /home/mrakitin/.ipython/profile_collection/startup/26-scalers.py
[TerminalIPythonApp] Running file in user namespace: /home/mrakitin/.ipython/profile_collection/startup/30-user.py
[TerminalIPythonApp] Running file in user namespace: /home/mrakitin/.ipython/profile_collection/startup/31-syringe_pump.py
[TerminalIPythonApp] Running file in user namespace: /home/mrakitin/.ipython/profile_collection/startup/34_fash_shutter_bpm_test.py
[TerminalIPythonApp] Running file in user namespace: /home/mrakitin/.ipython/profile_collection/startup/35-detectors.py
[TerminalIPythonApp] Running file in user namespace: /home/mrakitin/.ipython/profile_collection/startup/36-commisionning.py
[TerminalIPythonApp] Running file in user namespace: /home/mrakitin/.ipython/profile_collection/startup/37-database.py
[TerminalIPythonApp] WARNING | Unknown error in handling startup files:
AttributeError: 'Registry' object has no attribute 'config'


In [1]:
@tacaswell
Copy link
Member

The issue is that they are setting up additional connections to mongo by extracting the host from databroker.

cli = pymongo.MongoClient(db.reg.config['host'])
samples_2 = cli.get_database('samples').get_collection('samples_2')
data_acquisition_collection = cli.get_database('samples').get_collection('data_acquisition_collection')
beamline_pos = cli.get_database('samples').get_collection('beamline_pos')

cli = pymongo.MongoClient(db.reg.config['host'])
samples_2 = cli.get_database('samples').get_collection('samples_2')
data_acquisition_collection = cli.get_database('samples').get_collection('data_acquisition_collection')
beamline_pos = cli.get_database('samples').get_collection('beamline_pos')

(not sure why it is being done twice though)

We should either just embed their mongo host in the start up file or update thing to extract this information from the new databroker. I think the first option is better because we may want to migrate their databroker mongo but not touch their beamline specific stuff.

@mrakitin
Copy link
Member Author

We should either just embed their mongo host in the start up file or update thing to extract this information from the new databroker. I think the first option is better because we may want to migrate their databroker mongo but not touch their beamline specific stuff.

Thanks for investigating this, @tacaswell. Won't the first option override the settings we want in /etc/databroker/chx.yml?

@tacaswell
Copy link
Member

databroker will still look at the yaml file we will still respect that. It is the CHX-specific stuff that will ignore the yml. Another option is that we could read the yaml here (but then they will have to cope with any changes we make to its schema).

@mrakitin
Copy link
Member Author

Sounds good. We need a volunteer to implement that :)

@jklynch
Copy link
Contributor

jklynch commented Aug 4, 2020

cli = pymongo.MongoClient("xf11id-ca") 

@mrakitin
Copy link
Member Author

mrakitin commented Aug 4, 2020

That's easy. I wonder if we can still get it consistently from db.v1 and db.v2...

@jklynch
Copy link
Contributor

jklynch commented Aug 4, 2020

I asked @danielballan and the short answer is "no".

@danielballan
Copy link
Contributor

We ended up rely on private API (db.v2._run_start_collection.database.client). @jklynch's approach might have been better though, so I have renamed this issue and I will leave it open as a reminder to change it.

@danielballan danielballan changed the title Compatibility with collection-2020-2.0rc6 Mongo client for Lutz's custom sample database Aug 25, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants