From 64df7520e9bd7cfd020b79e324a32f51175eb556 Mon Sep 17 00:00:00 2001 From: Afonso Pinto Date: Tue, 13 Feb 2024 12:09:45 +0000 Subject: [PATCH 1/3] SCKAN-250 fix: Remove CircuitType.UNKNOWN from ingestion (#227) --- .../composer/services/cs_ingestion/cs_ingestion_services.py | 4 ++-- backend/composer/services/cs_ingestion/helpers.py | 5 ++--- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/backend/composer/services/cs_ingestion/cs_ingestion_services.py b/backend/composer/services/cs_ingestion/cs_ingestion_services.py index f4bc4d14..a540cfeb 100644 --- a/backend/composer/services/cs_ingestion/cs_ingestion_services.py +++ b/backend/composer/services/cs_ingestion/cs_ingestion_services.py @@ -339,10 +339,10 @@ def get_circuit_type(statement: Dict): if statement[CIRCUIT_TYPE]: if len(statement[CIRCUIT_TYPE]) > 1: logger_service.add_anomaly(LoggableAnomaly(statement[ID], None, f'Multiple circuit types found')) - return CIRCUIT_TYPE_MAPPING.get(statement[CIRCUIT_TYPE][0], CircuitType.UNKNOWN) + return CIRCUIT_TYPE_MAPPING.get(statement[CIRCUIT_TYPE][0], None) else: logger_service.add_anomaly(LoggableAnomaly(statement[ID], None, f'No circuit type found.')) - return CircuitType.UNKNOWN + return None def get_phenotype(statement: Dict) -> Optional[Phenotype]: diff --git a/backend/composer/services/cs_ingestion/helpers.py b/backend/composer/services/cs_ingestion/helpers.py index ee42fbc7..7016e6ad 100644 --- a/backend/composer/services/cs_ingestion/helpers.py +++ b/backend/composer/services/cs_ingestion/helpers.py @@ -1,8 +1,7 @@ import logging -from typing import Optional, Dict from composer.enums import CircuitType -from composer.models import AnatomicalEntity, ConnectivityStatement +from composer.models import AnatomicalEntity ID = "id" ORIGINS = "origins" @@ -26,7 +25,7 @@ "http://uri.interlex.org/tgbugs/uris/readable/ProjectionPhenotype": CircuitType.PROJECTION, "http://uri.interlex.org/tgbugs/uris/readable/MotorPhenotype": CircuitType.MOTOR, "http://uri.interlex.org/tgbugs/uris/readable/SensoryPhenotype": CircuitType.SENSORY, - "": CircuitType.UNKNOWN + "": None } VALIDATION_ERRORS = "validation_errors" From c152c72b9ad933ebfb4b547b17ee6fae239c5a7f Mon Sep 17 00:00:00 2001 From: ddelpiano Date: Tue, 13 Feb 2024 16:05:26 +0100 Subject: [PATCH 2/3] adding invalid --- frontend/src/apiclient/backend/api.ts | 8 +++++--- frontend/src/helpers/helpers.ts | 2 ++ frontend/src/helpers/settings.ts | 1 + frontend/src/redux/statementSlice.tsx | 1 + openapi/openapi.yaml | 2 ++ 5 files changed, 11 insertions(+), 3 deletions(-) diff --git a/frontend/src/apiclient/backend/api.ts b/frontend/src/apiclient/backend/api.ts index b5380214..7316ea57 100644 --- a/frontend/src/apiclient/backend/api.ts +++ b/frontend/src/apiclient/backend/api.ts @@ -5,7 +5,7 @@ * SCKAN Composer API * * The version of the OpenAPI document: 1.0.0 - * + * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech @@ -63,7 +63,8 @@ export const AvailableTransitionsC67Enum = { ToBeReviewed: 'to_be_reviewed', ConnectionMissing: 'connection_missing', NpoApproved: 'npo_approved', - Exported: 'exported' + Exported: 'exported', + Invalid: 'invalid' } as const; export type AvailableTransitionsC67Enum = typeof AvailableTransitionsC67Enum[keyof typeof AvailableTransitionsC67Enum]; @@ -6325,7 +6326,8 @@ export const ComposerConnectivityStatementListStateEnum = { Exported: 'exported', NpoApproved: 'npo_approved', Rejected: 'rejected', - ToBeReviewed: 'to_be_reviewed' + ToBeReviewed: 'to_be_reviewed', + Invalid: 'invalid' } as const; export type ComposerConnectivityStatementListStateEnum = typeof ComposerConnectivityStatementListStateEnum[keyof typeof ComposerConnectivityStatementListStateEnum]; /** diff --git a/frontend/src/helpers/helpers.ts b/frontend/src/helpers/helpers.ts index 0e3cf453..d153cf6f 100644 --- a/frontend/src/helpers/helpers.ts +++ b/frontend/src/helpers/helpers.ts @@ -114,6 +114,7 @@ export interface StatementStateToColor { connection_missing: StateColor; npo_approved: StateColor; exported: StateColor; + invalid: StateColor; } export const SentenceLabels = { @@ -134,6 +135,7 @@ export const StatementsLabels = { [statementStates.ConnectionMissing]: "Connection missing", [statementStates.NpoApproved]: "NPO approved", [statementStates.Exported]: "Exported", + [statementStates.Invalid]: "Invalid", }; export const formatDate = (date: string) => { diff --git a/frontend/src/helpers/settings.ts b/frontend/src/helpers/settings.ts index 9389da0e..293638c3 100644 --- a/frontend/src/helpers/settings.ts +++ b/frontend/src/helpers/settings.ts @@ -13,6 +13,7 @@ export const statementStateToColor: StatementStateToColor = { connection_missing: "warning", // orange npo_approved: "success", //green exported: "success", //green + invalid: "warning", //orange }; export const sentenceStateToColor: SentenceStateToColor = { diff --git a/frontend/src/redux/statementSlice.tsx b/frontend/src/redux/statementSlice.tsx index 1b88395a..61d3ab2f 100644 --- a/frontend/src/redux/statementSlice.tsx +++ b/frontend/src/redux/statementSlice.tsx @@ -11,6 +11,7 @@ export type StateFilter = Array< | "npo_approved" | "rejected" | "to_be_reviewed" + | "invalid" >; export interface QueryParams { diff --git a/openapi/openapi.yaml b/openapi/openapi.yaml index 0abcba5f..df6f0643 100644 --- a/openapi/openapi.yaml +++ b/openapi/openapi.yaml @@ -162,6 +162,7 @@ paths: - npo_approved - rejected - to_be_reviewed + - invalid explode: true style: form - in: query @@ -1789,6 +1790,7 @@ components: - connection_missing - npo_approved - exported + - invalid type: string CircuitTypeEnum: enum: From 669e5a982f7dcb0a999f68dd83428ff39373d6d6 Mon Sep 17 00:00:00 2001 From: ddelpiano Date: Tue, 13 Feb 2024 16:51:14 +0100 Subject: [PATCH 3/3] read only on invalid state --- frontend/src/Pages/StatementDetails.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/src/Pages/StatementDetails.tsx b/frontend/src/Pages/StatementDetails.tsx index ac8652a6..59d0424a 100644 --- a/frontend/src/Pages/StatementDetails.tsx +++ b/frontend/src/Pages/StatementDetails.tsx @@ -116,7 +116,7 @@ const StatementDetails = () => { //TODO add logic for isDisabled // TODO add an extra check for invalid state; - const isDisabled = statement?.state === statementStates.Exported; + const isDisabled = statement?.state === statementStates.Exported || statement?.state === statementStates.Invalid; return ( {loading && (