From 727f8033aac41975aae70634284111f747bc4bd5 Mon Sep 17 00:00:00 2001 From: Yuxing Fei Date: Mon, 8 Jul 2024 17:13:14 -0700 Subject: [PATCH] update _default folder --- .../_default/devices/default_device.py | 2 +- .../_default/tasks/default_task.py | 22 ++++++++++++++++++- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/alab_management/_default/devices/default_device.py b/alab_management/_default/devices/default_device.py index 02c973bb..da7518c2 100644 --- a/alab_management/_default/devices/default_device.py +++ b/alab_management/_default/devices/default_device.py @@ -56,7 +56,7 @@ def is_running(self): """ Check if the device is running. - Returns: + Returns ------- bool: True if the device is running, False otherwise. """ diff --git a/alab_management/_default/tasks/default_task.py b/alab_management/_default/tasks/default_task.py index 9455c570..707f1c94 100644 --- a/alab_management/_default/tasks/default_task.py +++ b/alab_management/_default/tasks/default_task.py @@ -12,6 +12,13 @@ def __init__(self, sample: ObjectId, *args, **kwargs): self.sample = sample def run(self): + """ + The main logic of the task. + + You can request resources, move samples, and communicate with devices in this method. + Finally, the return value of this method will be stored as the result of the task (valiated + by `result_specification`). + """ with self.lab_view.request_resources({None: {"DefaultSamplePosition": 1}}) as ( _, sample_positions, @@ -31,4 +38,17 @@ def validate(self) -> bool: @property def result_specification(self) -> type[BaseModel]: - pass + """ + The result specification of the task. + + The method should return a pydantic model that defines the result of the task. The result + will be validated using the result_specification. + """ + + class DefaultTaskResult(BaseModel): + """The result of the default task.""" + + mass: float + temperature: float + + return DefaultTaskResult