Refactor Cluster Materials nested lists into table schemas - #2153
Open
RajbanulAkhond wants to merge 1 commit into
Open
Refactor Cluster Materials nested lists into table schemas#2153RajbanulAkhond wants to merge 1 commit into
RajbanulAkhond wants to merge 1 commit into
Conversation
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
A newly introduced validation constraint is likely too restrictive (dimensionalities max length), risking rejection of valid records as data scales.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
This PR refactors the Cluster Materials Lux schema to move previously nested clusters and clusterPointGroups lists into separate table-style schemas, while keeping ClusterMaterial as the “main record” model and shifting certain validations to an external submission builder.
Changes:
- Introduces new table row models:
Cluster(forclusters) andClusterPointGroup(forclusterPointGroups). - Updates
FlatBandPropertiesto storelatticeDimensionalitiesandlatticeIdsas validated comma-separated strings instead of lists. - Removes nested cluster structures and associated cross-field validators from
ClusterMaterial, updating field descriptions accordingly.
File summaries
| File | Description |
|---|---|
| mpcontribs-lux/mpcontribs/lux/projects/cluster_materials/schema.py | Removes nested cluster/point-group models, updates FlatBandProperties to comma-separated string fields, and adjusts ClusterMaterial fields/descriptions accordingly. |
| mpcontribs-lux/mpcontribs/lux/projects/cluster_materials/cluster.py | Adds a table-schema Cluster model with validation for comma-separated elements and cluster invariants. |
| mpcontribs-lux/mpcontribs/lux/projects/cluster_materials/cluster_point_group.py | Adds a table-schema ClusterPointGroup model for point-group table rows. |
| mpcontribs-lux/mpcontribs/lux/projects/cluster_materials/init.py | Re-exports new public models (Cluster, ClusterPointGroup) alongside ClusterMaterial and FlatBandProperties. |
Review details
- Files reviewed: 4/4 changed files
- Comments generated: 2
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+67
to
71
| CommaSeparatedDimensionalities = Annotated[ | ||
| str, | ||
| StringConstraints(pattern=r"^X\d+$", max_length=16), | ||
| StringConstraints(min_length=1, max_length=64), | ||
| AfterValidator(_validate_lattice_dimensionalities), | ||
| ] |
Comment on lines
+18
to
+26
| def _split_comma_separated(value: str, field_name: str) -> list[str]: | ||
| """Return canonical comma-separated values or raise a validation error.""" | ||
| values = value.split(",") | ||
| if any(not item or item != item.strip() for item in values): | ||
| raise ValueError( | ||
| f"{field_name} must contain nonempty values separated by commas " | ||
| "without spaces" | ||
| ) | ||
| return values |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This follow-up to #2142 implements the table-based representation discussed after the initial Cluster Materials schema was merged.
Clusterincluster.pyfor theclusterstableClusterPointGroupincluster_point_group.pyfor theclusterPointGroupstableclustersandclusterPointGroupsfields fromClusterMaterialCluster.elements,FlatBandProperties.latticeDimensionalities, andFlatBandProperties.latticeIdsas validated comma-separated stringsCluster.averageDistanceexplicitly in angstromsDuring submission, each contribution will contain the main
ClusterMaterialdata and two named pandas DataFrames:clustersandclusterPointGroups. Cross-component count, distance, and label checks are handled by the external submission builder because the table rows are no longer nested in the main model.Validation
clustersrows validatedclusterPointGroupsrows validatedNo data files or upload tooling are included in this pull request.