Skip to content

Commit

Permalink
update task.py
Browse files Browse the repository at this point in the history
  • Loading branch information
idocx committed Jul 8, 2024
1 parent 146100c commit 066468f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
10 changes: 8 additions & 2 deletions alab_management/_default/tasks/default_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
5 changes: 3 additions & 2 deletions alab_management/task_view/task.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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."""
Expand Down

0 comments on commit 066468f

Please sign in to comment.