qkrun.tasks.Script

class qkrun.tasks.Script(*args, script: str | None = None, executable: str | None = None, **kwargs)

Base class for tasks that run a script.

__init__(*args, script: str | None = None, executable: str | None = None, **kwargs)

Initialize the task.

Parameters:
  • args – Task instance arguments.

  • script – The script to run.

  • executable – The executable to use to run the script.

  • kwargs – Task instance keyword arguments.

Methods

__init__(*args[, script, executable])

Initialize the task.

add_args(parser)

Add arguments to the parser.

condition_passes(*args, **kwargs)

Check the condition before running the task.

full_run(*args, **kwargs)

Execute the full task lifecycle and return the result of run().

get_after(*args, **kwargs)

Get the tasks to run after this task.

get_before(*args, **kwargs)

Get the tasks to run before this task.

get_cleanup(*args, **kwargs)

Get the tasks to run after this task, even if it fails.

get_env(*args, **kwargs)

Get the environment.

get_expected_exit_codes(*args, **kwargs)

Get accepted subprocess exit codes.

get_help()

Get the help message of the task.

get_parser(*[, name])

Get the parser for the task.

get_plain_usage()

Return the usage string without ANSI escape sequences.

get_retries()

Get the number of additional retry attempts.

get_retry_delay()

Get the seconds to wait between retry attempts.

get_script(*args, **kwargs)

Get the script to run.

get_short_help()

Get the short help message of the task.

get_timeout()

Get the subprocess timeout in seconds.

get_watch_config(*args, **kwargs)

Return watch configuration using this task's working directory.

get_wd(*args, **kwargs)

Get the working directory.

log_task_execution(*args, **kwargs)

Log information about the task execution.

log_task_execution_details(script)

Log details about the task execution.

parse_and_run(args)

Parse arguments and run the task.

parse_args(*, parser, args, extra_args)

Parse arguments.

run(*args, **kwargs)

Run the main work of this task.

run_after(*args, **kwargs)

Run the tasks after this task.

run_before(*args, **kwargs)

Run the tasks before this task.

run_cleanup(*args, **kwargs)

Run the tasks after this task, even if it fails.

to_info_dict(cwd)

Serialise task metadata to a plain dict suitable for JSON output.

validate_exit_code(*, return_code, command, ...)

Validate the subprocess return code.

Attributes

after

Tasks to run after this task.

args

Arguments for the task.

before

Tasks to run before this task.

cleanup

Tasks to run at the end, even if the task, or before or after tasks fail.

condition

The condition to check before running the task.

env

The environment.

env_file

Path to a .env file whose variables are merged into the environment.

executable

expected_exit_codes

Accepted subprocess exit codes.

extra_args

Whether to allow extra command line arguments.

output_mode

Controls how subprocess output is handled.

parser

Parser for the task.

retries

Number of additional attempts after an initial failure.

retry_delay

Seconds to wait between retry attempts.

script

timeout

Timeout in seconds for each subprocess attempt.

watch_debounce

Seconds to wait after a file change before re-running.

watch_ignore_paths

Default directory paths to ignore when --watch is used.

watch_ignore_patterns

Default patterns to ignore when --watch is used.

watch_paths

Default directories to watch when --watch is used.

watch_patterns

Default patterns for changed files when --watch is used.

watch_recursive

Whether watch mode observes directories recursively.

wd

The current working directory.