Skip to content

happi transfer does not handle list types well #268

@tangkong

Description

@tangkong

Expected Behavior

When entering information expected to be a list (say a list of strings), we should properly parse the input as a list of items, rather than just a list of single characters.

Current Behavior

While LightpathItem doesn't exist yet, suffice it to say input_branches and output_branches expect a list.

happi transfer at2l0 lightpath.happi.containers.LightpathItem

Include entry from at2l0: system = "None"? [Y/n]: 
LightpathItem expects information for entry "input_branches" [take default: None]: ['K0']
LightpathItem expects information for entry "output_branches" [take default: None]: "['K0']"

----------Amend Entries-----------
+--------------------+-------------------------------------------+
| EntryInfo          | Value                                     |
+--------------------+-------------------------------------------+
| active             | True                                      |
| args               | ['{{prefix}}']                            |
| beamline           | LFE                                       |
| detailed_screen    | None                                      |
| device_class       | pcdsdevices.attenuator.FEESolidAttenuator |
| documentation      | None                                      |
| embedded_screen    | None                                      |
| engineering_screen | None                                      |
| functional_group   | Attenuator                                |
| input_branches     | ['[', "'", 'K', '0', "'", ']']            |
| ioc_arch           | None                                      |
| ioc_engineer       | None                                      |
| ioc_hutch          | None                                      |
| ioc_location       | None                                      |
| ioc_name           | None                                      |
| ioc_release        | None                                      |
| ioc_type           | None                                      |
| kwargs             | {'name': '{{name}}'}                      |
| lightpath          | True                                      |
| location_group     | Front End Enclosure                       |
| macros             | None                                      |
| name               | at2l0                                     |
| output_branches    | ['"', '[', "'", 'K', '0', "'", ']', '"']  |
| parent             | None                                      |
| prefix             | AT2L0:XTES                                |
| stand              | L0S07                                     |
| system             | None                                      |
| z                  | 734.50000                                 |
+--------------------+-------------------------------------------+
Save final device? [y/N]: N

Possible Solution

Maybe use happi.prompt.prompt_for_entry as in happi add, since that parses lists with ast.literal_eval and dicts in a more robust way.

Steps to Reproduce (for bugs)

See "current behavior" section

Context

Prevents actual use of this tool in real situations

Your Environment

pcds-5.4.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    CLICommand-line interface

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions