Skip to content

Refactor Cluster Materials nested lists into table schemas - #2153

Open
RajbanulAkhond wants to merge 1 commit into
materialsproject:masterfrom
RajbanulAkhond:cluster-materials-table-schemas
Open

Refactor Cluster Materials nested lists into table schemas#2153
RajbanulAkhond wants to merge 1 commit into
materialsproject:masterfrom
RajbanulAkhond:cluster-materials-table-schemas

Conversation

@RajbanulAkhond

Copy link
Copy Markdown
Contributor

Summary

This follow-up to #2142 implements the table-based representation discussed after the initial Cluster Materials schema was merged.

  • add Cluster in cluster.py for the clusters table
  • add ClusterPointGroup in cluster_point_group.py for the clusterPointGroups table
  • remove the nested clusters and clusterPointGroups fields from ClusterMaterial
  • represent Cluster.elements, FlatBandProperties.latticeDimensionalities, and FlatBandProperties.latticeIds as validated comma-separated strings
  • document Cluster.averageDistance explicitly in angstroms
  • retain the polar, piezoelectric, enantiomorphic, and Battery Explorer membership fields without duplicating Materials Project or Battery Explorer properties
  • retain the flat-band citation to Neves et al. (2024), DOI 10.1038/s41524-024-01220-x

During submission, each contribution will contain the main ClusterMaterial data and two named pandas DataFrames: clusters and clusterPointGroups. 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

  • all 5,306 source records validated
  • 8,891 clusters rows validated
  • 7,464 clusterPointGroups rows validated
  • 21 upstream Lux Arrow-compatibility tests passed
  • Black, Pydocstyle, Mypy, and repository-aligned lint checks passed

No data files or upload tooling are included in this pull request.

Copilot AI lite review requested due to automatic review settings September 10, 2026 01:54

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 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 (for clusters) and ClusterPointGroup (for clusterPointGroups).
  • Updates FlatBandProperties to store latticeDimensionalities and latticeIds as 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
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