NSLS-II / nslsii

NSLS-II related devices
BSD 3-Clause "New" or "Revised" License
11 stars 22 forks source link

Added a check for RE in ns #16

Closed jrmlhermitte closed 6 years ago

jrmlhermitte commented 6 years ago

Allows user to define custom RE in namespace. Works as:

RE = MyCustomRunEngine()
nslsii.configure_base(get_ipython().user_ns, db)

other alternative is (which is not supported by this PR here)

RE= MyCustomRunEngine()
nslsii.configure_base(get_ipython().user_ns, db, RE=RE)

what do you think?

Use case: this is the custom run engine from LIX (they check that a user name and proposal id exist, and prompt user (with login()) if false):

class CustomRunEngine(RunEngine):
    def __call__(self, *args, **kwargs):
        global username
        global proposal_id
        global run_id

        if username is None or proposal_id is None or run_id is None:
            login()

        return super().__call__(*args, **kwargs)

RE = CustomRunEngine()
#gs.RE = RE
jrmlhermitte commented 6 years ago

sounds good. @danielballan what do you think?