collectorplugins Package

collectorplugins Package

jsoncollector Module

class fastr.resources.plugins.collectorplugins.jsoncollector.JsonCollector[source]

Bases: fastrinterface.CollectorPlugin

The JsonCollector plugin allows a program to print out the result in a pre-defined JSON format. It is then used as values for fastr.

The working is as follows:

  1. The location of the output is taken
  2. If the location is None, go to step 5
  3. The substitutions are performed on the location field (see below)
  4. The location is used as a regular expression and matched to the stdout line by line
  5. The matched string (or entire stdout if location is None) is loaded as a json
  6. The data is parsed by set_result

The structure of the JSON has to follow the a predefined format. For normal Nodes the format is in the form:

[value1, value2, value3]

where the multiple values represent the cardinality.

For a FlowNodes the format is the form:

{
  'sample_id1': [value1, value2, value3],
  'sample_id2': [value4, value5, value6]
}

This allows the tool to create multiple output samples in a single run.

__abstractmethods__ = frozenset()
__init__()[source]

Constructor

__module__ = 'fastr.resources.plugins.collectorplugins.jsoncollector'

pathcollector Module

class fastr.resources.plugins.collectorplugins.pathcollector.PathCollector[source]

Bases: fastrinterface.CollectorPlugin

The PathCollector plugin for the FastrInterface. This plugin uses the location fields to find data on the filesystem. To use this plugin the method of the output has to be set to path

The general working is as follows:

  1. The location field is taken from the output
  2. The substitutions are performed on the location field (see below)
  3. The updated location field will be used as a regular expression filter
  4. The filesystem is scanned for all matching files/directory

The special substitutions performed on the location use the Format Specification Mini-Language Format Specification Mini-Language. The predefined fields that can be used are:

  • inputs, an objet with the input values (use like {inputs.image[0]}) The input contains the following attributes that you can access:
    • .directory for the directory name (use like input.image[0].directory) The directory is the same as the result of os.path.dirname
    • .filename is the result of os.path.basename on the path
    • .basename for the basename name (use like input.image[0].basename) The basename is the same as the result of os.path.basename and the extension stripped. The extension is considered to be everything after the first dot in the filename.
    • .extension for the extension name (use like input.image[0].extension)
  • output, an object with the output values (use like {outputs.result[0]}) It contains the same attributes as the input
    • special.cardinality, the index of the current cardinality
    • special.extension, is the extension for the output DataType

Example use:

<output ... method="path" location="{output.directory[0]}/TransformParameters.{special.cardinality}.{special.extension}"/>

Given the output directory ./nodeid/sampleid/result, the second sample in the output and filetype with a txt extension, this would be translated into:

<output ... method="path" location="./nodeid/sampleid/result/TransformParameters.1.txt>
__abstractmethods__ = frozenset()
__init__()[source]

Constructor

__module__ = 'fastr.resources.plugins.collectorplugins.pathcollector'

stdoutcollector Module

class fastr.resources.plugins.collectorplugins.stdoutcollector.StdoutCollector[source]

Bases: fastrinterface.CollectorPlugin

The StdoutCollector can collect data from the stdout stream of a program. It filters the stdout line by line matching a predefined regular expression.

The general working is as follows:

  1. The location field is taken from the output
  2. The substitutions are performed on the location field (see below)
  3. The updated location field will be used as a regular expression filter
  4. The stdout is scanned line by line and the regular expression filter is applied

The special substitutions performed on the location use the Format Specification Mini-Language Format Specification Mini-Language. The predefined fields that can be used are:

  • inputs, an objet with the input values (use like {inputs.image[0]})
  • outputs, an object with the output values (use like {outputs.result[0]})
  • special which has two subfields:
    • special.cardinality, the index of the current cardinality
    • special.extension, is the extension for the output DataType

Note

because the plugin scans line by line, it is impossible to catch multi-line output into a single value

__abstractmethods__ = frozenset()
__init__()[source]

Constructor

__module__ = 'fastr.resources.plugins.collectorplugins.stdoutcollector'