Skip to content

Contribution identifiers - #2116

Open
bfoley12 wants to merge 15 commits into
devfrom
contribution-identifiers
Open

Contribution identifiers#2116
bfoley12 wants to merge 15 commits into
devfrom
contribution-identifiers

Conversation

@bfoley12

@bfoley12 bfoley12 commented Jul 27, 2026

Copy link
Copy Markdown
Collaborator

Summary

Modified how Contributions are identified.

Previously:

  • Uniqueness was only sometimes guaranteed by {Contribution.project, Contribution.identifier} (identifier is a user-defined field - it can be random, but was often set to an mp-id) - only true when it's Project had Project.unique_identifiers == True
  • If Project.unique_identifiers == False, the only way to get a unique Contribution was by querying the Contribution._id, which is an ObjectId - very cumbersome

This branch:

  • Removed Contribution.identifier
  • Contributions are guaranteed to be identified uniquely by {project, material_id, chemical_system_id, formula, unique_value?, condition_key?}:
    • Contribution.project: unchanged, the project the contribution belongs to
    • Contribution.material_id: the mp-id of the material being studied
    • Contribution.chemical_system_id: the chemical system string
    • Contribution.formula: unchanged, the formula of the system
    • Contribution.unique_value: optional, but required in Contributions that are not uniquely identified by the previous fields. This is specified by the user as a Contribution.data field, then extracted by the server into unique_value, so we can define a MongoDB index on it
    • Contribution.condition_key: Added in anticipation of another branch that 'pivots' contributions when conditions are present. Not fully developed, but set as a harness to use later.
  • Added validation to identifier fields
    • material_id: must start with "mp-" and be followed by numbers or letters (matching MP- and AlphaId formats)
    • chemical_system_id: hyphen-delimited list of valid Elements
    • formula: NFKC normalized string of valid elements and numbers (trimming leading 0s)
  • Replaced Project.unique_identifiers with Project.unique_column to signal which Contribution.data field is the Contribution.unique_value.

bfoley12 added 15 commits July 27, 2026 10:01
…in the case that {project, material_id, chemical_system_id, formula} is not enough. Also added condition_key - logic implemented in another branch
…a < material_id - ie. a formula must be specified if a material_id is).
…e an update to the identity fields collides with a preexisting identity
…ppercase, second char lowercase, regardless of input

Previously FE, fE, and fe would not be valid. Now they all get coerced to Fe before element validation
…ogic, created contributionidentity as a subclass

New Identity subclasses have to specify fields where order matters (changing order leads to schema migrations)
@bfoley12
bfoley12 marked this pull request as ready for review August 14, 2026 00:04
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