@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
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:
binaryDefines the binary to be executed after the task. Mandatory
argsDescribe 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_valueIs used to indicate the behavior when the epilog returns an exit value different than zero. Users can set the
fail_by_exit_valueto 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:
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.
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")