Skip to content

Commit 0943fb7

Browse files
committed
Upgrade to nmdc-submission-schema v11.10.0-rc.1
1 parent 67cdd93 commit 0943fb7

File tree

3 files changed

+105
-13
lines changed

3 files changed

+105
-13
lines changed
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
"""Update JGI submission-schema slot names
2+
3+
Revision ID: 0cb677fa8d5e
4+
Revises: e27443f0837e
5+
Create Date: 2025-08-06 19:53:09.430148
6+
7+
"""
8+
9+
from typing import Optional
10+
from uuid import uuid4
11+
12+
from alembic import op
13+
from sqlalchemy import Column, orm
14+
from sqlalchemy.dialects.postgresql import JSONB, UUID
15+
from sqlalchemy.ext.declarative import declarative_base
16+
17+
# revision identifiers, used by Alembic.
18+
revision: str = "0cb677fa8d5e"
19+
down_revision: Optional[str] = "e27443f0837e"
20+
branch_labels: Optional[str] = None
21+
depends_on: Optional[str] = None
22+
23+
24+
Base = declarative_base()
25+
26+
27+
class SubmissionMetadata(Base):
28+
__tablename__ = "submission_metadata"
29+
30+
id = Column(UUID(as_uuid=True), primary_key=True, default=uuid4)
31+
metadata_submission = Column(JSONB, nullable=False)
32+
33+
34+
RENAMED_SLOTS = [
35+
# ( old name, new name )
36+
("dna_absorb1", "nuc_acid_absorb1"),
37+
("rna_absorb1", "nuc_acid_absorb1"),
38+
("dna_absorb2", "nuc_acid_absorb2"),
39+
("rna_absorb2", "nuc_acid_absorb2"),
40+
("dna_concentration", "nuc_acid_concentration"),
41+
("rna_concentration", "nuc_acid_concentration"),
42+
("dna_cont_type", "cont_type"),
43+
("rna_cont_type", "cont_type"),
44+
("dna_cont_well", "cont_well"),
45+
("rna_cont_well", "cont_well"),
46+
("dna_container_id", "container_name"),
47+
("rna_container_id", "container_name"),
48+
("dna_dnase", "dnase"),
49+
("dnase_rna", "dnase"),
50+
("dna_samp_id", "jgi_samp_id"),
51+
("rna_samp_id", "jgi_samp_id"),
52+
("dna_sample_format", "jgi_sample_format"),
53+
("rna_sample_format", "jgi_sample_format"),
54+
("dna_sample_name", "jgi_sample_name"),
55+
("rna_sample_name", "jgi_sample_name"),
56+
("dna_seq_project", "jgi_seq_project"),
57+
("rna_seq_project", "jgi_seq_project"),
58+
("dna_seq_project_name", "jgi_seq_project_name"),
59+
("rna_seq_project_name", "jgi_seq_project_name"),
60+
("dna_volume", "jgi_sample_volume"),
61+
("rna_volume", "jgi_sample_volume"),
62+
]
63+
64+
65+
def do_rename(mapping: dict[str, str]):
66+
session = orm.Session(bind=op.get_bind())
67+
mappings = []
68+
for submission_metadata in session.query(SubmissionMetadata):
69+
metadata_submission = submission_metadata.metadata_submission
70+
71+
if isinstance(metadata_submission, list):
72+
continue
73+
74+
sample_data = metadata_submission.get("sampleData")
75+
76+
if sample_data is None or not isinstance(sample_data, dict):
77+
print(f"WARNING: sampleData not in migratable format for {submission_metadata.id}")
78+
continue
79+
80+
for tab, rows in sample_data.items():
81+
if not isinstance(rows, list):
82+
continue
83+
for row in rows:
84+
if not isinstance(row, dict):
85+
continue
86+
for old_key, new_key in mapping.items():
87+
if old_key in row:
88+
row[new_key] = row.pop(old_key)
89+
90+
mappings.append({"id": submission_metadata.id, "metadata_submission": metadata_submission})
91+
92+
session.bulk_update_mappings(SubmissionMetadata, mappings)
93+
session.commit()
94+
95+
96+
def upgrade():
97+
do_rename({old: new for old, new in RENAMED_SLOTS})
98+
99+
100+
def downgrade():
101+
do_rename({new: old for old, new in RENAMED_SLOTS})

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ dependencies = [
9797
"mypy==1.11.2",
9898
"mypy-extensions==1.0.0",
9999
"nmdc-schema==11.9.1",
100-
"nmdc-submission-schema==11.9.1",
100+
"nmdc-submission-schema==11.10.0-rc.1",
101101
"nmdc-geoloc-tools==0.2.0",
102102
"openpyxl==3.1.5",
103103
"packaging==24.1",

web/src/views/SubmissionPortal/HarmonizerView.vue

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -92,18 +92,9 @@ const TYPE_FIELD = ANALYSIS_TYPE;
9292
const COMMON_COLUMNS = [SAMP_NAME, SOURCE_MAT_ID, ANALYSIS_TYPE];
9393
9494
const ALWAYS_READ_ONLY_COLUMNS = [
95-
'dna_seq_project',
96-
'rna_seq_project',
97-
'dna_samp_id',
98-
'rna_samp_id',
99-
'rna_seq_project_pi',
100-
'dna_seq_project_pi',
101-
'dna_project_contact',
102-
'rna_project_contact',
103-
'proposal_rna',
104-
'proposal_dna',
105-
'rna_seq_project_name',
106-
'dna_seq_project_name',
95+
'jgi_seq_project',
96+
'jgi_samp_id',
97+
'jgi_seq_project_name',
10798
];
10899
109100
export default defineComponent({

0 commit comments

Comments
 (0)