popmon.io package
Submodules
popmon.io.file_reader module
- class popmon.io.file_reader.FileReader(store_key, file_path, apply_func=None, **kwargs)
Bases:
Module
Module to read contents from a file, transform the contents with a function and write them to the datastore.
- __init__(store_key, file_path, apply_func=None, **kwargs)
Initialize an instance.
- Parameters
store_key (str) – key of input data to be stored in the datastore
file_path (str) – the file path to read the data from
apply_func (callable) – function to be used for the transformation of data (optional)
kwargs (dict) – additional keyword arguments which would be passed to apply_func
- transform()
Central function of the module.
Typically transform() takes something from the datastore, does something to it, and puts the results back into the datastore again, to be passed on to the next module in the pipeline.
- Parameters
datastore (dict) – input datastore
- Returns
updated output datastore
- Return type
dict
popmon.io.file_writer module
- class popmon.io.file_writer.FileWriter(read_key, store_key=None, file_path=None, apply_func=None, **kwargs)
Bases:
Module
Module transforms specific datastore content and writes it to a file.
- __init__(read_key, store_key=None, file_path=None, apply_func=None, **kwargs)
Initialize an instance.
- Parameters
read_key (str) – key of input histogram-dict to read from data store
store_key (str) – key of output data to store in data store (optional)
file_path (str) – the file path where to output the report (optional)
apply_func (callable) – function to be used for the transformation of data (optional)
kwargs (dict) – additional keyword arguments which would be passed to apply_func
- transform(data)
Central function of the module.
Typically transform() takes something from the datastore, does something to it, and puts the results back into the datastore again, to be passed on to the next module in the pipeline.
- Parameters
datastore (dict) – input datastore
- Returns
updated output datastore
- Return type
dict
popmon.io.json_reader module
- class popmon.io.json_reader.JsonReader(file_path, store_key)
Bases:
FileReader
Read json file’s contents into the datastore.
- __init__(file_path, store_key)
Initialize an instance.
- Parameters
store_key (str) – key of input data to be stored in the datastore
file_path (str) – the file path to read the data from
- transform(*args)
Central function of the module.
Typically transform() takes something from the datastore, does something to it, and puts the results back into the datastore again, to be passed on to the next module in the pipeline.
- Parameters
datastore (dict) – input datastore
- Returns
updated output datastore
- Return type
dict