File tree Expand file tree Collapse file tree 2 files changed +36
-2
lines changed
cg/services/orders/validation/workflows Expand file tree Collapse file tree 2 files changed +36
-2
lines changed Original file line number Diff line number Diff line change 1
- from pydantic import BeforeValidator , Field
1
+ import logging
2
+
3
+ from pydantic import BeforeValidator , Field , model_validator
2
4
from typing_extensions import Annotated
3
5
4
6
from cg .models .orders .sample_base import ContainerEnum , ControlEnum , PriorityEnum
5
7
from cg .services .orders .validation .constants import IndexEnum
8
+ from cg .services .orders .validation .index_sequences import INDEX_SEQUENCES
6
9
from cg .services .orders .validation .models .sample import Sample
7
10
from cg .services .orders .validation .utils import parse_control
8
11
12
+ LOG = logging .getLogger (__name__ )
13
+
9
14
10
15
class FluffySample (Sample ):
11
16
concentration : float
@@ -20,3 +25,15 @@ class FluffySample(Sample):
20
25
rml_plate_name : str | None = None
21
26
volume : int
22
27
well_position_rml : str | None = None
28
+
29
+ @model_validator (mode = "after" )
30
+ def set_default_index_sequence (self ):
31
+ """Set a default index_sequence from the index and index_number."""
32
+ if not self .index_sequence and (self .index and self .index_number ):
33
+ try :
34
+ self .index_sequence = INDEX_SEQUENCES [self .index ][self .index_number - 1 ]
35
+ except Exception :
36
+ LOG .warning (
37
+ f"No index sequence set and no suitable sequence found for index { self .index } , number { self .index_number } "
38
+ )
39
+ return self
Original file line number Diff line number Diff line change 1
- from pydantic import BeforeValidator , Field
1
+ import logging
2
+
3
+ from pydantic import BeforeValidator , Field , model_validator
2
4
from typing_extensions import Annotated
3
5
4
6
from cg .models .orders .sample_base import ContainerEnum , ControlEnum , PriorityEnum
5
7
from cg .services .orders .validation .constants import IndexEnum
8
+ from cg .services .orders .validation .index_sequences import INDEX_SEQUENCES
6
9
from cg .services .orders .validation .models .sample import Sample
7
10
from cg .services .orders .validation .utils import parse_control
8
11
12
+ LOG = logging .getLogger (__name__ )
13
+
9
14
10
15
class RmlSample (Sample ):
11
16
concentration : float
@@ -20,3 +25,15 @@ class RmlSample(Sample):
20
25
rml_plate_name : str | None = None
21
26
volume : int
22
27
well_position_rml : str | None = None
28
+
29
+ @model_validator (mode = "after" )
30
+ def set_default_index_sequence (self ):
31
+ """Set a default index_sequence from the index and index_number."""
32
+ if not self .index_sequence and (self .index and self .index_number ):
33
+ try :
34
+ self .index_sequence = INDEX_SEQUENCES [self .index ][self .index_number - 1 ]
35
+ except Exception :
36
+ LOG .warning (
37
+ f"No index sequence set and no suitable sequence found for index { self .index } , number { self .index_number } "
38
+ )
39
+ return self
You can’t perform that action at this time.
0 commit comments