Skip to content
New issue

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

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

Already on GitHub? # to your account

happi edit cannot edit extraneous data #262

Open
tangkong opened this issue Jun 8, 2022 · 0 comments
Open

happi edit cannot edit extraneous data #262

tangkong opened this issue Jun 8, 2022 · 0 comments
Labels
CLI Command-line interface

Comments

@tangkong
Copy link
Contributor

tangkong commented Jun 8, 2022

Expected Behavior

We should be able to edit all information on a given device.

Current Behavior

happi will throw key error if the field is not in ._info_attrs, though this will also fail if the enforce checks are skipped since extraneous information is not set as attributes of the item.

Possible Solution

If a field is not found as an attribute of the item in question (attributes generated from info_attrs), look to the extraneous dictionary and edit them there

Steps to Reproduce (for bugs)

(pcds-5.4.1)roberttk@psbuild-rhel7-01:~/devrepos/happi(master -)$ happi edit at2l0 creation='poop'
Traceback (most recent call last):
  File "/cds/group/pcds/pyps/conda/py39/envs/pcds-5.4.1/bin/happi", line 10, in <module>
    sys.exit(main())
  File "/cds/home/r/roberttk/devrepos/happi/happi/cli.py", line 389, in main
    happi_cli()
  File "/cds/group/pcds/pyps/conda/py39/envs/pcds-5.4.1/lib/python3.9/site-packages/click/core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
  File "/cds/group/pcds/pyps/conda/py39/envs/pcds-5.4.1/lib/python3.9/site-packages/click/core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "/cds/group/pcds/pyps/conda/py39/envs/pcds-5.4.1/lib/python3.9/site-packages/click/core.py", line 1657, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/cds/group/pcds/pyps/conda/py39/envs/pcds-5.4.1/lib/python3.9/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/cds/group/pcds/pyps/conda/py39/envs/pcds-5.4.1/lib/python3.9/site-packages/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "/cds/group/pcds/pyps/conda/py39/envs/pcds-5.4.1/lib/python3.9/site-packages/click/decorators.py", line 26, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/cds/home/r/roberttk/devrepos/happi/happi/cli.py", line 265, in edit
    if device._info_attrs[field].enforce in (dict, list):
KeyError: 'creation'

Context

In building tests for another PR, I found I could not edit data on a field that is not in info_attrs

Your Environment

pcds-5.4.1

@tangkong tangkong added the CLI Command-line interface label Jun 13, 2022
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
CLI Command-line interface
Projects
None yet
Development

No branches or pull requests

1 participant