Saving Data

MATS provides a very flexible module for saving data.


The builtin ArchiveManager is the default class built for saving data. The ArchiveManager really implements one method, save(). The save() method accepts a dict as the parameter which contains key: value pairs containing the results of a single test execution.

There is a very specific format for the dictionary which is passed into the save() method. The keys will represent the heading names. The values of the dict will also be of a dict type and will contain a “value” key with a value. There is an optional nested “criteria” key which will contain the “pass_if”, “min” and “max” criteria, also as a dict. An example would best illustrate:

  'datetime': {'value': '2021-01-05 22:07:26.181921'},
  'pass': {'value': True},
  'failed': {'value': '[]'},
  'communications test': {
    'value': True,
    'criteria': {'pass_if': True}
  'pump flow test': {
    'value': 6.281,
    'criteria': {'min': 5.6, 'max': 6.4}

This dictionary will create the first row of data output below. Any custom save() would need to support this data format.

Default Output Format

The default ArchiveManager output format is in the form of a tab-separated values file with the pass-fail criteria placed at the top of the file.

Note that the spacing is a bit off because the tabs are not aligned well. This file will import into packages such as pandas quite well using:

pd.read_csv('./path/to/file.txt', delimiter='\t', skiprows=3)

Custom ArchiveManager Implementations

To create your own custom implementation that will save your data, you must:

  1. Implement a new class which contains a save() method which accepts a single dict as its parameter.
  2. Create an instance of your new custom class:
mam = MyArchiveManager()
  1. Supply the new instance to your test sequence:
ts = TestSequence(
    sequence=[T1(), T2()],

On every test execution, your new custom save() method will be called and supplied with the data for one execution of your test sequence.