diff --git a/apiv2/database/migrations/versions/20241010_135050_autogenerated.py b/apiv2/database/migrations/versions/20241010_135050_autogenerated.py index 0d49a400..62034697 100644 --- a/apiv2/database/migrations/versions/20241010_135050_autogenerated.py +++ b/apiv2/database/migrations/versions/20241010_135050_autogenerated.py @@ -3,51 +3,32 @@ Create Date: 2024-10-10 17:50:56.183502 """ + import sqlalchemy as sa from alembic import op # revision identifiers, used by Alembic. -revision = '20241010_135050' -down_revision = '20241008_125739' +revision = "20241010_135050" +down_revision = "20241008_125739" branch_labels = None depends_on = None def upgrade() -> None: # ### commands auto generated by Alembic - please adjust! ### - op.alter_column('frame', 'deposition_id', - existing_type=sa.INTEGER(), - nullable=False) - op.alter_column('frame', 'run_id', - existing_type=sa.INTEGER(), - nullable=False) - op.alter_column('frame', 'raw_angle', - existing_type=sa.DOUBLE_PRECISION(precision=53), - nullable=True) - op.alter_column('frame', 'dose', - existing_type=sa.DOUBLE_PRECISION(precision=53), - nullable=True) - op.alter_column('gain_file', 'run_id', - existing_type=sa.INTEGER(), - nullable=False) + op.alter_column("frame", "deposition_id", existing_type=sa.INTEGER(), nullable=False) + op.alter_column("frame", "run_id", existing_type=sa.INTEGER(), nullable=False) + op.alter_column("frame", "raw_angle", existing_type=sa.DOUBLE_PRECISION(precision=53), nullable=True) + op.alter_column("frame", "dose", existing_type=sa.DOUBLE_PRECISION(precision=53), nullable=True) + op.alter_column("gain_file", "run_id", existing_type=sa.INTEGER(), nullable=False) # ### end Alembic commands ### def downgrade() -> None: # ### commands auto generated by Alembic - please adjust! ### - op.alter_column('gain_file', 'run_id', - existing_type=sa.INTEGER(), - nullable=True) - op.alter_column('frame', 'dose', - existing_type=sa.DOUBLE_PRECISION(precision=53), - nullable=False) - op.alter_column('frame', 'raw_angle', - existing_type=sa.DOUBLE_PRECISION(precision=53), - nullable=False) - op.alter_column('frame', 'run_id', - existing_type=sa.INTEGER(), - nullable=True) - op.alter_column('frame', 'deposition_id', - existing_type=sa.INTEGER(), - nullable=True) + op.alter_column("gain_file", "run_id", existing_type=sa.INTEGER(), nullable=True) + op.alter_column("frame", "dose", existing_type=sa.DOUBLE_PRECISION(precision=53), nullable=False) + op.alter_column("frame", "raw_angle", existing_type=sa.DOUBLE_PRECISION(precision=53), nullable=False) + op.alter_column("frame", "run_id", existing_type=sa.INTEGER(), nullable=True) + op.alter_column("frame", "deposition_id", existing_type=sa.INTEGER(), nullable=True) # ### end Alembic commands ### diff --git a/apiv2/database/migrations/versions/20241010_153240_autogenerated.py b/apiv2/database/migrations/versions/20241010_153240_autogenerated.py new file mode 100644 index 00000000..d564b1b8 --- /dev/null +++ b/apiv2/database/migrations/versions/20241010_153240_autogenerated.py @@ -0,0 +1,25 @@ +"""autogenerated + +Create Date: 2024-10-10 19:32:49.117152 + +""" +import sqlalchemy as sa +from alembic import op + +# revision identifiers, used by Alembic. +revision = '20241010_153240' +down_revision = '20241010_135050' +branch_labels = None +depends_on = None + + +def upgrade() -> None: + # ### commands auto generated by Alembic - please adjust! ### + op.drop_column('tomogram', 'is_standardized') + # ### end Alembic commands ### + + +def downgrade() -> None: + # ### commands auto generated by Alembic - please adjust! ### + op.add_column('tomogram', sa.Column('is_standardized', sa.BOOLEAN(), autoincrement=False, nullable=False)) + # ### end Alembic commands ### diff --git a/apiv2/database/models/tomogram.py b/apiv2/database/models/tomogram.py index 9f614acb..59b2c93c 100644 --- a/apiv2/database/models/tomogram.py +++ b/apiv2/database/models/tomogram.py @@ -89,7 +89,6 @@ class Tomogram(Base): tomogram_version: Mapped[float] = mapped_column(Float, nullable=True) processing_software: Mapped[str] = mapped_column(String, nullable=True) reconstruction_software: Mapped[str] = mapped_column(String, nullable=False) - is_standardized: Mapped[bool] = mapped_column(Boolean, nullable=False) is_portal_standard: Mapped[bool] = mapped_column(Boolean, nullable=True) is_author_submitted: Mapped[bool] = mapped_column(Boolean, nullable=True) is_visualization_default: Mapped[bool] = mapped_column(Boolean, nullable=True) diff --git a/apiv2/db_import/common/finders.py b/apiv2/db_import/common/finders.py index 0201cfad..1b725ad3 100644 --- a/apiv2/db_import/common/finders.py +++ b/apiv2/db_import/common/finders.py @@ -1,4 +1,3 @@ - import logging import re from abc import ABC, abstractmethod diff --git a/apiv2/db_import/importers/frame.py b/apiv2/db_import/importers/frame.py index ae0f1afc..cbc63c00 100644 --- a/apiv2/db_import/importers/frame.py +++ b/apiv2/db_import/importers/frame.py @@ -15,6 +15,7 @@ # s3_frame_path: str # https_frame_path: str + class FrameItem(ItemDBImporter): direct_mapped_fields = {} id_fields = ["run_id", "s3_frame_path"] diff --git a/apiv2/db_import/importers/gain.py b/apiv2/db_import/importers/gain.py index c24e0a1c..f6ef950f 100644 --- a/apiv2/db_import/importers/gain.py +++ b/apiv2/db_import/importers/gain.py @@ -10,6 +10,7 @@ # s3_file_path: str # https_file_path: str + class GainItem(ItemDBImporter): direct_mapped_fields = {} id_fields = ["run_id", "s3_file_path"] diff --git a/apiv2/db_import/tests/test_frame_import.py b/apiv2/db_import/tests/test_frame_import.py index 3c9f7a75..1fbeee87 100644 --- a/apiv2/db_import/tests/test_frame_import.py +++ b/apiv2/db_import/tests/test_frame_import.py @@ -27,12 +27,22 @@ def expected_frames(http_prefix: str) -> list[dict[str, Any]]: }, ] + @write_data def populate_existing_frames(session: sa.orm.Session) -> models.Frame: populate_run(session) - stale_frame = models.Frame(run_id=RUN1_ID, deposition_id = DEPOSITION_ID1, https_frame_path="STALE_FRAME", s3_frame_path="STALE_FRAME") + stale_frame = models.Frame( + run_id=RUN1_ID, deposition_id=DEPOSITION_ID1, https_frame_path="STALE_FRAME", s3_frame_path="STALE_FRAME", + ) session.add(stale_frame) - return models.Frame(id=333, run_id=RUN1_ID, deposition_id=DEPOSITION_ID1, s3_frame_path="s3://test-public-bucket/30001/RUN1/Frames/frame1", https_frame_path="https://foo.com/30001/RUN1/Frames/frame1") + return models.Frame( + id=333, + run_id=RUN1_ID, + deposition_id=DEPOSITION_ID1, + s3_frame_path="s3://test-public-bucket/30001/RUN1/Frames/frame1", + https_frame_path="https://foo.com/30001/RUN1/Frames/frame1", + ) + # Tests addition of new frames, and updating entries already existing in db def test_import_frames( @@ -45,7 +55,7 @@ def test_import_frames( sync_db_session.commit() actual = verify_dataset_import(import_frames=True) expected_iter = iter(expected_frames) - for run in [run for run in actual.runs if run.name == 'RUN1']: + for run in [run for run in actual.runs if run.name == "RUN1"]: assert len(run.frames) == 2 assert run.frames[0].id == 333 for frame in run.frames: diff --git a/apiv2/db_import/tests/test_gain_import.py b/apiv2/db_import/tests/test_gain_import.py index 0c149384..81fce049 100644 --- a/apiv2/db_import/tests/test_gain_import.py +++ b/apiv2/db_import/tests/test_gain_import.py @@ -26,12 +26,19 @@ def expected_gains(http_prefix: str) -> list[dict[str, Any]]: }, ] + @write_data def populate_existing_gains(session: sa.orm.Session) -> models.GainFile: populate_run(session) stale_frame = models.GainFile(run_id=RUN1_ID, https_file_path="STALE_FRAME", s3_file_path="STALE_FRAME") session.add(stale_frame) - return models.GainFile(id=333, run_id=RUN1_ID, s3_file_path="s3://test-public-bucket/30001/RUN1/Frames/run1_gain.mrc", https_file_path="meep") + return models.GainFile( + id=333, + run_id=RUN1_ID, + s3_file_path="s3://test-public-bucket/30001/RUN1/Frames/run1_gain.mrc", + https_file_path="meep", + ) + # Tests addition of new gains, and updating entries already existing in db, and cleanup of old gains. def test_import_gains( @@ -44,7 +51,7 @@ def test_import_gains( sync_db_session.commit() actual = verify_dataset_import(import_gains=True) expected_iter = iter(expected_gains) - for run in [run for run in actual.runs if run.name == 'RUN1']: + for run in [run for run in actual.runs if run.name == "RUN1"]: assert len(run.gain_files) == 2 assert run.gain_files[0].id == 333 for gain in run.gain_files: diff --git a/apiv2/graphql_api/helpers/tomogram.py b/apiv2/graphql_api/helpers/tomogram.py index 70cb84ea..05a5a7d9 100644 --- a/apiv2/graphql_api/helpers/tomogram.py +++ b/apiv2/graphql_api/helpers/tomogram.py @@ -59,7 +59,6 @@ class TomogramGroupByOptions: tomogram_version: Optional[float] = None processing_software: Optional[str] = None reconstruction_software: Optional[str] = None - is_standardized: Optional[bool] = None is_portal_standard: Optional[bool] = None is_author_submitted: Optional[bool] = None is_visualization_default: Optional[bool] = None diff --git a/apiv2/graphql_api/schema.graphql b/apiv2/graphql_api/schema.graphql index 27ffb3d2..94bd5bd7 100644 --- a/apiv2/graphql_api/schema.graphql +++ b/apiv2/graphql_api/schema.graphql @@ -4999,9 +4999,6 @@ type Tomogram implements EntityInterface & Node { """Name of software used for reconstruction""" reconstructionSoftware: String! - """whether this tomogram adheres to portal standards""" - isStandardized: Boolean! - """whether this tomogram adheres to portal standards""" isPortalStandard: Boolean @@ -5342,7 +5339,6 @@ enum TomogramCountColumns { tomogramVersion processingSoftware reconstructionSoftware - isStandardized isPortalStandard isAuthorSubmitted isVisualizationDefault @@ -5416,9 +5412,6 @@ input TomogramCreateInput { """Name of software used for reconstruction""" reconstructionSoftware: String! - """whether this tomogram adheres to portal standards""" - isStandardized: Boolean! - """whether this tomogram adheres to portal standards""" isPortalStandard: Boolean = null @@ -5522,7 +5515,6 @@ type TomogramGroupByOptions { tomogramVersion: Float processingSoftware: String reconstructionSoftware: String - isStandardized: Boolean isPortalStandard: Boolean isAuthorSubmitted: Boolean isVisualizationDefault: Boolean @@ -5606,7 +5598,6 @@ input TomogramOrderByClause { tomogramVersion: orderBy processingSoftware: orderBy reconstructionSoftware: orderBy - isStandardized: orderBy isPortalStandard: orderBy isAuthorSubmitted: orderBy isVisualizationDefault: orderBy @@ -5680,9 +5671,6 @@ input TomogramUpdateInput { """Name of software used for reconstruction""" reconstructionSoftware: String - """whether this tomogram adheres to portal standards""" - isStandardized: Boolean - """whether this tomogram adheres to portal standards""" isPortalStandard: Boolean = null @@ -5968,7 +5956,6 @@ input TomogramWhereClause { tomogramVersion: FloatComparators processingSoftware: StrComparators reconstructionSoftware: StrComparators - isStandardized: BoolComparators isPortalStandard: BoolComparators isAuthorSubmitted: BoolComparators isVisualizationDefault: BoolComparators diff --git a/apiv2/graphql_api/schema.json b/apiv2/graphql_api/schema.json index fb9d1330..a92cbb9b 100644 --- a/apiv2/graphql_api/schema.json +++ b/apiv2/graphql_api/schema.json @@ -6747,15 +6747,6 @@ "ofType": null } }, - { - "defaultValue": null, - "name": "isStandardized", - "type": { - "kind": "INPUT_OBJECT", - "name": "BoolComparators", - "ofType": null - } - }, { "defaultValue": null, "name": "isPortalStandard", @@ -21883,19 +21874,6 @@ } } }, - { - "args": [], - "name": "isStandardized", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - } - }, { "args": [], "name": "isPortalStandard", @@ -22524,15 +22502,6 @@ "ofType": null } }, - { - "defaultValue": null, - "name": "isStandardized", - "type": { - "kind": "ENUM", - "name": "orderBy", - "ofType": null - } - }, { "defaultValue": null, "name": "isPortalStandard", @@ -23395,15 +23364,6 @@ "ofType": null } }, - { - "args": [], - "name": "isStandardized", - "type": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, { "args": [], "name": "isPortalStandard", @@ -24971,9 +24931,6 @@ { "name": "reconstructionSoftware" }, - { - "name": "isStandardized" - }, { "name": "isPortalStandard" }, @@ -35126,19 +35083,6 @@ } } }, - { - "defaultValue": null, - "name": "isStandardized", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - } - }, { "defaultValue": "null", "name": "isPortalStandard", @@ -35507,15 +35451,6 @@ "ofType": null } }, - { - "defaultValue": null, - "name": "isStandardized", - "type": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, { "defaultValue": "null", "name": "isPortalStandard", diff --git a/apiv2/graphql_api/types/tomogram.py b/apiv2/graphql_api/types/tomogram.py index de85871f..3d3a389b 100644 --- a/apiv2/graphql_api/types/tomogram.py +++ b/apiv2/graphql_api/types/tomogram.py @@ -235,7 +235,6 @@ class TomogramWhereClause(TypedDict): tomogram_version: Optional[FloatComparators] | None processing_software: Optional[StrComparators] | None reconstruction_software: Optional[StrComparators] | None - is_standardized: Optional[BoolComparators] | None is_portal_standard: Optional[BoolComparators] | None is_author_submitted: Optional[BoolComparators] | None is_visualization_default: Optional[BoolComparators] | None @@ -288,7 +287,6 @@ class TomogramOrderByClause(TypedDict): tomogram_version: Optional[orderBy] | None processing_software: Optional[orderBy] | None reconstruction_software: Optional[orderBy] | None - is_standardized: Optional[orderBy] | None is_portal_standard: Optional[orderBy] | None is_author_submitted: Optional[orderBy] | None is_visualization_default: Optional[orderBy] | None @@ -362,7 +360,6 @@ class Tomogram(EntityInterface): description="Processing software used to derive the tomogram", default=None, ) reconstruction_software: str = strawberry.field(description="Name of software used for reconstruction") - is_standardized: bool = strawberry.field(description="whether this tomogram adheres to portal standards") is_portal_standard: Optional[bool] = strawberry.field( description="whether this tomogram adheres to portal standards", default=None, ) @@ -514,7 +511,6 @@ class TomogramCountColumns(enum.Enum): tomogramVersion = "tomogram_version" processingSoftware = "processing_software" reconstructionSoftware = "reconstruction_software" - isStandardized = "is_standardized" isPortalStandard = "is_portal_standard" isAuthorSubmitted = "is_author_submitted" isVisualizationDefault = "is_visualization_default" @@ -610,7 +606,6 @@ class TomogramCreateInput: description="Processing software used to derive the tomogram", default=None, ) reconstruction_software: str = strawberry.field(description="Name of software used for reconstruction") - is_standardized: bool = strawberry.field(description="whether this tomogram adheres to portal standards") is_portal_standard: Optional[bool] = strawberry.field( description="whether this tomogram adheres to portal standards", default=None, ) @@ -703,7 +698,6 @@ class TomogramUpdateInput: description="Processing software used to derive the tomogram", default=None, ) reconstruction_software: Optional[str] = strawberry.field(description="Name of software used for reconstruction") - is_standardized: Optional[bool] = strawberry.field(description="whether this tomogram adheres to portal standards") is_portal_standard: Optional[bool] = strawberry.field( description="whether this tomogram adheres to portal standards", default=None, ) diff --git a/apiv2/schema/README.md b/apiv2/schema/README.md index 8581462d..ee38baf8 100644 --- a/apiv2/schema/README.md +++ b/apiv2/schema/README.md @@ -12,7 +12,6 @@ Tomogram { float tomogram_version string processing_software string reconstruction_software - boolean is_standardized boolean is_portal_standard boolean is_author_submitted boolean is_visualization_default diff --git a/apiv2/schema/schema.yaml b/apiv2/schema/schema.yaml index 5b6a454c..63957127 100644 --- a/apiv2/schema/schema.yaml +++ b/apiv2/schema/schema.yaml @@ -2373,11 +2373,6 @@ classes: range: string required: true description: Name of software used for reconstruction - is_standardized: - description: whether this tomogram adheres to portal standards - range: boolean - ifabsent: false - required: true is_portal_standard: description: whether this tomogram adheres to portal standards range: boolean diff --git a/apiv2/test_infra/factories/tomogram.py b/apiv2/test_infra/factories/tomogram.py index 6e5628b1..76d433c5 100644 --- a/apiv2/test_infra/factories/tomogram.py +++ b/apiv2/test_infra/factories/tomogram.py @@ -55,7 +55,6 @@ class Meta: tomogram_version = fuzzy.FuzzyFloat(1, 100) processing_software = fuzzy.FuzzyText() reconstruction_software = fuzzy.FuzzyText() - is_standardized = factory.Faker("boolean") is_portal_standard = factory.Faker("boolean") is_author_submitted = factory.Faker("boolean") is_visualization_default = factory.Faker("boolean") diff --git a/apiv2/validators/tomogram.py b/apiv2/validators/tomogram.py index fe47d049..a30f3f13 100644 --- a/apiv2/validators/tomogram.py +++ b/apiv2/validators/tomogram.py @@ -69,7 +69,6 @@ class TomogramCreateInputValidator(BaseModel): strip_whitespace=True, ), ] - is_standardized: Annotated[bool, Field()] is_portal_standard: Annotated[bool | None, Field()] is_author_submitted: Annotated[bool | None, Field()] is_visualization_default: Annotated[bool | None, Field()] @@ -210,7 +209,6 @@ class TomogramUpdateInputValidator(BaseModel): strip_whitespace=True, ), ] - is_standardized: Annotated[bool | None, Field()] is_portal_standard: Annotated[bool | None, Field()] is_author_submitted: Annotated[bool | None, Field()] is_visualization_default: Annotated[bool | None, Field()]