datmo.task module¶
-
class
datmo.task.
Task
(task_entity, home=None)[source]¶ Task is an entity object to enable user access to properties
Parameters: - task_entity (datmo.core.entity.task.Task) – core task entity to reference
- home (str, optional) – root directory of the project (default is CWD, if not provided)
-
id
¶ str – the id of the entity
-
model_id
¶ str – the parent model id for the entity
-
session_id
¶ str – id of session associated with task
-
command
¶ str – command that is used by the task
-
status
¶ str or None – status of the current task
-
start_time
¶ datetime.datetime or None – timestamp for the beginning time of the task
-
end_time
¶ datetime.datetime or None – timestamp for the end time of the task
-
duration
¶ float or None – delta in seconds between start and end times
-
logs
¶ str or None – string output of logs
-
results
¶ dict or None – dictionary containing output results from the task
-
files
¶ list – returns list of file objects for the task in read mode
Raises: InvalidArgumentType
-
duration
-
end_time
-
files
-
get_files
(mode='r')[source] Returns a list of file objects for the task
Parameters: mode (str) – file object mode (default is “r” which signifies read mode) Returns: list of file objects associated with the task Return type: list
-
logs
-
results
-
start_time
-
status
-
datmo.task.
ls
(session_id=None, filter=None, home=None)[source]¶ List tasks within a project
The project must be created before this is implemented. You can do that by using the following command:
$ datmo init
Parameters: - session_id (str, optional) – session to filter output tasks (default is None, which means no session filter is given)
- filter (str, optional) – a string to use to filter from message and label (default is to give all snapshots, unless provided a specific string. eg: best)
- home (str, optional) – absolute home path of the project (default is None, which will use the CWD as the project path)
Returns: returns a list of Task entities (as defined above)
Return type: list
Examples
You can use this function within a project repository to list tasks.
>>> import datmo >>> tasks = datmo.task.ls()
-
datmo.task.
run
(command, env=None, home=None, gpu=False)[source]¶ Run the code or script inside
The project must be created before this is implemented. You can do that by using the following command:
$ datmo init
Parameters: - command (str or list) – the command to be run in environment. this can be either a string or list
- env (str, optional) – the location for the environment definition path (default is None, which will defer to the environment to find a default environment, or will fail if not found)
- home (str, optional) – absolute home path of the project (default is None, which will use the CWD as the project path)
- gpu (boolean) – try to run task on GPU (if available)
Returns: returns a Task entity as defined above
Return type: Examples
You can use this function within a project repository to run tasks in the following way.
>>> import datmo >>> datmo.task.run(command="python script.py") >>> datmo.task.run(command="python script.py", env='Dockerfile')