Scope

Artifact. This method is optional, only artifacts that declare one or more attributes need to define this function.

Expected behavior

The function ties a runtime environment to the artifact installation manager. It is responsible for producing values for artifact attributes whenever such values are required at runtime to check that an artifact is installed with a certain combination of attributes. Let’s consider an example. Consider a alignment program that you wish to install as an artifact. Installing the executable is straightforward. However, building a genome index the first time that this artifact is needed will require information about the target organism. For instance, when an end-user starts an alignment job for reads from the “Mus musculus” organism, the artifact installation manager needs to prepare a “Mus musculus” index. The GobyWeb runtime environment exposes the ORGANISM variable, but how do we tie this information with artifact installation? The solution is to declare an ORGANISM attribute for the INDEX artifact for this alignment program resource:

<artifacts> <artifact id="EXECUTABLE"/> <artifact id="INDEX"> <attributes> <attribute name="organism"/> </attributes> </artifact> </artifacts>

Assuming that you have declared the organism attribute has shown above, then the script function will need to provide a value for the organism attribute at runtime, when the INDEX artifact is processed.

Input arguments

The function receives the following arguments:

  • $1: the ID of the artifact to install as specified in the resource configuration?
  • $2: output file where to write java properties output.

Assuming that we need to produce the organism attribute value, we can write the function as follows:

function get_attribute_values() {
id=$1
out=$2
echo "get_attribute_values for ID=${id}"
echo >>${out} "organism=${ORGANISM}"
exit 0
}

The get_attribute_values is especially useful should you need to transform environment variable values to remove space, replace character or compute other changes. Simply perform these changes before printing the attribute value.

Environment

The function has access to the environment variables that were populated in the PLUGIN_ROOT_LOCATION/artifacts-config/env.sh hook. Typically these variables include every variable that are visible to the plugin script that requested the resource.