@epilog

The @epilog decorator enables the definition of binaries to be executed after the task execution on the worker. All kind of PyCOMPSs tasks can have a @epilog. A basic usage is shown in the example below.

Tip

There is a similar decorator to the define binaries to be executed before the task execution on the worker. It is the @prolog decorator.

You can check the documentation of both decorators combined: @prolog and @epilog

Definition

Code 47 Epilog definition.
from pycompss.api.epilog import epilog
from pycompss.api.task import task

@epilog(binary="/my_service/stop.bin")
@task()
def run_simulation():
    ...

def main():
    run_simulation()

The @epilog decorator has 3 parameters:

binary

Defines the binary to be executed after the task. Mandatory

args

Describe the command line arguments of the binary. Users can also pass the task parameters as arguments. In this case, the task parameter should be surrounded by double curly braces (β€œ{{” and β€œ}}”) in the β€˜args’ string. Optional

Important

Task parameters used in β€˜args’ strings can be type of primitive types such as int, float, string, and boolean.

fail_by_exit_value

Is used to indicate the behavior when the epilog returns an exit value different than zero. Users can set the fail_by_exit_value to True, if they want to consider the exit value as a task failure. If set to False, failure of the epilog will be ignored and task execution will start as usual. Default value of β€˜fail_by_exit_value’ is False for Epilog. Optional

These parameters can be results of previous tasks and PyCOMPSs will handle data dependencies between tasks:

Code 48 Task parameter in Epilog definition.
from pycompss.api.epilog import epilog
from pycompss.api.task import task

@epilog(binary="tar", args="zcvf {{out_tgz}} /tmp/{{working_dir}}")
@task(returns=1)
def run_simulation(working_dir, out_tgz):
    ...

def main():
    # call to the task function
    run_simulation("my_logs", "my_logs_compressed")

In the next example, removing the sandbox is not crucial and can be ignored, so fail_by_exit_value in the Epilog can be set to False.

Code 49 Epilog with β€˜fail_by_exit_value’.
from pycompss.api.epilog import epilog
from pycompss.api.task import task

@epilog(binary="rm", args="-r {{sandbox_path}}", fail_by_exit_value=False)
@task()
def run_simulation(sandbox_path):
    ...
    return 1

# call to the task function
run_simulation("/tmp/my_task_sandbox")