pipeline.infrastructure.vdp

vdp is a pipeline framework module that contains classes to make writing task Inputs easier.

  • InputsContainer lets task implementations operate within the scope of a single measurement set, even if the pipeline run contains multiple data sets.

  • VisDependentProperty is a reworking of pipeline properties to reduce the amount of boilerplate code required to implement an Inputs class.

Implementation details:

See the documentation on the classes, particularly VisDependentProperty, for detailed information on how the framework operates.

Examples

There are three common scenarios that use VisDependentProperty. The following examples show each scenario for an Inputs property belonging to an Inputs class that extends vdp.StandardInputs.

  1. To provide a default value that can be overridden on a per-MS basis. Use the optional ‘default’ argument to VisDependentProperty, eg:

    myarg = VisDependentProperty(default=’some value’)

  2. For more sophisticated default values, e.g., a default value that is a function of other data or properties, use the @VisDependentProperty decorator. A class property decorated with @VisDependentProperty should return the default value for that property. The function will execute in the scope of a single measurement set, i.e., at the time it is called, vis is set to exactly one value. The function will be called to provide a default value for any measurement set that does not have a user override value.

    @VisDependentProperty def myarg():

    # do some processing then return the calculated value return ‘I am a custom property for measurement set %s’ % self.vis

  3. Convert or validate user input before accept it as an Inputs argument. Use the @VisDependentProperty.convert decorator, possibly alongside the getter decorator as above.

    @VisDependentProperty def myarg():

    # this will return 100 - but only if the user has not supplied # an override value! return 100

    @VisDependentProperty.convert def myarg(user_input):

    # convert then return the user input which is provided as an # argument to the convert decorator. The converted value will be # returned for all subsequent ‘gets’. return int(user_input)

Functions

all_unique(o)

Return True if all elements in the iterable argument are unique.

format_value_list(val)

gen_hash(o)

Makes a hash from a dictionary, list, tuple or set to any level, that contains only other hashable types (including any lists, tuples, sets, and dictionaries).

get_properties(inputs_cls)

name_all_arguments(cls, *args, **kwargs)

Classes

InputsContainer(task_cls, context, *args, …)

InputsContainer is the top-level container object for all task Inputs.

ModeInputs(context[, mode])

ModeInputs is a facade for Inputs of a common task type, allowing the user to switch between task implementations by changing the ‘mode’ parameter.

NoDefaultMarker(*args, **kwargs)

NoDefaultMarker is a class that represents the null “parameter not-set” case for default values.

NullMarker(null_input)

NullMarker is a class that represents the null “parameter not-set” case.

PipelineInputsMeta(name, bases, attrs)

Sets the name of a VisDependentProperty at class definition time.

SingletonType

SingletonType is a metaclass that ensures that only a single instance of a class exists.

StandardInputs()

VisDependentProperty([fdefault, fconvert, …])

VisDependentProperty is a Python data descriptor that standardises the behaviour of pipeline Inputs properties and lets them create default values more easily.