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

DM-46165: Removed optical configuration from enums #56

Open
wants to merge 5 commits into
base: develop
Choose a base branch
from

Conversation

parfa30
Copy link
Contributor

@parfa30 parfa30 commented Sep 6, 2024

This is related to lsst-ts/ts_xml#904, where we added this to the XML Enums

Copy link
Member

@tribeiro tribeiro left a comment

Choose a reason for hiding this comment

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

I think this looks mostly ok. I do have one thing I hope you will reconsider before merging. Instead of duplicating the enumeration definition all over the place, continue to use it from the package enums.py module (optionally re-exporting from ts-xml when it is available) and just add a note to remove it from there later.

@@ -46,7 +46,7 @@
type: number
optical_configuration:
description: The mirror alignment configuration for the laser
enum: ["SCU","No SCU","F1 SCU","F1 No SCU","F2 SCU","F2 No SCU"]
enum: ["SCU","F1 SCU","F2 SCU","No SCU","F1 No SCU","F2 No SCU"]
Copy link
Member

Choose a reason for hiding this comment

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

Consider making this dynamic by using the enumeration to generate the valid entries:, e.g.;

CONFIG_SCHEMA = yaml.safe_load(
    f"""
    ...
    enum: {[e.value for e in OpticalConfiguration]}
    ...
    """

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In order to do this, I'd have to import OpticalConfiguration. Does that work in config_schema?

from .register import AsciiRegister

try:
Copy link
Member

Choose a reason for hiding this comment

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

you are doing this in multiple places, defining the same enumeration, and you are then removing the enum from the enums.py module.

Consider leaving this alone and just adding a "TODO" in the enums.py module to replace the enumeration with the one from ts-xml once that becomes available.

from lsst.ts.xml.enums import TunableLaser
from lsst.ts.xml.enums.TunableLaser import LaserDetailedState, LaserErrorCode

try:
Copy link
Member

Choose a reason for hiding this comment

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

See my comment above about this.

@@ -31,20 +31,3 @@ class Output(enum.StrEnum):
"""A calibration energy level where the energy level adjusts."""
MAX = "MAX"
"""Maximum energy level for the laser."""


class OpticalConfiguration(enum.StrEnum):
Copy link
Member

Choose a reason for hiding this comment

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

I suggest you leave this alone for now and just add a note here to remove this enum and use the one from ts-xml once that is available. The way you are going about this is a bit awkward.

If you want to automatically switch the ts-xml once it is available, you can re-export it from here adding the try/except you included in the other files here and leaving the OpticalConfiguration entry in the __all__ list above.


# TODO: (DM-46168) Revert workaround for TunableLaser XML changes
try:
from lsst.ts.xml.enums.TunableLaser import OpticalConfiguration
Copy link
Member

Choose a reason for hiding this comment

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

See my note about this above. Just continue doing what you are doing now and replace the enum once it is available in ts-xml.

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.

2 participants