Momotor Bundles documentation

The momotor-bundles package contains the interfaces to read and write Momotor bundles.

A Momotor bundle is an XML document with optional attachments. Bundles without attachments can be pure XML documents, bundles with attachments are contained in zip files.

Bundles are at the heart of a Momotor transformation, as a Momotor transformation takes a recipe, config and product bundle as input and produces a result bundle as output.

The recipe bundle describes the transformations that need to be performed, the config bundle provides additional files and configuration to the recipe, while the product bundle defines the job specific files and configuration.

In an educational setting, the recipe defines a generic way to process a student’s submission, while the config defines the assignment specific details like the expected answers. The product contains the student’s submission.

Implemented functionality

The current version of the momotor-bundles package is not fully feature-complete. The meta tag of the bundles is currently not implemented for any bundle. Reading all bundle types is fully implemented except for the meta tag.

Example usage

Reading configuration bundle

The following example loads a configuration bundle and reads an option value from it in several ways:

Considering the following config.xml file:

<?xml version="1.0" encoding="UTF-8"?>
<config xmlns=""

        <option name="is_this_cool"><true/></option>
        <option name="inline_text">Inline text option</option>

    <options domain="example">
        <option name="time" type="integer" value="10" />


The following Python script will print the values of the options in several ways:

import contextlib
from momotor.bundles import ConfigBundle

with contextlib.closing(ConfigBundle.from_file_factory('config.xml')) as bundle:
   print('Options of',

   # Looping over all options and printing some attributes:
   for option in bundle.options:
       # option is of type momotor.bundles.elements.Option
       print(option.domain,, repr(option.value))

   # Directly access an option using the get_option_value method:
   print('Direct access of time:', bundle.get_option_value('time', domain='example'))

Creating result bundle

The following example will create a result bundle with some properties and write a result.xml:

from momotor.bundles import ResultsBundle
from momotor.bundles.elements.results import Result
from import Property

bundle = ResultsBundle()
            Property(bundle).create(name='status', type='string', value='OK'),
            Property(bundle).create(name='report', type='string', value='this is the report'),
bundle.to_file('result.xml', pretty_xml=True)


Indices and tables