I/O and Run Specifications

When creating an executable, an input specification and output specification can be given to indicate the expected inputs and outputs, and a run specification must be given to specify what is needed to and how to run the executable. For an applet, these specifications are optional and must be supplied upon creation of the executable. Applets are created in the "closed" state, so the specifications are immutable thereafter. For apps, both the input and output specifications are required in order to promote interoperability between apps with compatible inputs and outputs. Unlike applets, apps may be modified up until they are published (see the Apps for more details on how apps behave). In addition to these specifications, apps and applets can also request additional access in the form of network access or extra project and developer permissions. Note that the project permissions given to the executable will never be greater than those of the user running the executable.

Input Specification

The input specification is an array of input parameter descriptors that define the inputs that the executable expects to run. The order of inputs in the array determines the order in which they will be rendered on the DNAnexus website when a user tries to configure and launch the executable through the website. If an input specification is not provided, then an applet can be run with any input, which will not be validated for input argument names or types. An input parameter descriptor is a hash with the following key/value pairs:

  • name string Name of the input; it must be unique across the inputs. Each input name must match the regular expression ^[a-zA-Z_][0-9a-zA-Z_]*$ (only letters and numbers, at least one char, does not start with a number).
  • class string The class of the input. This could be any data object class supported by the platform (such as "record", "file", etc.), in which case a link to an object ID must be provided for that input when the executable is run. In addition to data object classes, the following value classes are supported:

    • "int" represents a decimal integer; a JSON number must be given
    • "float" represents a decimal floating-point number; a JSON number must be given
    • "string" represents a string; a JSON (UTF-8) string must be given
    • "boolean" represents a boolean; the JSON value true or false must be given
    • "hash" represents an arbitrary JSON object

    The input class name (other than "hash") can be preceded by the string "array:", e.g. "array:file", to indicate that the input must be a nonempty JSON array of links to objects of the corresponding class.

  • optional boolean (optional, default false) Whether this input is optional

  • default input class (optional) A value to which the input will be set if omitted when running the executable. This value is also used to provide information about default values to the user, when they attempt to configure and launch the executable through DNAnexus’ website. If not provided, then this input must be always given when launching the executable.

    • In addition to literal values, symbolic metadata references can be used as default values, for example:
      {"inputSpec": [
        {"name": "mappings_bam", "class": "file"},
        {"name": "sample_id", "class": "string", "default":
          {"$dnanexus_link": {"input": "mappings_bam",
                              "metadata": "properties.sample_id"}}
        }
      ]}
      
  • type string or mapping (optional) A constraint on the type that the input object must be tagged with (this is valid only for inputs whose class is a data object class). If not provided, no type constraints will be required. Constraints are specified via the following grammar:

      constraint ::= <string>
      constraint ::= { "$and": [ constraint, constraint,  ] }
      constraint ::= { "$or": [ constraint, constraint, ] }
    
    The "$and" operator means that all constraints need to be satisfied; the "$or" operator means that at least one constraint needs to be satisfied. A <string> represents a type that the object must have in its types. For example, to say that an object must be of type "Reads", and with either "LetterReads" or "ColorReads", specify the following constraint:
    {"$and": ["Reads", {"$or": ["LetterReads", "ColorReads"]}]}
    
  • patterns array of strings (optional) List of strings denoting name patterns for this input. This array is stored and returned verbatim by the API as part of the executable's description. Example: {"patterns": ["*.sam", "*.bam"]}. By convention, clients may use this array to filter objects displayed to the user as possible inputs for the executable; and to infer compatibility between executable outputs and inputs, if no types are specified.

  • suggestions array of input class (optional) List of suggested possible values and/or, for the case of data object inputs, an annotated hash which provides a suggested value or a project/folder path in which possible inputs can be found. For data object inputs, when the input specification is read back out via e.g. /applet-xxxx/describe an annotated hash will always be returned. (For example, if {"$dnanexus_link": "file-xxxx"} was supplied as a suggestion to /applet/new, when the resulting applet was described the same suggestion would be read out as {"value": {"$dnanexus_link": "file-xxxx"}}.) An annotated hash has the following key/value pairs:

    • name string (optional) Name for the suggestion
    • value input class (optional; required if project is not provided) A suggested value
    • project string (optional; required if path is provided and if value is not) ID of the project containing suggested inputs
    • path string (optional; can only be present if project is also present) Folder path inside project in which to suggest inputs
    • region string (this field is not accepted when specifying an input specification to an API call, but it may be returned when making an API call that returns an input specification) Region of the specified project or data object. This field is set if and only if this is a data object input. Clients are advised to use this field to restrict the list of suggestions displayed to the user to only show values that are in the same region as the project in which the executable is being run.

    Below are some examples shown in an excerpt of an input specification:

    {
      "inputSpec": [
        {
          "name": "reference",
          "class": "file",
          "suggestions": [
            {"name": "Reference Genomes", "project": "project-xxxx", "path": "/mm9/bwa"},
            {"name": "Modest Mouse","value": {"$dnanexus_link": {"project": "project-xxxx","id": "file-xxxx"}}},
            {"name": "Deadmau5", "value": {"$dnanexus_link": "file-xxxx"}},
            {"$dnanexus_link": "file-xxxx"}
          ]
        }
      ]
    }
    
    Note that for array inputs each element in the suggestions array should be a suggested value to be included in the array input. Thus for input of class "array:int", the value of suggestions should therefore be an array of integers (and not an array of integer arrays).
  • choices array of input class (optional) Indicate a list of the only possible values that the input field can take. The annotated syntax described under suggestions may also be used to annotate objects with a name, but a path cannot be provided.

    Also similar to the syntax for suggestions, the value of choices is expected to be an array of the enclosed class and not an array of arrays when the input class is an array. At runtime, the system will expect an array that is composed of elements that appear in the choices array.

  • label string (optional) Human-readable label for the input field to use in place of name for display purposes

  • group string (optional) Name for the group of settings this input field belongs to, which will be used when displaying this field in the UI under different tabs or sections. If not supplied, the input parameter will belong to the first and default group. By convention, groups will be shown in order of first appearance in the input specification with the unnamed group always appearing first.

  • help string (optional) A longer description of the input field

Output Specification

The output specification is an array of output descriptors that describe the outputs that an executable produces. If an output specification is not given for an applet, then it can produce any output, which will not be validated. An output descriptor is a hash supporting the same fields as the fields of an entry in the inputs array described earlier, except the following fields:

  • default
  • suggestions
  • choices

Run Specification

The run specification specifies how to run the executable and is a hash with the following key/values:

  • code string Source code of the executable (the script that will be run)
  • interpreter string The interpreter which will run code; must be one of the supported interpreters: "bash", "python2.7"
  • systemRequirements mapping (optional) Request specific resources for each of the executable's stages.
    • key Entry point name of the executable, or "*" to indicate all entry points that are otherwise not present as keys; use "main" for the initial entry point, or the function name run in /job/new for a subjob
    • value mapping Requested resources for the stage with key/values:
      • instanceType (default "mem2_hdd2_x2") A string specifying the instance type on which an Execution Environment will be set up to run your job. See Instance Types for a list of possible values.
  • executionPolicy mapping (optional) A collection of options that govern automatic job restart upon certain types of failures; this can only be set at the user-level API call (jobs cannot override this for their subjobs). Includes the following optional key/values:
    • restartOn mapping (optional; default is {"UnresponsiveWorker": 2, "JMInternalError": 1, "ExecutionError": 1}) Indicate a job restart policy
      • key A restartable failure reason ("ExecutionError", "UnresponsiveWorker", "JMInternalError", "AppInternalError", or "JobTimeoutExceeded") or "*" to indicate all restartable failure reasons that are otherwise not present as keys
      • value int Maximum number of restarts for the failure reason
    • maxRestarts int (optional, default 9) Non-negative integer less than 10, indicating the maximum number of times that the job will be restarted
  • timeoutPolicy mapping (optional) User-specified default timeout policy, configurable by entry point, for jobs running this executable. If unspecified, it indicates that no jobs running this executable will have a default timeout policy. This default timeout policy may be overridden at runtime. If present, includes at least one of the following key-value pairs:
    • key Entry point name or "*" to indicate all entry points not explicitly specified in timeoutPolicy. If an entry point name is not explicitly specified and "*" is not present, then a job running this executable at that entry point will not have a default timeout.
    • value mapping Default timeout for a job running this executable at the corresponding entry point. Includes at least one of the following key-value pairs:
      • key Unit of time; one of "days", "hours", or "minutes".
      • value number Amount of time for the corresponding time unit; must be nonnegative. The effective default timeout is the sum of the units of time represented in this mapping. Note that setting the effective timeout to 0 is the same as specifying null for the corresponding executable at the corresponding entry point.
  • bundledDepends array of mappings (optional) List of file objects (assets) to be placed the execution environment before the job is run. The files will be downloaded to "/" on the worker and unpacked if compressed (with a mechanism that supports at least tar, gz, and other popular formats). Note that these files must exist in the project in which the executable is being run or given as part of the input. Each element is a mapping with the following key/values:
    • name string Name of the asset.
    • id mapping DNAnexus link to the asset, with key/value:
      • $dnanexus_link string ID of the file
    • stages array of strings (optional, default all stages) List of the entry points of the executable for which the asset should be fetched; use "main" for the initial entry point, or the function name run in /job/new for a subjob
  • distribution string (optional, default "Ubuntu") The Linux operating system distribution to be used to run this executable's jobs. The only recognized value is "Ubuntu".
  • release string (optional, default "12.04") The Linux operating system release to be used to run this executable's jobs. If release is set, distribution must also be set. Recognized values are 12.04 and 14.04.
  • execDepends array of mappings (optional) Specify package names and versions to be installed by the system package manager or a language-specific package manager in the execution environment before the executable is run. Each element has the key/values:

    • name string Name of the package to be installed.
    • package_manager string (optional, default "apt") The package manager used to install this package; valid options are "apt", "pip", "gem", "cpan", "cran", and "git"
    • version string (optional) Version of the package to be installed; unsupported when package_manager is "git"
    • stages array of strings (optional, default all stages) List of the entry points of the executable for which the package should be installed; use "main" for the initial entry point, or the function name run in /job/new for a subjob

    Git-specific arguments: See Execution Environment Reference (Software Packages) for more information about Git-specific arguments in execDepends.

  • restartableEntryPoints string (optional, default "master") Indicates which entry points of the executable are restartable when a restartable error occurs; see the entry for executionPolicy.restartOn above for details on which errors are restartable. If a string, then restartableEntryPoints must be one of "master" or "all". The value "master" indicates that only master job entry points are restartable, whereas "all" indicates that all entry points, including subjob entry points, are restartable; please ensure that all entry points of the executable are idempotent before specifying "all".

These fields are only returned in the responses of /app-xxxx[/yyyy]/describe and /applet-xxxx/describe. They should not be specified as input to /applet/new

  • systemRequirementsByRegion mapping Mapping that contains the specific resources requested for each of the executable's stages, by region. See systemRequirements above for more information regarding requesting resources for an executable's stages.
    • key Name of an enabled region of the executable. For applets, there should only be one key, because they are single-region.
    • value mapping A mapping specifying the the specific resources requested for each of the app's stages for when the app is run in the corresponding region. The syntax of this mapping is like that of systemRequirements above.
  • bundledDependsByRegion mapping Mapping that contains the bundled dependencies of the executable (app or applet) in each region in which the executable may be run. See bundledDepends above for more information regarding bundled dependencies.
    • key Name of the region (e.g., "aws:us-east-1") in which this executable may be run.
    • value array of strings Array of bundled dependencies for the executable in the corresponding region.

Two run specifications are equivalent if and only if all of their fields are equal, with the exception of the following fields

  • systemRequirementsByRegion
  • systemRequirements
  • bundledDependsByRegion
  • bundledDepends

Access Requirements

Executables can request additional network access, or additional DNAnexus permissions in the form of project permissions or the ability to perform app development-related tasks on the behalf of the user. App development-related tasks include those of creating, modifying, and publishing apps, as well as adding and removing authorized developers for a particular app. To request additional access, provide a mapping with the following key/values:

  • network array of strings (optional) List of hostnames, hostname wildcards, network masks, and/or the string "*" (for unrestricted access) specifying which Internet hosts, domains, or subnets the executable will be permitted to access. If omitted, the executable has no network access, except to the API server.
  • project string (optional) A string from "VIEW", "UPLOAD", "CONTRIBUTE", and "ADMINISTER". The executable will have this permissions level in the project it was launched in, or the user’s permissions level, whichever is lower. Note: by default, applets but not apps have VIEW access to the project they are launched from.
  • allProjects string (optional) A string from "VIEW", "UPLOAD", "CONTRIBUTE", and "ADMINISTER". The executable will have this permissions level in all projects the user has access to, or the user’s permissions level, whichever is lower. If omitted, the executable will have no extra permissions.
  • developer boolean (optional) Whether the executable will have permission to act with the same developer permissions as the user launching it.
  • projectCreation boolean (optional) Whether the executable will be able to create projects on behalf of the user; jobs will have ADMINISTER access to projects they create, regardless of what the value of allProjects is set to. Note that within the same job tree, jobs will receive access to projects created by any ancestor jobs, but they will not be able to access jobs created by their own descendant jobs.

Last edited by pnguyen, 2017-06-13 14:50:57

 Feedback