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.
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')
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
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)
Classes¶
|
InputsContainer is the top-level container object for all task Inputs. |
|
ModeInputs is a facade for Inputs of a common task type, allowing the user to switch between task implementations by changing the 'mode' parameter. |
|
VisDependentProperty is a Python data descriptor that standardises the behaviour of pipeline Inputs properties and lets them create default values more easily. |