Task Pack

A Task Pack is a class that manages a group of setup tasks, teardown tasks, tests and resources.

Property definitions

Resource Run Modes

Note

  • The resource mode only applies if an ATS Client has been registered.
  • For all custom modes, a scheduler function must be regesiterd with schedule_func before calling any run que methods.

Warning

“all” is the only mode currently implemented

  • all Will reserve all resources needed by all tasks for the estimated duration of the run. This is the default mode

    Note

    run_all_que method must be used for running tasks

  • per_task_separate Will reserve resources on a task by task basis as each task is run. Each task will hold its own set of resources.

  • per_task_combine Will reserve resources on a task by task basis as each task is run. Resources common to tasks will be consolidated so they use the same resource.

  • custom_all The test que will be passed to the function registered with schedule_func for ordering. Resource management will be handled the same as all

  • custom_separate The que selected for execution will be passed to the function registered with schedule_func for ordering. Resource management will be handled the same as per_task_separate

  • custom_combine The que selected for execution will be passed to the function registered with schedule_func for ordering. Resource management will be handled the same as per_task_combine

ats_client

ats_client module containing the ATS_Client class to import and instantiate for resource management, if None, no client will be used.

Note

if set to “auto”, we will attempt to first import an ATS client based on the ATS name provided in the init_params, if that fails, we will attempt to pip install, then import, if that fails a KissATSError will be raised

TaskPack Class

class kissats.task_pack.TaskPack(init_params=None, schema_add=None, que_class=<class 'kissats.queues.PackQues'>)

Bases: kissats.task_pack.PackParams

Schedules and executes a group or package of kissats.BaseTask

see Global Parameters

Parameters:
  • init_params (dict) – Initialization parameter dict. see XXXXX
  • schema_add (dict) – (Optional) Additional Cerberus schema definition to be applied to the init_params
  • que_class (object) – Class or object containing the queues, see BaseQues

Note

If task_package is not supplied in the init_params, tasks must be added using the appropriate add task method. Any method that depends on a valid task_package will raise.

add_setup_task(task, allow_dupe=False, top=False)

add a task to the setup queue

Parameters:
  • task (kissats.task.Task or str or ModuleType) – Task to add
  • allow_dupe (bool) – Allow the task to run multiple times
  • top (bool) – Place the task at the top of the queue

see add_test_task() for Task input handling and further allow_dupe explanation

Returns:True if in the queue
Return type:bool
add_teardown_task(task, allow_dupe=False, top=False)

add a task to the teardown queue

Parameters:
  • task (kissats.task.Task or str or ModuleType) – Task to add
  • allow_dupe (bool) – Allow the task to run multiple times
  • top (bool) – Place the task at the top of the queue

see add_test_task() for Task input handling and further allow_dupe explanation

Returns:

True if in the queue

Return type:

bool

Raises:
  • FailedPrereq
  • KissATSError
add_test_group(test_group)

Add all tests in the test group to the test queue

If a corresponding group specific setup and teardown exists, they will also be added to the appropriate queue.

Parameters:test_group (str) –

Test group to add to the test queue.

Note

There must be a corresponding get_<test_group>_tests function in the test package’s seq_test

Raises:TaskPackageNotRegistered
add_test_task(task, allow_dupe=False, top=False)

add a task to the test queue

Parameters:
  • task (kissats.task.Task or str or ModuleType) – Task to add
  • allow_dupe (bool) – Allow the task to run multiple times If set to false and the task is already in the queue a warning will be logged and processing will continue.
  • top (bool) – Place the task at the top of the queue

Warning

If dut and/or ats are not set in the TaskPack, the dut and/or ats will not be verified and the task will be added to the queue

Note

Task input handling:

  • If task is a kissats.task.Task based class it will be added directly to the queue
  • If task is a str we will an attempt will be made to import by the Task class, if the import fails, we will prepend with the package name and try again.
  • If task is a ModuleType, it will be passed directly to the Task class
  • If the dut from the global params is not listed in the task params key valid_duts the task will not be added and processing will continue
  • If the ats from the global params is not listed in the task params key valid_ats the task will not be added and processing will continue
Returns:True if in the queue
Return type:bool
all_resources

A list of all resources needed for tasks currently in any queue

Resource should be kissats.ResourceReservation

ats

The Automated Test System used to perform the testing

ats_client

The ATS client for communication with the ATS

call_scheduler()

Call the registered scheduler/optimizer

Passes all queues to a previously registered function

check_prereqs(task)

Check if prereq tasks have been completed for a task

Parameters:task (Task) – the task to check
Returns:
  • (list): prereqs needed
  • (list): failed prereqs
Return type:tuple
clear_all_que()

clear all task queues

clear_delay_que()

clear the delay queue

clear_setup_que()

clear the setup queue

clear_teardown_que()

clear the teardown queue

clear_test_que()

clear the test queue

completed_tasks

dict of completed tasks and their results

dut

The Device Under Test

est_run_time

Estimated total run time in seconds

get_seq_group(group_name, seq_name)

Get a list of tasks from a seq

Parameters:
  • group_name (str) – Group to find
  • seq_name (str) – seq to check (setup, test or teardown)
Returns:

List of tasks

Return type:

list

ignore_prereq

when set, will ignore prereqs

json_params

Keys in the parameter dictionary formated in JSON

Note

Any key that cannot be flattened by json.dumps will be excluded

params

The global parameter dict

process_limit

Max additional processes to use

report_func

Function to report results

report_result(result)

Report results using a registered reporting function.

If no reporting function is registered, result will be reported using the python built in logging module.

Parameters:result (dict) – see reporting_schema for details
resource_mode

Resource reservation mode

run_all_que()

Run all queue’s

If ATS client is registered and resource mode is set to “all” or “custom_all”, all resources will be reserved and claimed. When complete, all resources will be released.

If resource mode is set to a custom mode, the registered schedular function will be called before execution.

Will run all queue’s in order:
  • setup
  • test
  • teardown
Raises:
  • KissATSError
  • ResourceUnavailable
run_mode

The global run mode, normal, process or thread

run_setup_que()

run all tasks in setup queue

run_teardown_que()

run all tasks in the teardown queue

run_test_que()

run all tasks in test queue

schedule_func

Function to schedule/order tasks

setup_list

The list of setup tasks required by the task package.

Will call the get_global_setup function from the seq_setup module in the task_package to populate the list.

task_pack

The Python package containing the tasks to run

Also accepts a wheel, distribution name must match the import name!

Note

Don’t be like PyYAML: distribution name is PyYAML import name is yaml

Warning

This property can only be set once!

teardown_list

The list of teardown tasks required by the task package

Will call the get_global_teardown function from the seq_teardown module in the task_package to populate the list.

test_groups

The scheduled test groups

thread_limit

Max additional threads to use

valid_result

Valid result returns

These are the only result values that will be considered a non-failure condition.

PackParams Class

class kissats.task_pack.PackParams(init_params=None, schema_add=None)

Bases: object

Holds the parameters of the task package

see Global Parameters

Parameters:
  • init_params (dict) – Initialization parameter dict. see XXXXX
  • schema_add (dict) –

    (Optional) Additional Cerberus schema definition to be applied to the init_params

Note

If task_package is not supplied in the init_params, tasks must be added using the appropriate add task method. Any method that depends on a valid task_package will raise.

all_resources

A list of all resources needed for tasks currently in any queue

Resource should be kissats.ResourceReservation

ats

The Automated Test System used to perform the testing

ats_client

The ATS client for communication with the ATS

completed_tasks

dict of completed tasks and their results

dut

The Device Under Test

est_run_time

Estimated total run time in seconds

ignore_prereq

when set, will ignore prereqs

json_params

Keys in the parameter dictionary formated in JSON

Note

Any key that cannot be flattened by json.dumps will be excluded

params

The global parameter dict

process_limit

Max additional processes to use

report_func

Function to report results

resource_mode

Resource reservation mode

run_mode

The global run mode, normal, process or thread

schedule_func

Function to schedule/order tasks

setup_list

The list of setup tasks required by the task package.

Will call the get_global_setup function from the seq_setup module in the task_package to populate the list.

task_pack

The Python package containing the tasks to run

Also accepts a wheel, distribution name must match the import name!

Note

Don’t be like PyYAML: distribution name is PyYAML import name is yaml

Warning

This property can only be set once!

teardown_list

The list of teardown tasks required by the task package

Will call the get_global_teardown function from the seq_teardown module in the task_package to populate the list.

test_groups

The scheduled test groups

thread_limit

Max additional threads to use

valid_result

Valid result returns

These are the only result values that will be considered a non-failure condition.