Analyzers (IAnalyzer)
Analyzers define how to extract and aggregate data from simulation outputs. Every analyzer extends IAnalyzer, which provides the map-reduce interface.
What is an analyzer?
An IAnalyzer is a class you implement with two core methods:
map(data, simulation)— called once per simulation; receives the simulation's output files and returns any Python objectreduce(all_data)— called once after all simulations are mapped; receives{simulation: map_result}and produces the final output (CSV, plots, etc.)
You can optionally override:
initialize()— called once before mapping begins; use it to create output directories or load shared resourcesfilter(simulation)— returnTrueto include a simulation,Falseto skip itdestroy()— called afterreduce()completes; use it for cleanup
Constructor parameters
1 | |
| Parameter | Type | Default | Description |
|---|---|---|---|
uid |
str |
class name | Unique identifier for this analyzer instance. Auto-set to the class name if omitted. Must be unique when multiple analyzers are used together. |
working_dir |
str |
None |
Directory where analyzer output is written. Falls back to AnalyzeManager.working_dir if not set. |
parse |
bool |
True |
When True, idmtools parses output files into Python objects (e.g. JSON → dict). When False, you receive raw bytes and must parse them yourself — useful for custom binary formats or CSV files you want to read with pandas. |
filenames |
List[str] |
[] |
Paths of output files to retrieve from each simulation, relative to the simulation root (e.g. "output/result.json"). Only these files are downloaded. |
Basic custom analyzer
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | |
Filtering simulations
Override filter() to skip simulations that don't meet your criteria:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | |
Raw file access (parse=False)
Set parse=False to receive raw bytes and handle parsing yourself — useful for CSV files with non-standard formatting:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | |
Built-in analyzers
idmtools ships several ready-to-use analyzers:
DownloadAnalyzer
Downloads the specified files from each simulation into the local working directory without further processing:
1 2 3 | |
You can also subclass it:
1 2 | |
CSVAnalyzer
Reads CSV output files and concatenates them across all simulations into a single CSV keyed by simulation ID:
1 2 3 4 | |
TagsAnalyzer
Collects all simulation tags into a single CSV file — useful for documenting what parameters were used:
1 2 3 | |
AddAnalyzer
Reads a text-based output file and prints or accumulates its contents across simulations:
1 2 3 | |
Next steps
- AnalyzeManager — Run your analyzers locally
- PlatformAnalysis — Run your analyzers remotely on COMPS