CHAP.pipeline
¶
File : pipeline.py
Author : Valentin Kuznetsov
Module Contents¶
Classes¶
Pipeline represent generic Pipeline class |
|
Wrapper for all results of PipelineItem.execute |
|
An object that can be supplied as one of the items
|
|
An object to deliver results from multiple |
API¶
- class CHAP.pipeline.Pipeline(items=None, kwds=None)¶
Pipeline represent generic Pipeline class
Initialization
Pipeline class constructor
- Parameters:
items – list of objects
kwds – list of method args for individual objects
- execute()¶
execute API
- class CHAP.pipeline.PipelineData(name=None, data=None, schema=None)¶
Bases:
dict
Wrapper for all results of PipelineItem.execute
Initialization
Initialize self. See help(type(self)) for accurate signature.
- class CHAP.pipeline.PipelineItem¶
An object that can be supplied as one of the items
Pipeline.items
Initialization
Constructor of PipelineItem class
- static unwrap_pipelinedata(data)¶
Given a list of PipelineData objects, return a list of their “data” values.
- Parameters:
data (list[PipelineData]) – input data to read, write, or process that needs to be unrapped from PipelineData before use
- Returns:
just the “data” values of the items in
data
- Return type:
list[object]
- get_config(data, schema, remove=True, **kwargs)¶
Look through
data
for an item whose value for the first'schema'
key matchesschema
. Convert the value for that item’s'data'
key into the configurationBaseModel
identified byschema
and return it.- Parameters:
data (list[PipelineData].) – Input data from a previous
PipelineItem
schema (str) – Name of the
BaseModel
class to match indata
& return,remove (bool, optional) – If there is a matching entry in
data
, remove it from the list, defaults toTrue
.
- Raises:
ValueError – If there’s no match for
schema
indata
.- Returns:
The first matching configuration model.
- Return type:
BaseModel
- get_data(data, name, remove=True)¶
Look through
data
for an item whose value for the first'name'
key matchesname
and return it.- Parameters:
data (list[PipelineData].) – Input data from a previous
PipelineItem
name (str) – Name of the data item to match in
data
& return.remove (bool, optional) – If there is a matching entry in
data
, remove it from the list, defaults toTrue
.
- Raises:
ValueError – If there’s no match for
name
indata
.- Returns:
The first matching data item.
- execute(schema=None, **kwargs)¶
Run the appropriate method of the object and return the result.
- Parameters:
schema (str) – the name of a schema associated with the data that will be returned
kwargs (dict) – a dictionary of any positional and keyword arguments to supply to the read, process, or write method.
- Returns:
the wrapped result of running read, process, or write.
- Return type:
list[PipelineData]
- class CHAP.pipeline.MultiplePipelineItem¶
Bases:
CHAP.pipeline.PipelineItem
An object to deliver results from multiple
PipelineItem
s to a singlePipelineItem
in thePipeline.execute()
method.Initialization
Constructor of PipelineItem class
- execute(items=[], **kwargs)¶
Independently execute all items in
self.items
, then return all of their results.- Parameters:
items (list) – PipelineItem configurations
- Return type:
list[PipelineData]