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

ENH: Add device descriptions #124

Closed
wants to merge 6 commits into from
Closed

Conversation

tangkong
Copy link
Contributor

@tangkong tangkong commented Jul 7, 2023

Description

Adds a device description field that saves information to the toolbar yaml file.

I'll admit I kinda hacked things together here but I'd procrastinated on this long enough

To-do:

  • Add a menu to the single device IndicatorCells
  • fix the test suite?...

Context

https://jira.slac.stanford.edu/browse/ECS-1039

Screenshots

image

@tangkong tangkong marked this pull request as ready for review July 7, 2023 19:41
@tangkong tangkong requested review from klauer and ZLLentz and removed request for klauer July 7, 2023 19:41
@ZLLentz
Copy link
Member

ZLLentz commented Jul 7, 2023

from the jira ticket:

I think it will be very helpful to have a comment/editable box (with date information) right next to each motor so we can put some information right next to it

It seems like this is implemented per device, where a device may be composed of many motors.

I bring this up because TMO probably wants to annotate their motors on their IP1 endstations:
image

So if this is the way to go then we need to adjust how TMO is represented in happi

Copy link
Member

@ZLLentz ZLLentz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few bigger picture thoughts, I think the result looks good.

from qtpy.QtWidgets import QGridLayout, QMenu, QPushButton, QWidget
from qtpy.QtWidgets import (QGridLayout, QHBoxLayout, QLineEdit, QMenu,
QPushButton, QWidget, QWidgetAction)
from ruamel.yaml import YAML
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we consolidate all yaml parsing to use ruamel in a future PR? It's kind of strange to use two different libraries for the same thing.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ruamel is only really necessary for writing the file, if we want to preserve comments / spacing etc. For reading pyyaml is sufficient. It's probably good to be consistent but I thought it wasn't too important

config['DEVICE_HINTS'].pop(device_name, None)
else:
config['DEVICE_HINTS'][device_name] = device_desc
ryaml.dump(config, Path(fpath))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is the first time in lucid where the user config file is written back to by the program.
Could this create issues where someone is editing the user config file and someone else is setting descriptions? Maybe.
I think we should consider using a second file for this sort of extra data.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Putting it all in the same file is probably the easy way out. I suppose the case where multiple lucid's are open at the same time will hit upon this rather quickly.

This reminds me of the issue we had in happi where a crash interrupts writing and wipes the file. I should do the write-new-file -> copy over sequence we implemented there.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To me, this feels qualitatively different to happi which has a cli tool for editing the file, whereas in this project the user is expected to edit the file themselves.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I commented on the typhos PR before making it back to this one... Separating the files makes sense.
Backing up a step, though...

You mention happi, @ZLLentz, did you guys discuss about putting these notes directly into the database? It seems sensible to have shared notes in a database to me. Or is it like different hutches should have different notes about a shared beamline component or something?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that happi could become a source for notes, but at a lower priority (shadowed by local or env var notes). This is precisely for the reason you mentioned; different hutches might be looking at the same beamline component and have different notes, and I wouldn't want them to clobber each other.

The other wrinkle is that happi makes sense for top-level device information, but storing component level notes in happi might get a bit messy (though not completely unreasonable).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel like we've talked about storing extra data in happi as a go-to per-device data source a bunch of times in many contexts, which makes me think that it's worth doing. It might even be worth storing subdevice notes along with the device notes, I'm not sure? It's not immediately clear to me and warrants some discussion and mock-ups.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a lot of sources of notes and documentation... Off the top of my head, correct me if I'm wrong:

  1. LUCID config file 1 - env var notes
  2. LUCID config file 2 - local notes
  3. typhos config file 1 - env var notes
  4. typhos config file 2 - local notes
  5. happi database
  6. confluence - PCDS
  7. confluence - mechanical team / hutch team / etc
  8. FRS / ESD / ...
  9. Design review slides...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To some extent the Typhos PR could supercede this one, or at least LUCID/Typhos could use the same files. (so maybe that simplifies things slightly)

Adding yet another source of documentation that can fall out of date leaves a slightly bitter after taste, but I could argue it fills a slightly different niche

@@ -7,4 +7,5 @@ pyqt5>=5
pyqtads
pyyaml
qtpy
ruamel.yaml
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unrelated: why are package names allowed to contain periods?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't like it either, but it's a pretty widely used package so it seems

@tangkong
Copy link
Contributor Author

tangkong commented Jul 7, 2023

I bring this up because TMO probably wants to annotate their motors on their > IP1 endstations

I see, that's a bit more involved then. If we wanted to add a description field to device components, that should probably target typhos/happi? I was thinking of the case where different hutches view the same device, and might want to have different descriptions. This would make storing those descriptions in happi a problem, as people collide.

Perhaps in the lucid-devices case, this isn't a common occurrence. I can follow up with MingFu to clarify

@ZLLentz
Copy link
Member

ZLLentz commented Jul 7, 2023

The other way we can handle this is to rework the TMO happi entries to have a separate entry for each of these endstation motors. I think some people might argue that this is better because it lets you open up the motors separately if needed.

@tangkong
Copy link
Contributor Author

superceded by pcdshub/typhos#557

@tangkong tangkong closed this Jul 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants