Software decorator

The @software decorator is useful in order to move definitions of several PyCOMPSs decorators to a JSON file. It allows the users to ‘define’ their decorator definitions from an external file, which can be generated by another resource. Thus, the only supported argument is the ‘config_file’ that should contain the path to the JSON configuration file. Following example shows a basic usage of the @software decorator:

Code 88 Software decorator definition example.
from pycompss.api.task import task
from pycompss.api.software import software

@software(config_file="example.json")
@task(returns=1)
def example():
    return "hola"

Configuration files can contain different key-values depending on the user’s needs. If the user wants to define an MPI task, then “mpi” value should be set for the “type” key. Moreover, arguments of @mpi decorator can be added inside the “properties”. A basic configuration file for an MPI task would look like in the example below:

Code 89 JSON configuration file of an MPI definition.
{
    "type":"mpi",
    "properties":{
        "runner":"mpirun",
        "processes": 2,
        "binary":"~/app_mpi.bin"
    }
}

As we see “runner”, “processes”, and “binary” are the regular parameters of @mpi decorator, and are added to the “properties” of the @software.

If we wanted to combine @constraint and @mpi decorators together, the JSON file would have been extended:

Code 90 JSON configuration file of an MPI definition.
{
    "type":"mpi",
    "properties":{
        "runner":"mpirun",
        "processes": 2,
        "binary":"~/app_mpi.bin",
            "params": "-d {{a}} {{b}}"
    },
    "constraints":{
        "computing_units": 2
    }
}

It’s also possible to add @prolog and @epilog definitions in the configuration files:

Code 91 Prolog and Epilog definitions in configuration files.
{
    "type":"mpi",
    "properties":{
        "runner":"mpirun",
        "processes": 2,
        "binary":"app_mpi.bin",
            "params": "-d {{a}} {{b}}"
    },
    "constraints":{
        "computing_units": 2
    },
    "prolog":{
        "binary":"echo",
        "params":"greetings from prolog."
    },
    "epilog":{
        "binary":"echo",
        "params":"execution finished."
    },
}

Next table provides more detailed information about JSON configuration files:

Key

Description

type

(Mandatory) Type of the software invocation. Supported values are ‘mpi’, ‘binary’, ‘mpmd_mpi’, ‘multinode’, ‘http’, and ‘compss’.

properties

(Mandatory) A dictionary containing parameters of the “type” decorator.

prolog

Replaces the @prolog definition and expects @prolog parameters in a dictionary.

epilog

Replaces the @epilog definition and expects @epilog parameters in a dictionary.

constraints

Replaces the @constraint definition and expects @constraint parameters in a dictionary.

container

Replaces the @container definition and expects @container parameters in a dictionary.

Please check Other task types summary for the full list of the parameters for each decorator.