-
Notifications
You must be signed in to change notification settings - Fork 0
feat: implement deposition upload workflow with semantics domain #62
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,108 @@ | ||
| """add_deposition_tables | ||
|
|
||
| Add ontologies, ontology_terms, schemas, conventions tables. | ||
| Alter depositions: add convention_srn, drop provenance. | ||
|
|
||
| Revision ID: add_deposition_tables | ||
| Revises: add_authorization | ||
| Create Date: 2026-02-08 | ||
|
|
||
| """ | ||
|
|
||
| from typing import Sequence, Union | ||
|
|
||
| import sqlalchemy as sa | ||
| from alembic import op | ||
|
|
||
| # revision identifiers, used by Alembic. | ||
| revision: str = "add_deposition_tables" | ||
| down_revision: Union[str, Sequence[str], None] = "add_authorization" | ||
| branch_labels: Union[str, Sequence[str], None] = None | ||
| depends_on: Union[str, Sequence[str], None] = None | ||
|
|
||
|
|
||
| def upgrade() -> None: | ||
| """Add semantics/convention tables and update depositions.""" | ||
| # ONTOLOGIES | ||
| op.create_table( | ||
| "ontologies", | ||
| sa.Column("srn", sa.String(), nullable=False), | ||
| sa.Column("title", sa.String(255), nullable=False), | ||
| sa.Column("description", sa.Text(), nullable=True), | ||
| sa.Column("created_at", sa.DateTime(timezone=True), nullable=False), | ||
| sa.PrimaryKeyConstraint("srn"), | ||
| ) | ||
|
|
||
| # ONTOLOGY TERMS | ||
| op.create_table( | ||
| "ontology_terms", | ||
| sa.Column("id", sa.String(), nullable=False), | ||
| sa.Column("ontology_srn", sa.String(), nullable=False), | ||
| sa.Column("term_id", sa.String(255), nullable=False), | ||
| sa.Column("label", sa.String(255), nullable=False), | ||
| sa.Column("synonyms", sa.JSON(), nullable=False), | ||
| sa.Column("parent_ids", sa.JSON(), nullable=False), | ||
| sa.Column("definition", sa.Text(), nullable=True), | ||
| sa.Column("deprecated", sa.Boolean(), nullable=False, server_default="false"), | ||
| sa.PrimaryKeyConstraint("id"), | ||
| sa.ForeignKeyConstraint( | ||
| ["ontology_srn"], | ||
| ["ontologies.srn"], | ||
| ondelete="CASCADE", | ||
| ), | ||
| sa.UniqueConstraint("ontology_srn", "term_id", name="uq_ontology_term"), | ||
| ) | ||
| op.create_index("idx_ontology_terms_ontology_srn", "ontology_terms", ["ontology_srn"]) | ||
|
|
||
| # SCHEMAS | ||
| op.create_table( | ||
| "schemas", | ||
| sa.Column("srn", sa.String(), nullable=False), | ||
| sa.Column("title", sa.String(255), nullable=False), | ||
| sa.Column("fields", sa.JSON(), nullable=False), | ||
| sa.Column("created_at", sa.DateTime(timezone=True), nullable=False), | ||
| sa.PrimaryKeyConstraint("srn"), | ||
| ) | ||
|
|
||
| # CONVENTIONS | ||
| op.create_table( | ||
| "conventions", | ||
| sa.Column("srn", sa.String(), nullable=False), | ||
| sa.Column("title", sa.String(255), nullable=False), | ||
| sa.Column("description", sa.Text(), nullable=True), | ||
| sa.Column("schema_srn", sa.String(), nullable=False), | ||
| sa.Column("file_requirements", sa.JSON(), nullable=False), | ||
| sa.Column("validator_refs", sa.JSON(), nullable=False), | ||
| sa.Column("created_at", sa.DateTime(timezone=True), nullable=False), | ||
| sa.PrimaryKeyConstraint("srn"), | ||
| ) | ||
|
|
||
| # ALTER DEPOSITIONS: add convention_srn, drop provenance | ||
| op.add_column( | ||
| "depositions", | ||
| sa.Column("convention_srn", sa.String(), nullable=False), | ||
| ) | ||
| op.drop_column("depositions", "provenance") | ||
|
|
||
|
|
||
| def downgrade() -> None: | ||
| """Reverse: restore depositions, drop new tables.""" | ||
| # DEPOSITIONS: re-add provenance, drop convention_srn | ||
| op.add_column( | ||
| "depositions", | ||
| sa.Column("provenance", sa.JSON(), nullable=False, server_default="{}"), | ||
| ) | ||
| op.drop_column("depositions", "convention_srn") | ||
|
|
||
| # CONVENTIONS | ||
| op.drop_table("conventions") | ||
|
|
||
| # SCHEMAS | ||
| op.drop_table("schemas") | ||
|
|
||
| # ONTOLOGY TERMS | ||
| op.drop_index("idx_ontology_terms_ontology_srn", table_name="ontology_terms") | ||
| op.drop_table("ontology_terms") | ||
|
|
||
| # ONTOLOGIES | ||
| op.drop_table("ontologies") | ||
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,82 @@ | ||
| { | ||
| "graphs": [ | ||
| { | ||
| "id": "http://purl.obolibrary.org/obo/osa/biological-sex.owl", | ||
| "lbl": "Biological Sex", | ||
| "meta": { | ||
| "version": "1.0.0", | ||
| "definition": { | ||
| "val": "An ontology of biological sex categories for scientific data annotation." | ||
| } | ||
| }, | ||
| "nodes": [ | ||
| { | ||
| "id": "OSAO:0000001", | ||
| "lbl": "biological sex", | ||
| "type": "CLASS", | ||
| "meta": { | ||
| "definition": { | ||
| "val": "The biological sex of an organism, determined by chromosomal, gonadal, and anatomical characteristics." | ||
| } | ||
| } | ||
| }, | ||
| { | ||
| "id": "OSAO:0000002", | ||
| "lbl": "female", | ||
| "type": "CLASS", | ||
| "meta": { | ||
| "definition": { | ||
| "val": "An organism that produces ova or has XX sex chromosomes." | ||
| }, | ||
| "synonyms": [ | ||
| { "val": "F" } | ||
| ] | ||
| } | ||
| }, | ||
| { | ||
| "id": "OSAO:0000003", | ||
| "lbl": "male", | ||
| "type": "CLASS", | ||
| "meta": { | ||
| "definition": { | ||
| "val": "An organism that produces spermatozoa or has XY sex chromosomes." | ||
| }, | ||
| "synonyms": [ | ||
| { "val": "M" } | ||
| ] | ||
| } | ||
| }, | ||
| { | ||
| "id": "OSAO:0000004", | ||
| "lbl": "intersex", | ||
| "type": "CLASS", | ||
| "meta": { | ||
| "definition": { | ||
| "val": "An organism with sex characteristics that do not fit typical definitions of male or female." | ||
| } | ||
| } | ||
| }, | ||
| { | ||
| "id": "OSAO:0000005", | ||
| "lbl": "unknown sex", | ||
| "type": "CLASS", | ||
| "meta": { | ||
| "definition": { | ||
| "val": "The biological sex of the organism has not been determined." | ||
| }, | ||
| "synonyms": [ | ||
| { "val": "undetermined" }, | ||
| { "val": "not recorded" } | ||
| ] | ||
| } | ||
| } | ||
| ], | ||
| "edges": [ | ||
| { "sub": "OSAO:0000002", "pred": "is_a", "obj": "OSAO:0000001" }, | ||
| { "sub": "OSAO:0000003", "pred": "is_a", "obj": "OSAO:0000001" }, | ||
| { "sub": "OSAO:0000004", "pred": "is_a", "obj": "OSAO:0000001" }, | ||
| { "sub": "OSAO:0000005", "pred": "is_a", "obj": "OSAO:0000001" } | ||
| ] | ||
| } | ||
| ] | ||
| } |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,122 @@ | ||
| { | ||
| "graphs": [ | ||
| { | ||
| "id": "http://purl.obolibrary.org/obo/osa/license.owl", | ||
| "lbl": "License", | ||
| "meta": { | ||
| "version": "1.0.0", | ||
| "definition": { | ||
| "val": "An ontology of common open-access and open-source license types for scientific data." | ||
| } | ||
| }, | ||
| "nodes": [ | ||
| { | ||
| "id": "OSAO:1000001", | ||
| "lbl": "license", | ||
| "type": "CLASS", | ||
| "meta": { | ||
| "definition": { | ||
| "val": "A legal instrument governing the use and redistribution of a creative work or dataset." | ||
| } | ||
| } | ||
| }, | ||
| { | ||
| "id": "OSAO:1000002", | ||
| "lbl": "CC0 1.0", | ||
| "type": "CLASS", | ||
| "meta": { | ||
| "definition": { | ||
| "val": "Creative Commons Zero v1.0 Universal — public domain dedication." | ||
| }, | ||
| "synonyms": [ | ||
| { "val": "CC0" }, | ||
| { "val": "Public Domain" } | ||
| ], | ||
| "xrefs": [ | ||
| { "val": "SPDX:CC0-1.0" } | ||
| ] | ||
| } | ||
| }, | ||
| { | ||
| "id": "OSAO:1000003", | ||
| "lbl": "CC BY 4.0", | ||
| "type": "CLASS", | ||
| "meta": { | ||
| "definition": { | ||
| "val": "Creative Commons Attribution 4.0 International — requires attribution." | ||
| }, | ||
| "synonyms": [ | ||
| { "val": "CC-BY" } | ||
| ], | ||
| "xrefs": [ | ||
| { "val": "SPDX:CC-BY-4.0" } | ||
| ] | ||
| } | ||
| }, | ||
| { | ||
| "id": "OSAO:1000004", | ||
| "lbl": "CC BY-SA 4.0", | ||
| "type": "CLASS", | ||
| "meta": { | ||
| "definition": { | ||
| "val": "Creative Commons Attribution-ShareAlike 4.0 International — requires attribution and share-alike." | ||
| }, | ||
| "xrefs": [ | ||
| { "val": "SPDX:CC-BY-SA-4.0" } | ||
| ] | ||
| } | ||
| }, | ||
| { | ||
| "id": "OSAO:1000005", | ||
| "lbl": "CC BY-NC 4.0", | ||
| "type": "CLASS", | ||
| "meta": { | ||
| "definition": { | ||
| "val": "Creative Commons Attribution-NonCommercial 4.0 International — requires attribution, non-commercial use." | ||
| }, | ||
| "xrefs": [ | ||
| { "val": "SPDX:CC-BY-NC-4.0" } | ||
| ] | ||
| } | ||
| }, | ||
| { | ||
| "id": "OSAO:1000006", | ||
| "lbl": "CC BY-NC-SA 4.0", | ||
| "type": "CLASS", | ||
| "meta": { | ||
| "definition": { | ||
| "val": "Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International." | ||
| }, | ||
| "xrefs": [ | ||
| { "val": "SPDX:CC-BY-NC-SA-4.0" } | ||
| ] | ||
| } | ||
| }, | ||
| { | ||
| "id": "OSAO:1000007", | ||
| "lbl": "MIT License", | ||
| "type": "CLASS", | ||
| "meta": { | ||
| "definition": { | ||
| "val": "A permissive open-source license with minimal restrictions on reuse." | ||
| }, | ||
| "synonyms": [ | ||
| { "val": "MIT" } | ||
| ], | ||
| "xrefs": [ | ||
| { "val": "SPDX:MIT" } | ||
| ] | ||
| } | ||
| } | ||
| ], | ||
| "edges": [ | ||
| { "sub": "OSAO:1000002", "pred": "is_a", "obj": "OSAO:1000001" }, | ||
| { "sub": "OSAO:1000003", "pred": "is_a", "obj": "OSAO:1000001" }, | ||
| { "sub": "OSAO:1000004", "pred": "is_a", "obj": "OSAO:1000001" }, | ||
| { "sub": "OSAO:1000005", "pred": "is_a", "obj": "OSAO:1000001" }, | ||
| { "sub": "OSAO:1000006", "pred": "is_a", "obj": "OSAO:1000001" }, | ||
| { "sub": "OSAO:1000007", "pred": "is_a", "obj": "OSAO:1000001" } | ||
| ] | ||
| } | ||
| ] | ||
| } |
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
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Migration/table definition nullability mismatch
The migration adds
convention_srnasnullable=True, but the SQLAlchemy table definition intables.py:29declares it asnullable=False, and the domain model requiresconvention_srnas a mandatory field onDeposition. This mismatch means:convention_srnvalue to satisfy the constraintIf this runs against a database with existing depositions, the
ALTER TABLE ADD COLUMNwithnullable=Truewill succeed, but those rows will haveNULLforconvention_srn, which will cause errors when the ORM tries to load them. The migration should either set aserver_defaultor include a data migration step for existing rows, then alter toNOT NULL.