schrodinger.tasks.maptasks module¶
- class schrodinger.tasks.maptasks.MapTaskMixin¶
Bases:
object
A mixin for tasks that process a list of input items and produce a list of output items of a defined type.
Input that is static for all input items is defined in the Settings class.
To use, subclasses must define the following: - InputItem: The type of the input items. - OutputItem: The type of the output items. - combineFunction: A function that takes the settings, processes the input items, and sets the task.output.output_items (or otherwise save the output, for example to a file or a database).
In keeping with standard tasks API, input items may be set in task.input (either via input_items or input_file). However, the input items may also be set via an input generator. If an input generator is set, it will be used instead of input_items or input_file. The input generator should yield InputItem objects. This allows for more complex input sources, such as reading from a database or an API, or generating input items on the fly.
Similarly, the output items are appended to task.output.output_items by default. However, an output handler may be set to handle the output items in a custom way. The output handler should take a single OutputItem object. This allows for more complex output handling, such as writing to a database or an API, or processing the output items in a custom way.
- InputItem = NotImplemented¶
- OutputItem = NotImplemented¶
- class Settings(*args, _param_type=<object object>, **kwargs)¶
Bases:
CompoundParam
- initializeValue()¶
- setInputGenerator(generator)¶
Set an input generator for the task. This generator should yield InputItem objects. If set, this generator will be used instead of input_items or input_file.
- setOutputHandler(func)¶
Set an output handler for the task. This function should take a single OutputItem object. If set, this function will be called for each output item instead of appending the output items to output.output_items.
- combineFunction(settings)¶
The combineFunction is responsible for getting inputs via _generateInputItems, processing them in conjunction with the settings, and calling _handleOutputItem for each output item.
This method should be implemented by subclasses.
- mainFunction()¶
- checkForOneInputSource()¶
- class schrodinger.tasks.maptasks.MapTask(*args, _param_type=<object object>, **kwargs)¶
Bases:
MapTaskMixin
,ComboJobTask
A task that processes a sequence of input items through a map function and produces a sequence of output items.
To use, subclasses must define the InputItem and OutputItem types, and implement the mapFunction method.
- combineFunction(settings)¶
The combineFunction is responsible for getting inputs via _generateInputItems, processing them in conjunction with the settings, and calling _handleOutputItem for each output item.
This method should be implemented by subclasses.
- mapFunction(item, settings)¶
Implement in subclasses to process a single item of type InputItem and yield any number of output items of type OutputItem.
- class Input(*args, _param_type=<object object>, **kwargs)¶
Bases:
Settings
- Variables:
input_items – A list of input items.
input_file – A file containing input items.
- input_fileChanged¶
A
pyqtSignal
emitted by instances of the class.
- input_fileReplaced¶
A
pyqtSignal
emitted by instances of the class.
- input_items: list[NotImplemented]¶
A parameter of the class.
- input_itemsChanged¶
A
pyqtSignal
emitted by instances of the class.
- input_itemsReplaced¶
A
pyqtSignal
emitted by instances of the class.
- class Output(*args, _param_type=<object object>, **kwargs)¶
Bases:
CompoundParam
- output_items: list[NotImplemented]¶
A parameter of the class.
- output_itemsChanged¶
A
pyqtSignal
emitted by instances of the class.
- output_itemsReplaced¶
A
pyqtSignal
emitted by instances of the class.
- calling_contextChanged¶
A
pyqtSignal
emitted by instances of the class.
- calling_contextReplaced¶
A
pyqtSignal
emitted by instances of the class.
- failure_infoChanged¶
A
pyqtSignal
emitted by instances of the class.
- failure_infoReplaced¶
A
pyqtSignal
emitted by instances of the class.
- input: parameters.CompoundParam¶
A parameter of the class.
- inputChanged¶
A
pyqtSignal
emitted by instances of the class.
- inputReplaced¶
A
pyqtSignal
emitted by instances of the class.
- job_configChanged¶
A
pyqtSignal
emitted by instances of the class.
- job_configReplaced¶
A
pyqtSignal
emitted by instances of the class.
- max_progressChanged¶
A
pyqtSignal
emitted by instances of the class.
- max_progressReplaced¶
A
pyqtSignal
emitted by instances of the class.
- nameChanged¶
A
pyqtSignal
emitted by instances of the class.
- nameReplaced¶
A
pyqtSignal
emitted by instances of the class.
- output: parameters.CompoundParam¶
A parameter of the class.
- outputChanged¶
A
pyqtSignal
emitted by instances of the class.
- outputReplaced¶
A
pyqtSignal
emitted by instances of the class.
- progressChanged¶
A
pyqtSignal
emitted by instances of the class.
- progressReplaced¶
A
pyqtSignal
emitted by instances of the class.
- progress_stringChanged¶
A
pyqtSignal
emitted by instances of the class.
- progress_stringReplaced¶
A
pyqtSignal
emitted by instances of the class.
- statusChanged¶
A
pyqtSignal
emitted by instances of the class.
- statusReplaced¶
A
pyqtSignal
emitted by instances of the class.