multiml.task.basic.base module
BaseTask module.
- class multiml.task.basic.base.BaseTask(saver=None, input_saver_key='tmpkey', output_saver_key='tmpkey', storegate=None, data_id=None, name=None)
Bases:
Task
Base task class for the default functions.
All subtasks defined by users, need to inherit this
BaseTask
. In user defined class, super.__init__() must be called in __init__() method. A task class is assumed to call its methods by following sequence:set_hps()
->execute()
->finalize()
. If task class instance is registered toTaskScheduler
as subtask,self._task_id
andself._subtask_id
are automatically set byTaskScheduler
.Examples
>>> task = BaseTask() >>> task.set_hps({'hp_layer': 5, 'hp_epoch': 256}) >>> task.execute() >>> task.finalize()
- __init__(saver=None, input_saver_key='tmpkey', output_saver_key='tmpkey', storegate=None, data_id=None, name=None)
Initialize base task.
- Parameters:
saver (Saver) –
Saver
class instance to record metadata data.input_saver_key (int) – unique saver key to retrieve metadata.
output_saver_key (int) – unique saver key to save metadata.
storegate (Storegate) –
Storegate
class instance to manage data.data_id (str) – data_id of
Storegate
, which is set by set_hps().name (str) – task’s name. If None,
classname
is used alternatively.
- execute()
Execute base task.
Users implement their algorithms.
- finalize()
Finalize base task.
Users implement their algorithms.
- set_hps(params)
Set hyperparameters to this task.
Class attributes (self._XXX) are automatically set based on keys and values of given dict. E.g. dict of {‘key0’: 0, ‘key1’: 1} is given, self._key0 = 0 and self._key1 = 1 are created.
- property name
Return name of task.
- property job_id
Return job_id of task.
- property trial_id
Return trial_id of task.
- property task_id
Return task_id of task.
- property subtask_id
Return subtask_id of task.
- property pool_id
Return pool_id of task.
- property storegate
Return storegate of task.
- property saver
Return saver of task.
- property input_saver_key
Return input_saver_key.
- property output_saver_key
Return output_saver_key.
- get_unique_id()
Returns unique identifier of task.