labtasker task
¶
Abstract
This page details the task related operations.
Submit tasks¶
Specifying task args via --args
option or [ARGS]
argument¶
You can submit the task args that you want to run.
Tip
Specify task args via [ARGS]
argument is convenient if you have a job script that takes CLI arguments directly.
Normally, you would run it like this (suppose your job script takes --foo.bar
as a CLI argument):
You can directly copy and paste the --foo.bar
argument as a positional argument to labtasker task submit
.
arg cast to python primitive
By default, labtasker task submit
will cast the args
to python primitive types.
Therefore, if you specify -- --foo 0.1
, it will be cast to float
type rather than remain as a string.
The same principle applies to labtasker task update
.
Dict nesting
Labtasker parses the dot-separated top-level keys as keys to nested dicts.
For example:
--foo.bar 0.1
would give you task args
as {"foo": {"bar": 0.1}}
.
If you are accessing task args
via labtasker.task_info().args
,
remember to access like labtasker.task_info().args["foo"]["bar"]
rather than labtasker.task_info().args["foo.bar"]
.
The same principle applies to args
, metadata
, summary
for queues, tasks and workers.
Metadata¶
Metadata is handy if you want to filter tasks according to certain conditions.
For example, you may implement a custom tag system to manage your tasks through metadata.
Example
# submit a task 1
labtasker task submit --metadata '{"tags": ["test", "experimental"]}' -- --foo.bar 0.1
# submit a task 2
labtasker task submit --metadata '{"tags": ["tag-baz"]}' -- --foo.baz 0.2
# loop up tasks that contains 'experimental' or 'tag-baz' (1)
labtasker task ls --extra-filter '{"metadata.tags": {"$in": ["experimental", "tag-baz"]}}' --quiet --no-pager
# output:
# dd4e3ce3-25a8-4176-bf4b-dba82187679d
# 155f3872-1a07-45c9-85fb-51fce5cc29b5
- See more about
labtasker task ls
in List tasks.
List (query) tasks¶
By default, labtasker task ls
displays all tasks in the queue. Output is shown through a pager like less
by default. Add --no-pager
to display directly in the terminal.
You can filter tasks using:
--task-id
or--task-name
for basic filtering--extra-filter / -f
for advanced queries
Using Filters¶
Choose between two filter syntaxes:
-
Python Native Syntax: Intuitive to use but less powerful.
Note: Does not supportnot in
,not expr
, or!=
due to null value ambiguities -
MongoDB Syntax: More powerful but requires MongoDB knowledge.
You can see the transpiled query using --verbose
option.
See detail in How to Use Filter.
Modify (update) tasks¶
By default, labtasker task update
will open terminal editor (such as vim) to allow you edit the task info.
The read-only fields are marked with a comment # Read-only. DO NOT modify!
.
However, you may specify the --update
option or the [UPDATES]
argument to specify the fields to update instead of
opening the editor.
If you wish to use this command in a bash script, use --quiet
option to disable unnecessary output and confirmations.
If you want to filter out which tasks to update, use --extra-filter / -f
option.
See detail in How to Use Filter.
Delete tasks¶
To batch delete tasks, you can use Unix pipes.
Example: