pcdshub / pcdshub/hutch-python

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

Open
#227 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
Python
Stars
1
Forks
18
Avg merge
7d 9h
Merged PRs (30d)
1

Description

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'}

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start from the proposed Python introspection approach and inspect how beamline globals and happi-backed devices are loaded. The tool should identify non-happi ophyd.Device aliases and report each class plus constructor parameters, including positional and keyword arguments, for migration.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
tooling
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.