idmtools.analysis.add_analyzer module¶
idmtools add analyzer.
More of an example.
Copyright 2021, Bill & Melinda Gates Foundation. All rights reserved.
- class idmtools.analysis.add_analyzer.AddAnalyzer(filenames=None, output_path='output')¶
Bases:
IAnalyzer
A simple base class to add analyzers.
Examples
# Example AddAnalyzer for EMOD Experiment # In this example, we will demonstrate how to create an AddAnalyzer to analyze an experiment's output file # First, import some necessary system and idmtools packages. from idmtools.analysis.analyze_manager import AnalyzeManager from idmtools.analysis.add_analyzer import AddAnalyzer from idmtools.core import ItemType from idmtools.core.platform_factory import Platform if __name__ == '__main__': # Set the platform where you want to run your analysis # In this case we are running in BELEGOST, but this can be changed to run 'Local' with Platform('BELEGOST') as platform: # Arg option for analyzer init are uid, working_dir, data in the method map (aka select_simulation_data), # and filenames # In this case, we want to provide a filename to analyze filenames = ['StdOut.txt'] # Initialize the analyser class with the name of file to save to and start the analysis analyzers = [AddAnalyzer(filenames=filenames)] # Set the experiment you want to analyze experiment_id = '6f305619-64b3-ea11-a2c6-c4346bcb1557' # comps exp id # Specify the id Type, in this case an Experiment manager = AnalyzeManager(ids=[(experiment_id, ItemType.EXPERIMENT)], analyzers=analyzers) manager.analyze()
- __init__(filenames=None, output_path='output')¶
Initialize our analyzer.
- Parameters:
filenames – Filename to fetch
output_path – Path to write output to
- filter(item: Union[IWorkflowItem, Simulation])¶
Filter analyzers. Here we want all the items so just return true.
- Parameters:
item – Item to filter
- Returns:
True
- initialize()¶
Initialize our analyzer before running it.
We use this to create our output directory.
- Returns:
None
- map(data, item: Union[IWorkflowItem, Simulation])¶
Run this on each item and the files we retrieve.
- Parameters:
data – Map of filesnames -> content
item – Item we are mapping
- Returns:
Values added up
- reduce(data)¶
Combine all the data we mapped.
- Parameters:
data – Map of results in form Item -> map results
- Returns:
Sum of all the results