sio3pack.workflow¶
Submodules¶
Package Contents¶
- class sio3pack.workflow.Object(handle)[source]¶
A class to represent an object in a workflow. A object is a file, stored either locally or remotely.
- Parameters:
handle (str) – The handle of the object.
- class sio3pack.workflow.ObjectList[source]¶
A class to represent a list of objects in a workflow.
- union(other)[source]¶
Union the list with another list of objects.
- Parameters:
other (ObjectList) – The other list to union with.
- class sio3pack.workflow.ObjectsManager[source]¶
A class to manage objects in a workflow. Allows creation, retrieval, and management of objects.
- add_object(obj)[source]¶
Add an object to the manager.
- Parameters:
obj (Object) – The object to add.
- class sio3pack.workflow.ExecutionTask(name, workflow, exclusive=False, hard_time_limit=None, extra_limit=None, output_register=None, pid_namespaces=1, processes=None, pipes=0, channels=None)[source]¶
Bases:
Task
A task that executes a program.
- Parameters:
name (str) – The name of the task.
workflow (Workflow) – The workflow the task belongs to.
exclusive (bool) – Whether the task is exclusive.
hard_time_limit (int) – The hard time limit.
extra_limit (int) – If set, the hard_time_limit for the task will be the maximum time limit of all resource groups plus this value.
output_register (int | str) – The output register of the task.
pid_namespaces (int) – The number of PID namespaces.
pipes (int) – The number of pipes available to the task.
channels (list[Channel]) – Configuration of the channels for the task.
output_register
- add_filesystem(filesystem)[source]¶
Add a filesystem to the task.
- Parameters:
filesystem (Filesystem) – The filesystem to add.
- add_mount_namespace(mount_namespace)[source]¶
Add a mount namespace to the task.
- Parameters:
mount_namespace (MountNamespace) – The mount namespace to add.
- add_resource_group(resource_group)[source]¶
Add a resource group to the task.
- Parameters:
resource_group (ResourceGroup) – The resource group to add.
- class sio3pack.workflow.ScriptTask(name, workflow, reactive=False, input_registers=None, output_registers=None, objects=None, script=None)[source]¶
Bases:
Task
A task that runs a script.
- Parameters:
name (str) – The name of the task.
workflow (Workflow) – The workflow the task belongs to.
reactive (bool) – Whether the task is reactive.
input_registers (list[int | str]) – The input registers of the task.
output_registers (list[int | str]) – The output registers of the task.
script (str) – The script to run.
input_registers
output_registers
- class sio3pack.workflow.Task[source]¶
Base class for a task.
- class sio3pack.workflow.Workflow(name, external_objects=None, observable_objects=None, observable_registers=0, tasks=None)[source]¶
A class to represent a workflow. Number of registers is not required, as it is calculated automatically.
- Parameters:
name (str) – The name of the workflow.
external_objects (ObjectList) – The external objects used in the workflow.
observable_objects (ObjectList) – The observable objects used in the workflow.
observable_registers (int) – The number of observable registers used in the workflow.
- classmethod from_json(data)[source]¶
Create a new workflow from a dictionary.
- Parameters:
data (dict) – The dictionary to create the workflow from.
- only_string_registers()[source]¶
Check if all registers in the workflow are strings.
- Return bool:
True if all registers are strings, False otherwise.
- Return type:
- abstractmethod get_prog_files()[source]¶
Get all program files in the workflow.
- Returns:
A list of program files.
- Return type:
list[sio3pack.files.file.File]
- add_external_object(obj)[source]¶
Add an external object to the workflow.
- Parameters:
obj (Object) – The object to add.
- add_observable_object(obj)[source]¶
Add an observable object to the workflow.
- Parameters:
obj (Object) – The object to add.
- replace_templates(replacements)[source]¶
Replace strings in the workflow with the given replacements.
- class sio3pack.workflow.WorkflowManager(package, workflows)[source]¶
A class to manage workflows for a package. Allows to get workflows by name, manages default and user created workflows, and provides methods to get workflows for compiling files, generating tests, and verifying results. This class can be overridden to provide custom workflows in other package types.
- Parameters:
- get(name)[source]¶
Get the workflow with the given name. If the workflow does not exist, return default workflow for this name from
WorkflowManager.get_default()
.- Parameters:
name (str) – The name of the workflow.
- Returns:
The workflow with the given name.
- Return type:
sio3pack.workflow.workflow.Workflow
- get_default(name)[source]¶
Get the default workflow for the given name. This method should be overridden by subclasses to provide the default workflow for the given name.
- Parameters:
name (str) – The name of the workflow.
- Returns:
The default workflow for the given name.
- Return type:
sio3pack.workflow.workflow.Workflow
- get_compile_file_workflow(file)[source]¶
A helper function to get a workflow for compiling the given file. The file should be a program file, not a test file. Returns a tuple of the workflow and the path to the compiled file. The files are not added as external or observable objects, since they don’t have to be.
- Parameters:
file (sio3pack.files.File | str) – The file (or the path to the file) to compile.
file
- Returns:
A tuple of the workflow and the path to the compiled file.
- Return type:
- get_unpack_operation(has_test_gen, has_verify, return_func=None)[source]¶
Get the operation for unpacking the package.
- abstractmethod get_run_operation(program, tests=None, return_func=None)[source]¶
Get the operation for running the program with the given tests.
- Parameters:
program (File) – The program file to run.
tests (list[sio3pack.test.Test] | None) – The list of tests to run the program with or None if all tests should be run.
return_func (callable) – A function to call with the results of the workflow execution.
tests
- Return type:
sio3pack.workflow.workflow_op.WorkflowOperation
- abstractmethod get_user_out_operation(program, test, return_func=None)[source]¶
Get the operation for running the user output with the given program and test.
- class sio3pack.workflow.WorkflowOperation(get_workflow_func, return_results=False, return_results_func=None, *wf_args, **wf_kwargs)[source]¶
A class to handle workflow operations, allowing for the retrieval of workflows and the return of results from those workflows.
- Parameters:
get_workflow_func (callable) – Function to retrieve workflows.
return_results (bool) – Whether to return results from the workflow.
return_results_func (callable) – Function to handle returning results.
wf_args (list[Any]) – Additional positional arguments for the workflow function.
wf_kwargs (dict[str, Any]) – Additional keyword arguments for the workflow function.