diff --git a/alab_management/_default/tasks/default_task.py b/alab_management/_default/tasks/default_task.py index 166b3234..9455c570 100644 --- a/alab_management/_default/tasks/default_task.py +++ b/alab_management/_default/tasks/default_task.py @@ -20,9 +20,15 @@ def run(self): self.sample, sample_positions[None]["DefaultSamplePosition"][0] ) - def validate(self): + def validate(self) -> bool: + """ + Validation of the input parameters. + + You can add more validation logic here. The method should return True if the input parameters + are valid, False otherwise. This method is called when you build the task. + """ return True @property - def result_specification(self) -> BaseModel: + def result_specification(self) -> type[BaseModel]: pass diff --git a/alab_management/task_view/task.py b/alab_management/task_view/task.py index f5b876fe..0ea0c4ec 100644 --- a/alab_management/task_view/task.py +++ b/alab_management/task_view/task.py @@ -94,8 +94,6 @@ def __init__(self, sample_1: ObjectId, sample_2: Optional[ObjectId], for key, val in inspect.getargvalues(subclass_init_frame).locals.items() if key not in ["self", "args", "kwargs", "__class__"] } - if not self.validate(): - raise ValueError("Task validation failed!") else: if (task_id is None) or (lab_view is None) or (samples is None): raise ValueError( @@ -108,6 +106,9 @@ def __init__(self, sample_1: ObjectId, sample_2: Optional[ObjectId], self.priority = priority self.lab_view.priority = priority + if not self.validate(): + raise ValueError("Task validation failed!") + @property def is_offline(self) -> bool: """Returns True if this task is in offline, False if it is a live task."""