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

Tool to help determine which devices need to be added to happi #227

Open
klauer opened this issue Oct 2, 2020 · 0 comments
Open

Tool to help determine which devices need to be added to happi #227

klauer opened this issue Oct 2, 2020 · 0 comments

Comments

@klauer
Copy link
Contributor

klauer commented Oct 2, 2020

Expected Behavior

  • Give me a list of devices needed to be added to happi

Current Behavior

  • Beamline configuration has many devices that aren't in happi
  • Tool does not (?) exist to ease migration to happi

Possible Solution

Add tool, based on something like this:

import inspect
import ophyd

non_happi_devices = {
    alias_name: dev for alias_name, dev in globals().items()
    if isinstance(dev, ophyd.Device) and not hasattr(dev.root, 'md')
}

def info(alias, dev):
    cls = type(dev)
    print('Alias', alias)
    print('Class:', f'{cls.__module__}.{cls.__name__}')
    kwargs = {
        param_name: getattr(dev, param_name, param.default if param.default is not param.empty else 'TODO')
        for param_name, param in inspect.signature(type(dev)).parameters.items()
    }
    print('Kwargs:', kwargs)

for alias, dev in non_happi_devices.items():
    info(alias, dev)
    print()

Can show something like this (note args/kwargs erroneously not checked here):

Alias scan_pvs
Class: pcdsdaq.scan_vars.ScanVars
Kwargs: {'prefix': 'XCS:SCAN', 'name': 'scan_pvs', 'RE': 'TODO', 'i_start': 0, 'kwargs': 'TODO'}

Alias snd
Class: hxrsnd.sndsystem.SplitAndDelay
Kwargs: {'prefix': 'XCS:SND', 'name': 'snd', 'daq': <pcdsdaq.daq.Daq object at 0x7fd0d42cbda0>, 'RE': <bluesky.run_engine.RunEngine object at 0x7fd0d42d9e48>, 'args': 'TODO', 'kwargs': 'TODO'}

Alias seq
Class: pcdsdevices.sequencer.EventSequencer
Kwargs: {'prefix': 'ECS:SYS0:4', 'name': 'seq_4', 'monitor_attrs': ['current_step', 'play_count'], 'kwargs': 'TODO'}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants