Skip to content

Validate enums - #169

Open
izkgao wants to merge 86 commits into
devfrom
zhenkai/157_validate_enums
Open

Validate enums#169
izkgao wants to merge 86 commits into
devfrom
zhenkai/157_validate_enums

Conversation

@izkgao

@izkgao izkgao commented Apr 30, 2026

Copy link
Copy Markdown
Contributor

Description

Closes #157.
Need frontend CARTAvis/carta-frontend#2759 to be merged first.

Adds enum snapshot checks to keep Python constants aligned with frontend/protobuf enums.

What is implemented

  • Align constants with frontend/protobuf enum snapshots and add private enum mismatch diagnostics with an opt-in live test.

How to test

  1. Build this frontend branch Add higher level functions for carta-python carta-frontend#2759 or after
  2. Launch CARTA with --enable_scripting
  3. Replace the url and session id below with yours.
CARTA_RUN_LIVE_ENUM_SNAPSHOTS=1 \
CARTA_FRONTEND_URL='http://127.0.0.1:3002' \
CARTA_SESSION_ID='1584862638' \
uv run pytest tests/live/test_live_enum_snapshots.py
  1. See only this error
    Because ANNULUS has not been implemented yet, we do not add it to RegionType in constants.py.
AssertionError: [{'missing_in_frontend': [], 'missing_in_python': [{'frontend_name': 'ANNULUS', 'frontend_value': 5}], 'name': 'RegionType', 'source': 'protobuf:RegionType', ...}]
assert [{'missing_in...onType', ...}] == []

izkgao added 30 commits April 30, 2025 16:38
…or coordinate system and number format methods
…ces for consistency with documentation style
@izkgao izkgao added this to the v6-beta2 milestone Apr 30, 2026
@izkgao
izkgao requested review from confluence and kswang1029 April 30, 2026 05:09
@izkgao izkgao added awaiting code review For pull requests that require code review awaiting testing For pull requests that require testing blocked For issues/PRs that are blocked, either by other issues/PRs, or by external dependencies labels Apr 30, 2026
@izkgao
izkgao marked this pull request as ready for review April 30, 2026 05:12
@izkgao izkgao assigned confluence and unassigned kswang1029 Aug 18, 2026

@confluence confluence left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I'm going to wait until the other PRs have been resolved before doing a final review, but I have an alternative suggestion for specifying the links to protobuf and frontend enums:

  • Create mix-in classes called FrontendEnum and ProtobufEnum.
  • For each of these, implement a registration mechanism for subclasses (similar to the region and view mechanism), which:
    • Checks the subclass for an optional snapshot_name class attribute (maybe this should be called something like external_name or reference_name -- and it should probably be in all caps for style consistency)
    • Updates a class dict that maps snapshot names to enum subclasses (if no custom snapshot_name is provided, the name of the class is used by default)
  • Make each class that is linked to a frontend or protobuf enum inherit one of these mixins.

Now by default enums won't be linked to anything, and you can access the mappings of the mixins to get the lists of frontend- and protobuf-linked enums (instead of having to tag every enum and parse them all manually), and you don't have to provide external names explicitly unless the class name is different.

@izkgao izkgao removed the blocked For issues/PRs that are blocked, either by other issues/PRs, or by external dependencies label Aug 18, 2026
@izkgao

izkgao commented Aug 18, 2026

Copy link
Copy Markdown
Contributor Author

I removed the unrelated code changes from zhenkai/check_version branch so it can be reviewed independently.

@izkgao izkgao added awaiting code changes For pull requests that require code changes and removed awaiting code review For pull requests that require code review awaiting testing For pull requests that require testing labels Aug 19, 2026
@izkgao

izkgao commented Aug 19, 2026

Copy link
Copy Markdown
Contributor Author

I found that it would be better to make it work without launching CARTA. I will make a script in frontend to generate a list of enum and use it for validation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting code changes For pull requests that require code changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Revise colormap code

3 participants