From 0ef1613114e5917c5963e93d717a8767008b44c9 Mon Sep 17 00:00:00 2001 From: Sebastian Diaz Date: Thu, 16 Jan 2025 14:25:14 +0100 Subject: [PATCH] remove organism validation (#4103) remove organism existence validation --- .../errors/sample_errors.py | 5 ---- .../models/order_aliases.py | 1 - .../rules/sample/rules.py | 17 ----------- .../workflows/microsalt/validation_rules.py | 2 -- .../workflows/mutant/validation_rules.py | 2 -- cg/store/crud/read.py | 2 +- .../cgweb_orders/microbial_fastq.json | 4 +-- tests/meta/orders/test_meta_orders_api.py | 4 +-- .../sample_rules/test_data_validators.py | 28 ------------------- 9 files changed, 5 insertions(+), 60 deletions(-) diff --git a/cg/services/order_validation_service/errors/sample_errors.py b/cg/services/order_validation_service/errors/sample_errors.py index 767784d398..9e827e02eb 100644 --- a/cg/services/order_validation_service/errors/sample_errors.py +++ b/cg/services/order_validation_service/errors/sample_errors.py @@ -52,11 +52,6 @@ class VolumeRequiredError(SampleError): message: str = "Volume is required" -class OrganismDoesNotExistError(SampleError): - field: str = "organism" - message: str = "Organism does not exist" - - class SampleNameNotAvailableError(SampleError): field: str = "name" message: str = "Sample name already used in previous order" diff --git a/cg/services/order_validation_service/models/order_aliases.py b/cg/services/order_validation_service/models/order_aliases.py index d87312c471..6ad046cac4 100644 --- a/cg/services/order_validation_service/models/order_aliases.py +++ b/cg/services/order_validation_service/models/order_aliases.py @@ -11,7 +11,6 @@ ) OrderWithIndexedSamples = FluffyOrder | RmlOrder -OrderWithSamplesFromOrganism = MutantOrder | MicrosaltOrder OrderWithControlSamples = ( MetagenomeSample | MicrobialFastqOrder | MicrosaltOrder | MutantOrder | TaxprofilerSample ) diff --git a/cg/services/order_validation_service/rules/sample/rules.py b/cg/services/order_validation_service/rules/sample/rules.py index ba3aa4306e..f66cdc3dee 100644 --- a/cg/services/order_validation_service/rules/sample/rules.py +++ b/cg/services/order_validation_service/rules/sample/rules.py @@ -14,7 +14,6 @@ IndexSequenceMissingError, InvalidVolumeError, OccupiedWellError, - OrganismDoesNotExistError, PoolApplicationError, PoolPriorityError, SampleNameNotAvailableControlError, @@ -29,7 +28,6 @@ from cg.services.order_validation_service.models.order_aliases import ( OrderWithControlSamples, OrderWithIndexedSamples, - OrderWithSamplesFromOrganism, ) from cg.services.order_validation_service.models.sample_aliases import IndexedSample from cg.services.order_validation_service.rules.sample.utils import ( @@ -211,21 +209,6 @@ def validate_index_sequence_required( return errors -def validate_organism_exists( - order: OrderWithSamplesFromOrganism, store: Store, **kwargs -) -> list[OrganismDoesNotExistError]: - """ - Validate that the organisms of all samples in the order exist in the database. - Only applicable to Microsalt and Mutant orders. - """ - errors: list[OrganismDoesNotExistError] = [] - for sample_index, sample in order.enumerated_samples: - if not store.get_organism_by_internal_id(sample.organism): - error = OrganismDoesNotExistError(sample_index=sample_index) - errors.append(error) - return errors - - def validate_pools_contain_one_application( order: OrderWithIndexedSamples, **kwargs ) -> list[PoolApplicationError]: diff --git a/cg/services/order_validation_service/workflows/microsalt/validation_rules.py b/cg/services/order_validation_service/workflows/microsalt/validation_rules.py index c226a3a0ce..46ead869b9 100644 --- a/cg/services/order_validation_service/workflows/microsalt/validation_rules.py +++ b/cg/services/order_validation_service/workflows/microsalt/validation_rules.py @@ -4,7 +4,6 @@ validate_applications_not_archived, validate_container_name_required, validate_non_control_sample_names_available, - validate_organism_exists, validate_sample_names_unique, validate_tube_container_name_unique, validate_volume_interval, @@ -20,7 +19,6 @@ validate_applications_not_archived, validate_container_name_required, validate_non_control_sample_names_available, - validate_organism_exists, validate_sample_names_unique, validate_tube_container_name_unique, validate_volume_interval, diff --git a/cg/services/order_validation_service/workflows/mutant/validation_rules.py b/cg/services/order_validation_service/workflows/mutant/validation_rules.py index 86010d13a5..940fd11205 100644 --- a/cg/services/order_validation_service/workflows/mutant/validation_rules.py +++ b/cg/services/order_validation_service/workflows/mutant/validation_rules.py @@ -4,7 +4,6 @@ validate_applications_not_archived, validate_container_name_required, validate_non_control_sample_names_available, - validate_organism_exists, validate_sample_names_unique, validate_tube_container_name_unique, validate_volume_interval, @@ -20,7 +19,6 @@ validate_applications_not_archived, validate_container_name_required, validate_non_control_sample_names_available, - validate_organism_exists, validate_volume_required, validate_sample_names_unique, validate_tube_container_name_unique, diff --git a/cg/store/crud/read.py b/cg/store/crud/read.py index b34b68a3e7..a6679fb966 100644 --- a/cg/store/crud/read.py +++ b/cg/store/crud/read.py @@ -16,8 +16,8 @@ ) from cg.constants.sequencing import DNA_PREP_CATEGORIES, SeqLibraryPrepCategory from cg.exc import CaseNotFoundError, CgError, OrderNotFoundError, SampleNotFoundError -from cg.models.orders.sample_base import SexEnum from cg.models.orders.constants import OrderType +from cg.models.orders.sample_base import SexEnum from cg.server.dto.samples.collaborator_samples_request import CollaboratorSamplesRequest from cg.services.orders.order_service.models import OrderQueryParams from cg.store.base import BaseHandler diff --git a/tests/fixtures/cgweb_orders/microbial_fastq.json b/tests/fixtures/cgweb_orders/microbial_fastq.json index b03e524b43..e85d9116da 100644 --- a/tests/fixtures/cgweb_orders/microbial_fastq.json +++ b/tests/fixtures/cgweb_orders/microbial_fastq.json @@ -16,7 +16,7 @@ "elution_buffer": "Nuclease-free water", "name": "prov1", "priority": "priority", - "volume": "1", + "volume": "100", "well_position": "" }, { @@ -29,7 +29,7 @@ "elution_buffer": "Nuclease-free water", "name": "prov2", "priority": "priority", - "volume": "2", + "volume": "20", "well_position": "A:1" } ] diff --git a/tests/meta/orders/test_meta_orders_api.py b/tests/meta/orders/test_meta_orders_api.py index 19a8d8d231..6192dfef12 100644 --- a/tests/meta/orders/test_meta_orders_api.py +++ b/tests/meta/orders/test_meta_orders_api.py @@ -72,8 +72,8 @@ def test_too_long_order_name(): OrderType.FASTQ, OrderType.FLUFFY, OrderType.METAGENOME, - # OrderType.MICROBIAL_FASTQ, - # OrderType.MICROSALT, + OrderType.MICROBIAL_FASTQ, + OrderType.MICROSALT, # OrderType.MIP_DNA, # OrderType.MIP_RNA, # OrderType.PACBIO_LONG_READ, diff --git a/tests/services/order_validation_service/sample_rules/test_data_validators.py b/tests/services/order_validation_service/sample_rules/test_data_validators.py index d21aa44777..31a3c4de8e 100644 --- a/tests/services/order_validation_service/sample_rules/test_data_validators.py +++ b/tests/services/order_validation_service/sample_rules/test_data_validators.py @@ -4,13 +4,11 @@ ApplicationNotCompatibleError, ApplicationNotValidError, InvalidVolumeError, - OrganismDoesNotExistError, ) from cg.services.order_validation_service.rules.sample.rules import ( validate_application_compatibility, validate_application_exists, validate_applications_not_archived, - validate_organism_exists, validate_volume_interval, ) from cg.services.order_validation_service.workflows.microsalt.models.order import MicrosaltOrder @@ -85,29 +83,3 @@ def test_invalid_volume(valid_microsalt_order: MicrosaltOrder, base_store: Store # THEN the error should concern the invalid volume assert isinstance(errors[0], InvalidVolumeError) - - -def test_invalid_organism(valid_microsalt_order: MicrosaltOrder, base_store: Store): - - # GIVEN an order with a sample specifying a non-existent organism - valid_microsalt_order.samples[0].organism = "Non-existent organism" - - # WHEN validating that all organisms exist - errors = validate_organism_exists(order=valid_microsalt_order, store=base_store) - - # THEN an error should be returned - assert errors - - # THEN the error should concern the invalid organism - assert isinstance(errors[0], OrganismDoesNotExistError) - - -def test_valid_organisms(valid_microsalt_order: MicrosaltOrder, base_store: Store): - - # GIVEN a valid order - - # WHEN validating that all organisms exist - errors = validate_organism_exists(order=valid_microsalt_order, store=base_store) - - # THEN no error should be returned - assert not errors