File tree Expand file tree Collapse file tree 3 files changed +16
-7
lines changed
Expand file tree Collapse file tree 3 files changed +16
-7
lines changed Original file line number Diff line number Diff line change @@ -411,17 +411,21 @@ class ExperimentPeriod(BaseModel):
411411
412412 #: The start time of the period in time units as defined in the model.
413413 start : float = Field (alias = C .TIME )
414+ # TODO: decide if optional
414415 #: The ID of the condition to be applied at the start time.
415416 condition_id : str = Field (alias = C .CONDITION_ID )
416417
417418 #: :meta private:
418419 model_config = ConfigDict (populate_by_name = True )
419420
420- @field_validator ("condition_id" )
421+ @field_validator ("condition_id" , mode = "before" )
421422 @classmethod
422423 def _validate_id (cls , condition_id ):
423- if not condition_id :
424- raise ValueError ("ID must not be empty." )
424+ # TODO to be decided if optional
425+ if pd .isna (condition_id ):
426+ return ""
427+ # if not condition_id:
428+ # raise ValueError("ID must not be empty.")
425429 if not is_valid_identifier (condition_id ):
426430 raise ValueError (f"Invalid ID: { condition_id } " )
427431 return condition_id
Original file line number Diff line number Diff line change @@ -545,6 +545,8 @@ def run(self, problem: Problem) -> ValidationIssue | None:
545545 missing_conditions = set (required_conditions ) - set (
546546 existing_conditions
547547 )
548+ # TODO NA allowed?
549+ missing_conditions = {x for x in missing_conditions if not pd .isna (x )}
548550 if missing_conditions :
549551 return ValidationError (
550552 f"Experiment table contains conditions that are not present "
@@ -842,7 +844,8 @@ def append_overrides(overrides):
842844 CheckExperimentTable (),
843845 CheckValidPetabIdColumn ("measurement" , EXPERIMENT_ID , ignore_nan = True ),
844846 CheckValidPetabIdColumn ("experiment" , EXPERIMENT_ID ),
845- CheckValidPetabIdColumn ("experiment" , CONDITION_ID ),
847+ # TODO: NAN allowed?
848+ CheckValidPetabIdColumn ("experiment" , CONDITION_ID , ignore_nan = True ),
846849 CheckExperimentConditionsExist (),
847850 CheckObservableTable (),
848851 CheckObservablesDoNotShadowModelEntities (),
Original file line number Diff line number Diff line change @@ -798,10 +798,12 @@ def add_condition(
798798 {
799799 CONDITION_ID : id_ ,
800800 TARGET_ID : target_id ,
801- OPERATION_TYPE : op_type ,
802- TARGET_VALUE : target_value ,
801+ OPERATION_TYPE : "setCurrentValue" ,
802+ TARGET_VALUE : target_value
803+ if not isinstance (target_value , tuple )
804+ else target_value [1 ],
803805 }
804- for target_id , ( op_type , target_value ) in kwargs .items ()
806+ for target_id , target_value in kwargs .items ()
805807 ]
806808 # TODO: is the condition name supported in v2?
807809 if name is not None :
You can’t perform that action at this time.
0 commit comments