From cf871d89c99934d66d997944c9d6db8f2b2f5bc3 Mon Sep 17 00:00:00 2001 From: Jessica Gadling Date: Thu, 17 Oct 2024 11:44:04 -0400 Subject: [PATCH] Lint. --- client/python/cryoet_data_portal/Makefile | 2 +- .../src/cryoet_data_portal/_client.py | 6 +- .../tests/test_get_client.py | 6 +- .../tests/test_infra/seed_db.py | 56 +++++++++++++------ client/python/cryoet_data_portal/tests/tmp.py | 21 ------- 5 files changed, 50 insertions(+), 41 deletions(-) delete mode 100644 client/python/cryoet_data_portal/tests/tmp.py diff --git a/client/python/cryoet_data_portal/Makefile b/client/python/cryoet_data_portal/Makefile index 98027bd9b..201ae2dd1 100644 --- a/client/python/cryoet_data_portal/Makefile +++ b/client/python/cryoet_data_portal/Makefile @@ -3,7 +3,7 @@ SHELL := /bin/bash export BACKEND_DIR=/tmp/cryoet-data-portal-backend-test-infra .PHONY: set-api-version set-api-version: - if [ ! -e $(BACKEND_DIR) ]; then git clone git@github.com:chanzuckerberg/cryoet-data-portal-backend.git $(BACKEND_DIR); fi + if [ ! -e $(BACKEND_DIR) ]; then git clone https://github.com/chanzuckerberg/cryoet-data-portal-backend.git $(BACKEND_DIR); fi export STAGING_SHA=$$(./tests/test_infra/get_deployment.sh staging); \ if [ -n "$${STAGING_SHA}" ]; then \ echo "Setting backend to SHA: $${STAGING_SHA}"; \ diff --git a/client/python/cryoet_data_portal/src/cryoet_data_portal/_client.py b/client/python/cryoet_data_portal/src/cryoet_data_portal/_client.py index 5c142b859..788243666 100644 --- a/client/python/cryoet_data_portal/src/cryoet_data_portal/_client.py +++ b/client/python/cryoet_data_portal/src/cryoet_data_portal/_client.py @@ -47,7 +47,11 @@ def __init__(self, url: Optional[str] = None): self.ds = DSLSchema(self.client.schema) def build_query( - self, cls, root_field: str, gql_class_name: str, query_filters=None, + self, + cls, + root_field: str, + gql_class_name: str, + query_filters=None, ): ds = self.ds query_filters = {} if not query_filters else {"where": query_filters} diff --git a/client/python/cryoet_data_portal/tests/test_get_client.py b/client/python/cryoet_data_portal/tests/test_get_client.py index b4d8ac27f..ba4adccd8 100644 --- a/client/python/cryoet_data_portal/tests/test_get_client.py +++ b/client/python/cryoet_data_portal/tests/test_get_client.py @@ -65,7 +65,8 @@ def test_relationships_reverse(client) -> None: def test_correct_number_of_related_objects(client: Client): annos = Annotation.find( - client, [Annotation.object_name == "Test Annotation Object Name"], + client, + [Annotation.object_name == "Test Annotation Object Name"], ) assert len(annos) == 1 @@ -74,7 +75,8 @@ def test_correct_number_of_related_objects(client: Client): def test_item_relationship_with_missing_id(client: Client): annos = Annotation.find( - client, [Annotation.object_name == "Test Annotation Object Name"], + client, + [Annotation.object_name == "Test Annotation Object Name"], ) assert len(annos) == 1 diff --git a/client/python/cryoet_data_portal/tests/test_infra/seed_db.py b/client/python/cryoet_data_portal/tests/test_infra/seed_db.py index 722d5886f..93b3fded9 100644 --- a/client/python/cryoet_data_portal/tests/test_infra/seed_db.py +++ b/client/python/cryoet_data_portal/tests/test_infra/seed_db.py @@ -261,51 +261,75 @@ def use_factoryboy() -> None: ) AnnotationAuthorFactory.create( - annotation=a40, name="Author 1", orcid="0000-0000-0000-0007", + annotation=a40, + name="Author 1", + orcid="0000-0000-0000-0007", ) AnnotationAuthorFactory.create( - annotation=a40, name="Author 2", orcid="0000-0000-0000-0008", + annotation=a40, + name="Author 2", + orcid="0000-0000-0000-0008", ) AnnotationAuthorFactory.create( - annotation=a41, name="Author 1", orcid="0000-0000-0000-0007", + annotation=a41, + name="Author 1", + orcid="0000-0000-0000-0007", ) AnnotationAuthorFactory.create( - annotation=a41, name="Author 2", orcid="0000-0000-0000-0008", + annotation=a41, + name="Author 2", + orcid="0000-0000-0000-0008", ) AnnotationAuthorFactory.create( - annotation=a42, name="Author 3", orcid="0000-0000-0000-0039", + annotation=a42, + name="Author 3", + orcid="0000-0000-0000-0039", ) AnnotationAuthorFactory.create( - annotation=a42, name="Author 4", orcid="0000-0000-0000-0049", + annotation=a42, + name="Author 4", + orcid="0000-0000-0000-0049", ) AnnotationAuthorFactory.create( - annotation=a43, name="Author 5", orcid="0000-0000-0000-0059", + annotation=a43, + name="Author 5", + orcid="0000-0000-0000-0059", ) AnnotationAuthorFactory.create( - annotation=a44, name="Author 6", orcid="0000-0000-0000-0069", + annotation=a44, + name="Author 6", + orcid="0000-0000-0000-0069", ) AnnotationAuthorFactory.create( - annotation=a45, name="Author 7", orcid="0000-0000-0000-0079", + annotation=a45, + name="Author 7", + orcid="0000-0000-0000-0079", ) AnnotationAuthorFactory.create( - annotation=a45, name="Author 8", orcid="0000-0000-0000-0089", + annotation=a45, + name="Author 8", + orcid="0000-0000-0000-0089", ) as40op = AnnotationShapeFactory.create(annotation=a40, shape_type="OrientedPoint") as40sm = AnnotationShapeFactory.create( - annotation=a40, shape_type="SegmentationMask", + annotation=a40, + shape_type="SegmentationMask", ) as41pt = AnnotationShapeFactory.create(annotation=a41, shape_type="Point") as41sm = AnnotationShapeFactory.create( - annotation=a41, shape_type="SegmentationMask", + annotation=a41, + shape_type="SegmentationMask", ) as42op = AnnotationShapeFactory.create(annotation=a42, shape_type="OrientedPoint") as42sm = AnnotationShapeFactory.create( - annotation=a42, shape_type="SegmentationMask", + annotation=a42, + shape_type="SegmentationMask", ) as43op = AnnotationShapeFactory.create(annotation=a43, shape_type="OrientedPoint") as44sm = AnnotationShapeFactory.create( - annotation=a44, shape_type="SegmentationMask", + annotation=a44, + shape_type="SegmentationMask", ) as45pt = AnnotationShapeFactory.create(annotation=a45, shape_type="Point") @@ -479,6 +503,6 @@ def use_factoryboy() -> None: if __name__ == "__main__": - print("Seeding database") + print("Seeding database") # noqa use_factoryboy() - print("Seeding complete") + print("Seeding complete") # noqa diff --git a/client/python/cryoet_data_portal/tests/tmp.py b/client/python/cryoet_data_portal/tests/tmp.py deleted file mode 100644 index 022ef8d82..000000000 --- a/client/python/cryoet_data_portal/tests/tmp.py +++ /dev/null @@ -1,21 +0,0 @@ -from cryoet_data_portal import Client, Run, Tomogram - -# Instantiate a client, using the data portal GraphQL API by default -client = Client() - -# runs_list = Run.find(client, query_filters=[Run.name.ilike("%TS%"), Run.tomogram_voxel_spacings.tomograms.size_x > 900]) -runs_list = Run.find(client) -for run in runs_list: - print(run.name) - for vs in run.tomogram_voxel_spacings: - # for tomo in vs.tomograms: - # These tomograms may or may not be > 900 voxels wide because I didn't add another filter above! - tomos = Tomogram.find( - client, - query_filters=[ - Tomogram.tomogram_voxel_spacing.id == vs.id, - ], - ) - for tomo in tomos: - print(tomo.to_dict()) - print(run.to_dict())