Skip to content

Commit

Permalink
Merge pull request #51 from chanzuckerberg/jgadling/new_anno_author_f…
Browse files Browse the repository at this point in the history
…ield

chore: Make a new `annotation_authors.primary_author_status` field
  • Loading branch information
jgadling authored Apr 22, 2024
2 parents 105753b + 253debb commit 60fe5b4
Show file tree
Hide file tree
Showing 11 changed files with 31 additions and 18 deletions.
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ select_permissions:
- name
- orcid
- primary_annotator_status
- primary_author_status
filter: {}
allow_aggregations: true
query_root_fields:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
alter table "public"."annotation_authors" drop column "primary_author_status";
Original file line number Diff line number Diff line change
@@ -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;
2 changes: 1 addition & 1 deletion ingestion_tools/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 6 additions & 4 deletions ingestion_tools/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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]
Expand Down
1 change: 1 addition & 0 deletions ingestion_tools/scripts/common/db_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions ingestion_tools/scripts/importers/db/annotation.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,20 +84,23 @@ 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,
},
{
"annotation_id": ANNOTATION_ID,
"name": "J Carpenter",
"corresponding_author_status": False,
"primary_annotator_status": True,
"primary_author_status": True,
"author_list_order": 2,
},
{
"annotation_id": ANNOTATION_ID,
"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,
Expand Down
3 changes: 2 additions & 1 deletion test_infra/sql/schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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
);


Expand Down
20 changes: 10 additions & 10 deletions test_infra/sql/seed_db_data.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down

0 comments on commit 60fe5b4

Please sign in to comment.