diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index eaa17ee8d..3de98999b 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,10 +1,10 @@ repos: - repo: https://github.com/psf/black-pre-commit-mirror - rev: 23.9.1 + rev: 24.4.0 hooks: - id: black - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.0.292 + rev: v0.4.1 hooks: - id: ruff args: diff --git a/api_server/metadata/databases/cryoetdataportal/tables/public_annotation_authors.yaml b/api_server/metadata/databases/cryoetdataportal/tables/public_annotation_authors.yaml index 87975a1db..24bedd0b7 100644 --- a/api_server/metadata/databases/cryoetdataportal/tables/public_annotation_authors.yaml +++ b/api_server/metadata/databases/cryoetdataportal/tables/public_annotation_authors.yaml @@ -20,6 +20,7 @@ select_permissions: - name - orcid - primary_annotator_status + - primary_author_status filter: {} allow_aggregations: true query_root_fields: diff --git a/api_server/migrations/cryoetdataportal/1712956764128_alter_table_public_annotation_authors_add_column_primary_author_status/down.sql b/api_server/migrations/cryoetdataportal/1712956764128_alter_table_public_annotation_authors_add_column_primary_author_status/down.sql new file mode 100644 index 000000000..a44205644 --- /dev/null +++ b/api_server/migrations/cryoetdataportal/1712956764128_alter_table_public_annotation_authors_add_column_primary_author_status/down.sql @@ -0,0 +1 @@ +alter table "public"."annotation_authors" drop column "primary_author_status"; diff --git a/api_server/migrations/cryoetdataportal/1712956764128_alter_table_public_annotation_authors_add_column_primary_author_status/up.sql b/api_server/migrations/cryoetdataportal/1712956764128_alter_table_public_annotation_authors_add_column_primary_author_status/up.sql new file mode 100644 index 000000000..66ac33e3d --- /dev/null +++ b/api_server/migrations/cryoetdataportal/1712956764128_alter_table_public_annotation_authors_add_column_primary_author_status/up.sql @@ -0,0 +1,3 @@ +alter table "public"."annotation_authors" add column "primary_author_status" boolean + null; +UPDATE "public"."annotation_authors" SET primary_author_status = primary_annotator_status; diff --git a/ingestion_tools/Dockerfile b/ingestion_tools/Dockerfile index 59312e8d9..054bd97ed 100644 --- a/ingestion_tools/Dockerfile +++ b/ingestion_tools/Dockerfile @@ -17,7 +17,7 @@ ENV IMOD_DIR /usr/local/IMOD # Get our packaging house in order RUN pip install --upgrade pip -ENV POETRY_VERSION=1.7 +ENV POETRY_VERSION=1.8.2 RUN python3 -m pip install --no-cache-dir poetry==$POETRY_VERSION # Install our dependencies diff --git a/ingestion_tools/pyproject.toml b/ingestion_tools/pyproject.toml index 6625f56bc..66c0b626f 100644 --- a/ingestion_tools/pyproject.toml +++ b/ingestion_tools/pyproject.toml @@ -50,6 +50,10 @@ line-length = 120 target_version = ['py311'] [tool.ruff] +line-length = 120 +target-version = "py39" + +[tool.ruff.lint] select = [ "E", "W", # pycodestyle "F", # pyflakes @@ -72,17 +76,15 @@ ignore = [ "DTZ007", # Datetime objects without timezones. "DTZ005", # More datetimes without timezones. ] -line-length = 120 -target-version = "py39" [tool.ruff.lint.per-file-ignores] # Ignore `SIM115` (not using open() in a context manager) since all calls to this method *do* use a context manager. "scripts/common/fs.py" = ["SIM115"] -[tool.ruff.isort] +[tool.ruff.lint.isort] known-first-party =["common"] -[tool.ruff.flake8-quotes] +[tool.ruff.lint.flake8-quotes] docstring-quotes = "double" [tool.mypy] diff --git a/ingestion_tools/scripts/common/db_models.py b/ingestion_tools/scripts/common/db_models.py index e26b2cdc3..7af806440 100644 --- a/ingestion_tools/scripts/common/db_models.py +++ b/ingestion_tools/scripts/common/db_models.py @@ -206,6 +206,7 @@ class Meta: orcid = CharField(null=True) corresponding_author_status = BooleanField(default=False) primary_annotator_status = BooleanField(default=False) + primary_author_status = BooleanField(default=False) email = CharField(null=True) affiliation_name = CharField(null=True) affiliation_address = CharField(null=True) diff --git a/ingestion_tools/scripts/importers/db/annotation.py b/ingestion_tools/scripts/importers/db/annotation.py index 500c1cd61..87b8fd315 100644 --- a/ingestion_tools/scripts/importers/db/annotation.py +++ b/ingestion_tools/scripts/importers/db/annotation.py @@ -147,6 +147,7 @@ def update_data_map(self, data_map: dict[str, Any], metadata: dict[str, Any], in data_map = super().update_data_map(data_map, metadata, index) primary_author_status = { "primary_annotator_status": metadata.get("primary_annotator_status", metadata.get("primary_author_status")), + "primary_author_status": metadata.get("primary_annotator_status", metadata.get("primary_author_status")), } return {**data_map, **primary_author_status} diff --git a/ingestion_tools/scripts/tests/db_import/test_db_annotation_import.py b/ingestion_tools/scripts/tests/db_import/test_db_annotation_import.py index 00b365593..6adf711dd 100644 --- a/ingestion_tools/scripts/tests/db_import/test_db_annotation_import.py +++ b/ingestion_tools/scripts/tests/db_import/test_db_annotation_import.py @@ -84,6 +84,7 @@ def expected_annotation_authors() -> list[dict[str, Any]]: "name": "Jane Smith", "corresponding_author_status": False, "primary_annotator_status": True, + "primary_author_status": True, "author_list_order": 1, }, { @@ -91,6 +92,7 @@ def expected_annotation_authors() -> list[dict[str, Any]]: "name": "J Carpenter", "corresponding_author_status": False, "primary_annotator_status": True, + "primary_author_status": True, "author_list_order": 2, }, { @@ -98,6 +100,7 @@ def expected_annotation_authors() -> list[dict[str, Any]]: "name": "John Doe", "corresponding_author_status": False, "primary_annotator_status": False, + "primary_author_status": False, "orcid": "0000-0000-1234-0000", "email": "jdoe@test.com", "author_list_order": 3, diff --git a/test_infra/sql/schema.sql b/test_infra/sql/schema.sql index d6fc86377..109520ee3 100644 --- a/test_infra/sql/schema.sql +++ b/test_infra/sql/schema.sql @@ -116,7 +116,8 @@ CREATE TABLE public.annotation_authors ( affiliation_name character varying, affiliation_address character varying, affiliation_identifier character varying, - author_list_order integer + author_list_order integer, + primary_author_status boolean ); diff --git a/test_infra/sql/seed_db_data.sql b/test_infra/sql/seed_db_data.sql index 4859fa60d..30acabe5a 100644 --- a/test_infra/sql/seed_db_data.sql +++ b/test_infra/sql/seed_db_data.sql @@ -29,16 +29,16 @@ INSERT INTO public.annotations VALUES (43, 's3://test-public-bucket/20002/RUN001 INSERT INTO public.annotations VALUES (44, 's3://test-public-bucket/20002/RUN002/TomogramVoxelSpacing13.48/Annotations/author4-ribosome-1.0.json', 'http://localhost:4444/20002/RUN002/TomogramVoxelSpacing13.48/Annotations/author4-ribosome-1.0.json', '2023-04-01', '2023-06-01', '2023-06-01', 'EMPIAR-77777', 'Manual', true, 'Ribosome', 'GO:000000A', NULL, NULL, 16, NULL, NULL, NULL, 7, NULL, true); INSERT INTO public.annotations VALUES (45, 's3://test-public-bucket/20002/RUN002/TomogramVoxelSpacing13.48/Annotations/author4-spike-1.0.json', 'http://localhost:4444/20002/RUN002/TomogramVoxelSpacing13.48/Annotations/author4-spike-1.0.json', '2023-04-01', '2023-06-01', '2023-06-01', 'EMPIAR-77777', 'Manual', true, 'Spike Protein', 'GO:000000A', NULL, NULL, 16, NULL, NULL, NULL, 7, NULL, true); -INSERT INTO public.annotation_authors VALUES (50, 40, 'Author 1', '0000-0000-0000-0007', false, true, NULL, NULL, NULL, NULL, NULL); -INSERT INTO public.annotation_authors VALUES (51, 40, 'Author 2', '0000-0000-0000-0008', false, true, NULL, NULL, NULL, NULL, NULL); -INSERT INTO public.annotation_authors VALUES (52, 41, 'Author 1', '0000-0000-0000-0007', false, true, NULL, NULL, NULL, NULL, NULL); -INSERT INTO public.annotation_authors VALUES (53, 41, 'Author 2', '0000-0000-0000-0008', false, true, NULL, NULL, NULL, NULL, NULL); -INSERT INTO public.annotation_authors VALUES (54, 42, 'Author 3', '0000-0000-0000-0039', false, true, NULL, NULL, NULL, NULL, NULL); -INSERT INTO public.annotation_authors VALUES (55, 42, 'Author 4', '0000-0000-0000-0049', false, true, NULL, NULL, NULL, NULL, NULL); -INSERT INTO public.annotation_authors VALUES (56, 43, 'Author 5', '0000-0000-0000-0059', false, true, NULL, NULL, NULL, NULL, NULL); -INSERT INTO public.annotation_authors VALUES (57, 44, 'Author 6', '0000-0000-0000-0069', false, true, NULL, NULL, NULL, NULL, NULL); -INSERT INTO public.annotation_authors VALUES (58, 45, 'Author 7', '0000-0000-0000-0079', false, true, NULL, NULL, NULL, NULL, NULL); -INSERT INTO public.annotation_authors VALUES (59, 45, 'Author 8', '0000-0000-0000-0089', false, true, NULL, NULL, NULL, NULL, NULL); +INSERT INTO public.annotation_authors VALUES (50, 40, 'Author 1', '0000-0000-0000-0007', false, true, NULL, NULL, NULL, NULL, NULL, true); +INSERT INTO public.annotation_authors VALUES (51, 40, 'Author 2', '0000-0000-0000-0008', false, NULL, NULL, NULL, NULL, NULL, NULL, NULL); +INSERT INTO public.annotation_authors VALUES (52, 41, 'Author 1', '0000-0000-0000-0007', false, true, NULL, NULL, NULL, NULL, NULL, true); +INSERT INTO public.annotation_authors VALUES (53, 41, 'Author 2', '0000-0000-0000-0008', true, NULL, NULL, NULL, NULL, NULL, NULL NULL); +INSERT INTO public.annotation_authors VALUES (54, 42, 'Author 3', '0000-0000-0000-0039', false, true, NULL, NULL, NULL, NULL, NULL, true); +INSERT INTO public.annotation_authors VALUES (55, 42, 'Author 4', '0000-0000-0000-0049', true, false, NULL, NULL, NULL, NULL, NULL, false); +INSERT INTO public.annotation_authors VALUES (56, 43, 'Author 5', '0000-0000-0000-0059', false, true, NULL, NULL, NULL, NULL, NULL, true); +INSERT INTO public.annotation_authors VALUES (57, 44, 'Author 6', '0000-0000-0000-0069', false, true, NULL, NULL, NULL, NULL, NULL, true); +INSERT INTO public.annotation_authors VALUES (58, 45, 'Author 7', '0000-0000-0000-0079', false, true, NULL, NULL, NULL, NULL, NULL, true); +INSERT INTO public.annotation_authors VALUES (59, 45, 'Author 8', '0000-0000-0000-0089', false, true, NULL, NULL, NULL, NULL, NULL, true); INSERT INTO public.annotation_files VALUES (70, 40, 'OrientedPoint', 'ndjson', 'http://localhost:4444/20001/RUN1/TomogramVoxelSpacing13.48/Annotations/mitochondria.ndjson', 's3://test-public-bucket/20001/RUN1/TomogramVoxelSpacing13.48/Annotations/mitochondria.ndjson');