Skip to content

PR-R3: Persist viewer representations in extras - #770

Open
cpignedoli wants to merge 1 commit into
feature/load-viewer-representations-from-extrasfrom
feature/persist-viewer-representations-in-extras
Open

PR-R3: Persist viewer representations in extras#770
cpignedoli wants to merge 1 commit into
feature/load-viewer-representations-from-extrasfrom
feature/persist-viewer-representations-in-extras

Conversation

@cpignedoli

@cpignedoli cpignedoli commented Jun 25, 2026

Copy link
Copy Markdown
Member

What

PR-R3 in the representation split. This is stacked on top of #769.

This PR adds the persistence side of viewer representations:

  • convert viewer representation arrays into JSON-safe masks;
  • store those masks in StructureData/CifData extras;
  • add a Store representations button for already-stored structures;
  • make Store in AiiDA persist representation masks when a structure is first stored;
  • keep standalone viewer Apply representations in sync with extras when the viewer has a stored node.

Why

Users can now change visualization styles without creating a new structure node. The geometry remains the same AiiDA node, while the mutable viewer state lives in extras.

Small defaulting fix

This PR also makes the StructureManagerWidget storage format selector explicitly default to StructureData when no node_class is passed.

Previously the RadioButtons widget relied on the first entry in SUPPORTED_DATA_FORMATS. That is implicit and can silently select the wrong storage type if the option order changes. The new logic keeps explicit caller choices unchanged, but falls back to StructureData for the default structure-manager path. This matters here because representation persistence is stored on the AiiDA node extras, so the node type must be the one the widget is actually intended to create.

Chain

Implemented with Codex.

Validation

python -m pytest tests/test_viewers.py tests/test_structures.py

Result: 37 passed, 24 warnings.

@codecov

codecov Bot commented Jun 25, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 85.71429% with 5 lines in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (feature/load-viewer-representations-from-extras@2ea5cd3). Learn more about missing BASE report.

Files with missing lines Patch % Lines
aiidalab_widgets_base/structures.py 80.95% 4 Missing ⚠️
aiidalab_widgets_base/viewers.py 92.85% 1 Missing ⚠️
Additional details and impacted files
@@                                Coverage Diff                                 @@
##             feature/load-viewer-representations-from-extras     #770   +/-   ##
==================================================================================
  Coverage                                                   ?   85.69%           
==================================================================================
  Files                                                      ?       18           
  Lines                                                      ?     3426           
  Branches                                                   ?        0           
==================================================================================
  Hits                                                       ?     2936           
  Misses                                                     ?      490           
  Partials                                                   ?        0           
Flag Coverage Δ
python-3.12 85.66% <85.71%> (?)
python-3.9 85.62% <85.71%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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.

1 participant