Skip to content

Commit

Permalink
docstring for task signature contains example.
Browse files Browse the repository at this point in the history
  • Loading branch information
oliche committed Nov 14, 2024
1 parent ff23403 commit 296fab3
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
1 change: 0 additions & 1 deletion ibllib/pipes/dynamic_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
import ibllib.pipes.ephys_tasks as etasks
import ibllib.pipes.audio_tasks as atasks
import ibllib.pipes.neurophotometrics as ptasks
# from ibllib.pipes.photometry_tasks import FibrePhotometryPreprocess, FibrePhotometryRegisterRaw

_logger = logging.getLogger(__name__)

Expand Down
27 changes: 26 additions & 1 deletion ibllib/pipes/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@
from collections import OrderedDict
import traceback
import json
from typing import List, Dict

from graphviz import Digraph

Expand Down Expand Up @@ -108,7 +109,6 @@ class Task(abc.ABC):
time_elapsed_secs = None
time_out_secs = 3600 * 2 # time-out after which a task is considered dead
version = ibllib.__version__
signature = {'input_files': [], 'output_files': []} # list of tuples (filename, collection, required_flag[, register])
force = False # whether to re-download missing input files on local server if not present
job_size = 'small' # either 'small' or 'large', defines whether task should be run as part of the large or small job services
env = None # the environment name within which to run the task (NB: the env is not activated automatically!)
Expand Down Expand Up @@ -145,6 +145,31 @@ def __init__(self, session_path, parents=None, taskid=None, one=None,
self.scratch_folder = scratch_folder
self.kwargs = kwargs

@property
def signature(self) -> Dict[str, List]:
"""
The signature of the task specifies inputs and outputs for the given task.
For some tasks it is dynamic and calculated. The legacy code specifies those as tuples.
The preferred way is to use the ExpectedDataset input and output constructors.
I = ExpectedDataset.input
O = ExpectedDataset.output
signature = {
'input_files': [
I(name='extract.me.npy', collection='raw_data', required=True, register=False, unique=False),
],
'output_files': [
O(name='look.atme.npy', collection='shiny_data', required=True, register=True, unique=False)
]}
is equivalent to:
signature = {
'input_files': [('extract.me.npy', 'raw_data', True, True)],
'output_files': [('look.atme.npy', 'shiny_data', True)],
}
:return:
"""
return {'input_files': [], 'output_files': []}

@property
def name(self):
return self.__class__.__name__
Expand Down

0 comments on commit 296fab3

Please sign in to comment.