sierra-research 1.3.11__py3-none-any.whl → 1.5.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- sierra/__init__.py +3 -3
- sierra/core/__init__.py +3 -3
- sierra/core/batchroot.py +223 -0
- sierra/core/cmdline.py +681 -1057
- sierra/core/compare.py +11 -0
- sierra/core/config.py +96 -88
- sierra/core/engine.py +306 -0
- sierra/core/execenv.py +380 -0
- sierra/core/expdef.py +11 -0
- sierra/core/experiment/__init__.py +1 -0
- sierra/core/experiment/bindings.py +150 -101
- sierra/core/experiment/definition.py +414 -245
- sierra/core/experiment/spec.py +83 -85
- sierra/core/exproot.py +44 -0
- sierra/core/generators/__init__.py +10 -0
- sierra/core/generators/experiment.py +528 -0
- sierra/core/generators/generator_factory.py +138 -137
- sierra/core/graphs/__init__.py +23 -0
- sierra/core/graphs/bcbridge.py +94 -0
- sierra/core/graphs/heatmap.py +245 -324
- sierra/core/graphs/pathset.py +27 -0
- sierra/core/graphs/schema.py +77 -0
- sierra/core/graphs/stacked_line.py +341 -0
- sierra/core/graphs/summary_line.py +506 -0
- sierra/core/logging.py +3 -2
- sierra/core/models/__init__.py +3 -1
- sierra/core/models/info.py +19 -0
- sierra/core/models/interface.py +52 -122
- sierra/core/pipeline/__init__.py +2 -5
- sierra/core/pipeline/pipeline.py +228 -126
- sierra/core/pipeline/stage1/__init__.py +10 -0
- sierra/core/pipeline/stage1/pipeline_stage1.py +45 -31
- sierra/core/pipeline/stage2/__init__.py +10 -0
- sierra/core/pipeline/stage2/pipeline_stage2.py +8 -11
- sierra/core/pipeline/stage2/runner.py +401 -0
- sierra/core/pipeline/stage3/__init__.py +12 -0
- sierra/core/pipeline/stage3/gather.py +321 -0
- sierra/core/pipeline/stage3/pipeline_stage3.py +37 -84
- sierra/core/pipeline/stage4/__init__.py +12 -2
- sierra/core/pipeline/stage4/pipeline_stage4.py +36 -354
- sierra/core/pipeline/stage5/__init__.py +12 -0
- sierra/core/pipeline/stage5/pipeline_stage5.py +33 -208
- sierra/core/pipeline/yaml.py +48 -0
- sierra/core/plugin.py +529 -62
- sierra/core/proc.py +11 -0
- sierra/core/prod.py +11 -0
- sierra/core/ros1/__init__.py +5 -1
- sierra/core/ros1/callbacks.py +22 -21
- sierra/core/ros1/cmdline.py +59 -88
- sierra/core/ros1/generators.py +159 -175
- sierra/core/ros1/variables/__init__.py +3 -0
- sierra/core/ros1/variables/exp_setup.py +122 -116
- sierra/core/startup.py +106 -76
- sierra/core/stat_kernels.py +4 -5
- sierra/core/storage.py +13 -32
- sierra/core/trampoline.py +30 -0
- sierra/core/types.py +116 -71
- sierra/core/utils.py +103 -106
- sierra/core/variables/__init__.py +1 -1
- sierra/core/variables/base_variable.py +12 -17
- sierra/core/variables/batch_criteria.py +387 -481
- sierra/core/variables/builtin.py +135 -0
- sierra/core/variables/exp_setup.py +19 -39
- sierra/core/variables/population_size.py +72 -76
- sierra/core/variables/variable_density.py +44 -68
- sierra/core/vector.py +1 -1
- sierra/main.py +256 -88
- sierra/plugins/__init__.py +119 -0
- sierra/plugins/compare/__init__.py +14 -0
- sierra/plugins/compare/graphs/__init__.py +19 -0
- sierra/plugins/compare/graphs/cmdline.py +120 -0
- sierra/plugins/compare/graphs/comparator.py +291 -0
- sierra/plugins/compare/graphs/inter_controller.py +531 -0
- sierra/plugins/compare/graphs/inter_scenario.py +297 -0
- sierra/plugins/compare/graphs/namecalc.py +53 -0
- sierra/plugins/compare/graphs/outputroot.py +73 -0
- sierra/plugins/compare/graphs/plugin.py +147 -0
- sierra/plugins/compare/graphs/preprocess.py +172 -0
- sierra/plugins/compare/graphs/schema.py +37 -0
- sierra/plugins/engine/__init__.py +14 -0
- sierra/plugins/engine/argos/__init__.py +18 -0
- sierra/plugins/{platform → engine}/argos/cmdline.py +144 -151
- sierra/plugins/{platform/argos/variables → engine/argos/generators}/__init__.py +5 -0
- sierra/plugins/engine/argos/generators/engine.py +394 -0
- sierra/plugins/engine/argos/plugin.py +393 -0
- sierra/plugins/{platform/argos/generators → engine/argos/variables}/__init__.py +5 -0
- sierra/plugins/engine/argos/variables/arena_shape.py +183 -0
- sierra/plugins/engine/argos/variables/cameras.py +240 -0
- sierra/plugins/engine/argos/variables/constant_density.py +112 -0
- sierra/plugins/engine/argos/variables/exp_setup.py +82 -0
- sierra/plugins/{platform → engine}/argos/variables/physics_engines.py +83 -87
- sierra/plugins/engine/argos/variables/population_constant_density.py +178 -0
- sierra/plugins/engine/argos/variables/population_size.py +115 -0
- sierra/plugins/engine/argos/variables/population_variable_density.py +123 -0
- sierra/plugins/engine/argos/variables/rendering.py +108 -0
- sierra/plugins/engine/ros1gazebo/__init__.py +18 -0
- sierra/plugins/engine/ros1gazebo/cmdline.py +175 -0
- sierra/plugins/{platform/ros1robot → engine/ros1gazebo}/generators/__init__.py +5 -0
- sierra/plugins/engine/ros1gazebo/generators/engine.py +125 -0
- sierra/plugins/engine/ros1gazebo/plugin.py +404 -0
- sierra/plugins/engine/ros1gazebo/variables/__init__.py +15 -0
- sierra/plugins/engine/ros1gazebo/variables/population_size.py +214 -0
- sierra/plugins/engine/ros1robot/__init__.py +18 -0
- sierra/plugins/engine/ros1robot/cmdline.py +159 -0
- sierra/plugins/{platform/ros1gazebo → engine/ros1robot}/generators/__init__.py +4 -0
- sierra/plugins/engine/ros1robot/generators/engine.py +95 -0
- sierra/plugins/engine/ros1robot/plugin.py +410 -0
- sierra/plugins/{hpc/local → engine/ros1robot/variables}/__init__.py +5 -0
- sierra/plugins/engine/ros1robot/variables/population_size.py +146 -0
- sierra/plugins/execenv/__init__.py +11 -0
- sierra/plugins/execenv/hpc/__init__.py +18 -0
- sierra/plugins/execenv/hpc/adhoc/__init__.py +18 -0
- sierra/plugins/execenv/hpc/adhoc/cmdline.py +30 -0
- sierra/plugins/execenv/hpc/adhoc/plugin.py +131 -0
- sierra/plugins/execenv/hpc/cmdline.py +137 -0
- sierra/plugins/execenv/hpc/local/__init__.py +18 -0
- sierra/plugins/execenv/hpc/local/cmdline.py +31 -0
- sierra/plugins/execenv/hpc/local/plugin.py +145 -0
- sierra/plugins/execenv/hpc/pbs/__init__.py +18 -0
- sierra/plugins/execenv/hpc/pbs/cmdline.py +30 -0
- sierra/plugins/execenv/hpc/pbs/plugin.py +121 -0
- sierra/plugins/execenv/hpc/slurm/__init__.py +18 -0
- sierra/plugins/execenv/hpc/slurm/cmdline.py +30 -0
- sierra/plugins/execenv/hpc/slurm/plugin.py +133 -0
- sierra/plugins/execenv/prefectserver/__init__.py +18 -0
- sierra/plugins/execenv/prefectserver/cmdline.py +66 -0
- sierra/plugins/execenv/prefectserver/dockerremote/__init__.py +18 -0
- sierra/plugins/execenv/prefectserver/dockerremote/cmdline.py +66 -0
- sierra/plugins/execenv/prefectserver/dockerremote/plugin.py +132 -0
- sierra/plugins/execenv/prefectserver/flow.py +66 -0
- sierra/plugins/execenv/prefectserver/local/__init__.py +18 -0
- sierra/plugins/execenv/prefectserver/local/cmdline.py +29 -0
- sierra/plugins/execenv/prefectserver/local/plugin.py +133 -0
- sierra/plugins/{hpc/adhoc → execenv/robot}/__init__.py +1 -0
- sierra/plugins/execenv/robot/turtlebot3/__init__.py +18 -0
- sierra/plugins/execenv/robot/turtlebot3/plugin.py +204 -0
- sierra/plugins/expdef/__init__.py +14 -0
- sierra/plugins/expdef/json/__init__.py +14 -0
- sierra/plugins/expdef/json/plugin.py +504 -0
- sierra/plugins/expdef/xml/__init__.py +14 -0
- sierra/plugins/expdef/xml/plugin.py +386 -0
- sierra/{core/hpc → plugins/proc}/__init__.py +1 -1
- sierra/plugins/proc/collate/__init__.py +15 -0
- sierra/plugins/proc/collate/cmdline.py +47 -0
- sierra/plugins/proc/collate/plugin.py +271 -0
- sierra/plugins/proc/compress/__init__.py +18 -0
- sierra/plugins/proc/compress/cmdline.py +47 -0
- sierra/plugins/proc/compress/plugin.py +123 -0
- sierra/plugins/proc/decompress/__init__.py +18 -0
- sierra/plugins/proc/decompress/plugin.py +96 -0
- sierra/plugins/proc/imagize/__init__.py +15 -0
- sierra/plugins/proc/imagize/cmdline.py +49 -0
- sierra/plugins/proc/imagize/plugin.py +270 -0
- sierra/plugins/proc/modelrunner/__init__.py +16 -0
- sierra/plugins/proc/modelrunner/plugin.py +250 -0
- sierra/plugins/proc/statistics/__init__.py +15 -0
- sierra/plugins/proc/statistics/cmdline.py +64 -0
- sierra/plugins/proc/statistics/plugin.py +390 -0
- sierra/plugins/{hpc → prod}/__init__.py +1 -0
- sierra/plugins/prod/graphs/__init__.py +18 -0
- sierra/plugins/prod/graphs/cmdline.py +269 -0
- sierra/plugins/prod/graphs/collate.py +279 -0
- sierra/plugins/prod/graphs/inter/__init__.py +13 -0
- sierra/plugins/prod/graphs/inter/generate.py +83 -0
- sierra/plugins/prod/graphs/inter/heatmap.py +86 -0
- sierra/plugins/prod/graphs/inter/line.py +134 -0
- sierra/plugins/prod/graphs/intra/__init__.py +15 -0
- sierra/plugins/prod/graphs/intra/generate.py +202 -0
- sierra/plugins/prod/graphs/intra/heatmap.py +74 -0
- sierra/plugins/prod/graphs/intra/line.py +114 -0
- sierra/plugins/prod/graphs/plugin.py +103 -0
- sierra/plugins/prod/graphs/targets.py +63 -0
- sierra/plugins/prod/render/__init__.py +18 -0
- sierra/plugins/prod/render/cmdline.py +72 -0
- sierra/plugins/prod/render/plugin.py +282 -0
- sierra/plugins/storage/__init__.py +5 -0
- sierra/plugins/storage/arrow/__init__.py +18 -0
- sierra/plugins/storage/arrow/plugin.py +38 -0
- sierra/plugins/storage/csv/__init__.py +9 -0
- sierra/plugins/storage/csv/plugin.py +12 -5
- sierra/version.py +3 -2
- sierra_research-1.5.0.dist-info/METADATA +238 -0
- sierra_research-1.5.0.dist-info/RECORD +186 -0
- {sierra_research-1.3.11.dist-info → sierra_research-1.5.0.dist-info}/WHEEL +1 -2
- sierra/core/experiment/xml.py +0 -454
- sierra/core/generators/controller_generator_parser.py +0 -34
- sierra/core/generators/exp_creator.py +0 -351
- sierra/core/generators/exp_generators.py +0 -142
- sierra/core/graphs/scatterplot2D.py +0 -109
- sierra/core/graphs/stacked_line_graph.py +0 -251
- sierra/core/graphs/stacked_surface_graph.py +0 -220
- sierra/core/graphs/summary_line_graph.py +0 -371
- sierra/core/hpc/cmdline.py +0 -142
- sierra/core/models/graphs.py +0 -87
- sierra/core/pipeline/stage2/exp_runner.py +0 -286
- sierra/core/pipeline/stage3/imagizer.py +0 -149
- sierra/core/pipeline/stage3/run_collator.py +0 -317
- sierra/core/pipeline/stage3/statistics_calculator.py +0 -478
- sierra/core/pipeline/stage4/graph_collator.py +0 -320
- sierra/core/pipeline/stage4/inter_exp_graph_generator.py +0 -240
- sierra/core/pipeline/stage4/intra_exp_graph_generator.py +0 -317
- sierra/core/pipeline/stage4/model_runner.py +0 -168
- sierra/core/pipeline/stage4/rendering.py +0 -283
- sierra/core/pipeline/stage4/yaml_config_loader.py +0 -103
- sierra/core/pipeline/stage5/inter_scenario_comparator.py +0 -328
- sierra/core/pipeline/stage5/intra_scenario_comparator.py +0 -989
- sierra/core/platform.py +0 -493
- sierra/core/plugin_manager.py +0 -369
- sierra/core/root_dirpath_generator.py +0 -241
- sierra/plugins/hpc/adhoc/plugin.py +0 -125
- sierra/plugins/hpc/local/plugin.py +0 -81
- sierra/plugins/hpc/pbs/__init__.py +0 -9
- sierra/plugins/hpc/pbs/plugin.py +0 -126
- sierra/plugins/hpc/slurm/__init__.py +0 -9
- sierra/plugins/hpc/slurm/plugin.py +0 -130
- sierra/plugins/platform/__init__.py +0 -9
- sierra/plugins/platform/argos/__init__.py +0 -9
- sierra/plugins/platform/argos/generators/platform_generators.py +0 -383
- sierra/plugins/platform/argos/plugin.py +0 -337
- sierra/plugins/platform/argos/variables/arena_shape.py +0 -145
- sierra/plugins/platform/argos/variables/cameras.py +0 -243
- sierra/plugins/platform/argos/variables/constant_density.py +0 -136
- sierra/plugins/platform/argos/variables/exp_setup.py +0 -113
- sierra/plugins/platform/argos/variables/population_constant_density.py +0 -175
- sierra/plugins/platform/argos/variables/population_size.py +0 -102
- sierra/plugins/platform/argos/variables/population_variable_density.py +0 -132
- sierra/plugins/platform/argos/variables/rendering.py +0 -104
- sierra/plugins/platform/ros1gazebo/__init__.py +0 -9
- sierra/plugins/platform/ros1gazebo/cmdline.py +0 -213
- sierra/plugins/platform/ros1gazebo/generators/platform_generators.py +0 -137
- sierra/plugins/platform/ros1gazebo/plugin.py +0 -335
- sierra/plugins/platform/ros1gazebo/variables/__init__.py +0 -10
- sierra/plugins/platform/ros1gazebo/variables/population_size.py +0 -204
- sierra/plugins/platform/ros1robot/__init__.py +0 -9
- sierra/plugins/platform/ros1robot/cmdline.py +0 -175
- sierra/plugins/platform/ros1robot/generators/platform_generators.py +0 -112
- sierra/plugins/platform/ros1robot/plugin.py +0 -373
- sierra/plugins/platform/ros1robot/variables/__init__.py +0 -10
- sierra/plugins/platform/ros1robot/variables/population_size.py +0 -146
- sierra/plugins/robot/__init__.py +0 -9
- sierra/plugins/robot/turtlebot3/__init__.py +0 -9
- sierra/plugins/robot/turtlebot3/plugin.py +0 -194
- sierra_research-1.3.11.data/data/share/man/man1/sierra-cli.1 +0 -2349
- sierra_research-1.3.11.data/data/share/man/man7/sierra-examples.7 +0 -508
- sierra_research-1.3.11.data/data/share/man/man7/sierra-exec-envs.7 +0 -331
- sierra_research-1.3.11.data/data/share/man/man7/sierra-glossary.7 +0 -285
- sierra_research-1.3.11.data/data/share/man/man7/sierra-platforms.7 +0 -358
- sierra_research-1.3.11.data/data/share/man/man7/sierra-usage.7 +0 -729
- sierra_research-1.3.11.data/data/share/man/man7/sierra.7 +0 -78
- sierra_research-1.3.11.dist-info/METADATA +0 -492
- sierra_research-1.3.11.dist-info/RECORD +0 -133
- sierra_research-1.3.11.dist-info/top_level.txt +0 -1
- {sierra_research-1.3.11.dist-info → sierra_research-1.5.0.dist-info}/entry_points.txt +0 -0
- {sierra_research-1.3.11.dist-info → sierra_research-1.5.0.dist-info/licenses}/LICENSE +0 -0
@@ -1,317 +0,0 @@
|
|
1
|
-
# Copyright 2019 John Harwell, All rights reserved.
|
2
|
-
#
|
3
|
-
# SPDX-License-Identifier: MIT
|
4
|
-
|
5
|
-
"""Classes for collating data within a :term:`Batch Experiment`.
|
6
|
-
|
7
|
-
Collation is the process of "lifting" data from :term:`Experimental Runs
|
8
|
-
<Experimental Run>` across all :term:`Experiment` for all experiments in a
|
9
|
-
:term:`Batch Experiment` into a single CSV (a reduce operation). This is needed
|
10
|
-
to correctly calculate summary statistics for performance measures in stage 4:
|
11
|
-
you can't just run the calculated stddev through the calculations for
|
12
|
-
flexibility (for example) because comparing curves of stddev is not
|
13
|
-
meaningful. Stage 4 needs access to raw-(er) run data to construct a
|
14
|
-
`distribution` of performance measure values to then calculate the summary
|
15
|
-
statistics (such as stddev) over.
|
16
|
-
|
17
|
-
"""
|
18
|
-
|
19
|
-
# Core packages
|
20
|
-
import multiprocessing as mp
|
21
|
-
import typing as tp
|
22
|
-
import queue
|
23
|
-
import logging
|
24
|
-
import pathlib
|
25
|
-
|
26
|
-
# 3rd party packages
|
27
|
-
import pandas as pd
|
28
|
-
import numpy as np
|
29
|
-
import psutil
|
30
|
-
|
31
|
-
# Project packages
|
32
|
-
import sierra.core.variables.batch_criteria as bc
|
33
|
-
import sierra.core.plugin_manager as pm
|
34
|
-
from sierra.core import types, storage, utils, config
|
35
|
-
|
36
|
-
|
37
|
-
class ExperimentalRunParallelCollator:
|
38
|
-
"""Generates :term:`Collated .csv` files for each :term:`Experiment`.
|
39
|
-
|
40
|
-
:term:`Collated .csv` files generated from :term:`Output .csv` files across
|
41
|
-
:term:`Experimental Runs <Experimental Run>`. Gathered in parallel for
|
42
|
-
each experiment for speed, unless disabled with ``--processing-serial``.
|
43
|
-
|
44
|
-
"""
|
45
|
-
|
46
|
-
def __init__(self, main_config: dict, cmdopts: types.Cmdopts):
|
47
|
-
self.main_config = main_config
|
48
|
-
self.cmdopts = cmdopts
|
49
|
-
self.logger = logging.getLogger(__name__)
|
50
|
-
|
51
|
-
def __call__(self, criteria: bc.IConcreteBatchCriteria) -> None:
|
52
|
-
if self.cmdopts['processing_serial']:
|
53
|
-
n_gatherers = 1
|
54
|
-
n_processors = 1
|
55
|
-
else:
|
56
|
-
# Aways need to have at least one of each! If SIERRA is invoked on a
|
57
|
-
# machine with 2 or less logical cores, the calculation with
|
58
|
-
# psutil.cpu_count() will return 0 for # gatherers.
|
59
|
-
n_gatherers = max(1, int(psutil.cpu_count() * 0.25))
|
60
|
-
n_processors = max(1, int(psutil.cpu_count() * 0.75))
|
61
|
-
|
62
|
-
pool = mp.Pool(processes=n_gatherers + n_processors)
|
63
|
-
|
64
|
-
m = mp.Manager()
|
65
|
-
gatherq = m.Queue()
|
66
|
-
processq = m.Queue()
|
67
|
-
|
68
|
-
exp_to_proc = utils.exp_range_calc(self.cmdopts,
|
69
|
-
self.cmdopts['batch_output_root'],
|
70
|
-
criteria)
|
71
|
-
|
72
|
-
for exp in exp_to_proc:
|
73
|
-
gatherq.put((self.cmdopts['batch_output_root'], exp.name))
|
74
|
-
|
75
|
-
self.logger.debug("Starting %d gatherers, method=%s",
|
76
|
-
n_gatherers,
|
77
|
-
mp.get_start_method())
|
78
|
-
|
79
|
-
gathered = [pool.apply_async(ExperimentalRunParallelCollator._gather_worker,
|
80
|
-
(gatherq,
|
81
|
-
processq,
|
82
|
-
self.main_config,
|
83
|
-
self.cmdopts['project'],
|
84
|
-
self.cmdopts['storage_medium'])) for _ in range(0, n_gatherers)]
|
85
|
-
|
86
|
-
self.logger.debug("Starting %d processors, method=%s",
|
87
|
-
n_processors,
|
88
|
-
mp.get_start_method())
|
89
|
-
processed = [pool.apply_async(ExperimentalRunParallelCollator._process_worker,
|
90
|
-
(processq,
|
91
|
-
self.main_config,
|
92
|
-
self.cmdopts['batch_stat_collate_root'],
|
93
|
-
self.cmdopts['storage_medium'],
|
94
|
-
self.cmdopts['df_homogenize'])) for _ in range(0, n_processors)]
|
95
|
-
|
96
|
-
# To capture the otherwise silent crashes when something goes wrong in
|
97
|
-
# worker threads. Any assertions will show and any exceptions will be
|
98
|
-
# re-raised.
|
99
|
-
self.logger.debug("Waiting for workers to finish")
|
100
|
-
for g in gathered:
|
101
|
-
g.get()
|
102
|
-
|
103
|
-
for p in processed:
|
104
|
-
p.get()
|
105
|
-
|
106
|
-
pool.close()
|
107
|
-
pool.join()
|
108
|
-
self.logger.debug("All threads finished")
|
109
|
-
|
110
|
-
@staticmethod
|
111
|
-
def _gather_worker(gatherq: mp.Queue,
|
112
|
-
processq: mp.Queue,
|
113
|
-
main_config: types.YAMLDict,
|
114
|
-
project: str,
|
115
|
-
storage_medium: str) -> None:
|
116
|
-
module = pm.module_load_tiered(project=project,
|
117
|
-
path='pipeline.stage3.run_collator')
|
118
|
-
gatherer = module.ExperimentalRunCSVGatherer(main_config,
|
119
|
-
storage_medium,
|
120
|
-
processq)
|
121
|
-
while True:
|
122
|
-
# Wait for 3 seconds after the queue is empty before bailing
|
123
|
-
try:
|
124
|
-
batch_output_root, exp = gatherq.get(True, 3)
|
125
|
-
gatherer(batch_output_root, exp)
|
126
|
-
gatherq.task_done()
|
127
|
-
|
128
|
-
except queue.Empty:
|
129
|
-
break
|
130
|
-
|
131
|
-
@staticmethod
|
132
|
-
def _process_worker(processq: mp.Queue,
|
133
|
-
main_config: types.YAMLDict,
|
134
|
-
batch_stat_collate_root: pathlib.Path,
|
135
|
-
storage_medium: str,
|
136
|
-
df_homogenize: str) -> None:
|
137
|
-
collator = ExperimentalRunCollator(main_config,
|
138
|
-
batch_stat_collate_root,
|
139
|
-
storage_medium,
|
140
|
-
df_homogenize)
|
141
|
-
while True:
|
142
|
-
# Wait for 3 seconds after the queue is empty before bailing
|
143
|
-
try:
|
144
|
-
item = processq.get(True, 3)
|
145
|
-
|
146
|
-
exp_leaf = list(item.keys())[0]
|
147
|
-
gathered_runs, gathered_dfs = item[exp_leaf]
|
148
|
-
collator(gathered_runs, gathered_dfs, exp_leaf)
|
149
|
-
processq.task_done()
|
150
|
-
except queue.Empty:
|
151
|
-
break
|
152
|
-
|
153
|
-
|
154
|
-
class ExperimentalRunCSVGatherer:
|
155
|
-
"""Gather :term:`Output .csv` files across all runs within an experiment.
|
156
|
-
|
157
|
-
This class can be extended/overriden using a :term:`Project` hook. See
|
158
|
-
:ref:`ln-sierra-tutorials-project-hooks` for details.
|
159
|
-
|
160
|
-
Attributes:
|
161
|
-
|
162
|
-
processq: The multiprocessing-safe producer-consumer queue that the data
|
163
|
-
gathered from experimental runs will be placed in for
|
164
|
-
processing.
|
165
|
-
|
166
|
-
storage_medium: The name of the storage medium plugin to use to extract
|
167
|
-
dataframes from when reading run data.
|
168
|
-
|
169
|
-
main_config: Parsed dictionary of main YAML configuration.
|
170
|
-
|
171
|
-
logger: The handle to the logger for this class. If you extend this
|
172
|
-
class, you should save/restore this variable in tandem with
|
173
|
-
overriding it in order to get logging messages have unique
|
174
|
-
logger names between this class and your derived class, in order
|
175
|
-
to reduce confusion.
|
176
|
-
|
177
|
-
"""
|
178
|
-
|
179
|
-
def __init__(self,
|
180
|
-
main_config: types.YAMLDict,
|
181
|
-
storage_medium: str,
|
182
|
-
processq: mp.Queue) -> None:
|
183
|
-
self.processq = processq
|
184
|
-
|
185
|
-
self.storage_medium = storage_medium
|
186
|
-
self.main_config = main_config
|
187
|
-
|
188
|
-
self.run_metrics_leaf = main_config['sierra']['run']['run_metrics_leaf']
|
189
|
-
|
190
|
-
self.logger = logging.getLogger(__name__)
|
191
|
-
|
192
|
-
def __call__(self,
|
193
|
-
batch_output_root: pathlib.Path,
|
194
|
-
exp_leaf: str):
|
195
|
-
"""
|
196
|
-
Gather CSV data from all experimental runs in an experiment.
|
197
|
-
|
198
|
-
Gathered data is put in a queue for processing.
|
199
|
-
|
200
|
-
Arguments:
|
201
|
-
|
202
|
-
exp_leaf: The name of the experiment directory within the
|
203
|
-
``batch_output_root``.
|
204
|
-
|
205
|
-
"""
|
206
|
-
self.logger.info('Gathering .csvs: %s...', exp_leaf)
|
207
|
-
|
208
|
-
exp_output_root = batch_output_root / exp_leaf
|
209
|
-
|
210
|
-
runs = sorted(exp_output_root.iterdir())
|
211
|
-
|
212
|
-
gathered = []
|
213
|
-
for run in runs:
|
214
|
-
run_output_root = run / self.run_metrics_leaf
|
215
|
-
gathered.append(self.gather_csvs_from_run(run_output_root))
|
216
|
-
|
217
|
-
names = [run.name for run in runs]
|
218
|
-
self.processq.put({exp_leaf: (names, gathered)})
|
219
|
-
|
220
|
-
def gather_csvs_from_run(self,
|
221
|
-
run_output_root: pathlib.Path) -> tp.Dict[tp.Tuple[str, str],
|
222
|
-
pd.DataFrame]:
|
223
|
-
"""Gather all data from a single run within an experiment.
|
224
|
-
|
225
|
-
Returns:
|
226
|
-
|
227
|
-
dict: A dictionary of <(CSV file name, CSV performance column),
|
228
|
-
dataframe> key-value pairs. The CSV file name is the leaf part
|
229
|
-
of the path with the extension included.
|
230
|
-
|
231
|
-
"""
|
232
|
-
|
233
|
-
intra_perf_csv = self.main_config['sierra']['perf']['intra_perf_csv']
|
234
|
-
intra_perf_leaf = intra_perf_csv.split('.')[0]
|
235
|
-
intra_perf_col = self.main_config['sierra']['perf']['intra_perf_col']
|
236
|
-
|
237
|
-
reader = storage.DataFrameReader(self.storage_medium)
|
238
|
-
perf_path = run_output_root / (intra_perf_leaf +
|
239
|
-
config.kStorageExt['csv'])
|
240
|
-
perf_df = reader(perf_path, index_col=False)
|
241
|
-
|
242
|
-
return {
|
243
|
-
(intra_perf_leaf, intra_perf_col): perf_df[intra_perf_col],
|
244
|
-
}
|
245
|
-
|
246
|
-
|
247
|
-
class ExperimentalRunCollator:
|
248
|
-
"""Collate gathered :term:`Output .csv` files together (reduce operation).
|
249
|
-
|
250
|
-
:term:`Output .csv`s gathered from N :term:`Experimental Runs <Experimental
|
251
|
-
Run>` are combined together into a single :term:`Summary .csv` per
|
252
|
-
:term:`Experiment` with 1 column per run.
|
253
|
-
|
254
|
-
"""
|
255
|
-
|
256
|
-
def __init__(self,
|
257
|
-
main_config: types.YAMLDict,
|
258
|
-
batch_stat_collate_root: pathlib.Path,
|
259
|
-
storage_medium: str,
|
260
|
-
df_homogenize: str) -> None:
|
261
|
-
self.main_config = main_config
|
262
|
-
self.batch_stat_collate_root = batch_stat_collate_root
|
263
|
-
self.df_homogenize = df_homogenize
|
264
|
-
|
265
|
-
self.storage_medium = storage_medium
|
266
|
-
|
267
|
-
# To support inverted performance measures where smaller is better
|
268
|
-
self.invert_perf = main_config['sierra']['perf'].get('inverted', False)
|
269
|
-
self.intra_perf_csv = main_config['sierra']['perf']['intra_perf_csv']
|
270
|
-
|
271
|
-
utils.dir_create_checked(self.batch_stat_collate_root, exist_ok=True)
|
272
|
-
|
273
|
-
def __call__(self,
|
274
|
-
gathered_runs: tp.List[str],
|
275
|
-
gathered_dfs: tp.List[tp.Dict[tp.Tuple[str, str], pd.DataFrame]],
|
276
|
-
exp_leaf: str) -> None:
|
277
|
-
collated = {}
|
278
|
-
|
279
|
-
for run in gathered_runs:
|
280
|
-
run_dfs = gathered_dfs[gathered_runs.index(run)]
|
281
|
-
|
282
|
-
for csv_leaf, col in run_dfs.keys():
|
283
|
-
csv_df = run_dfs[(csv_leaf, col)]
|
284
|
-
|
285
|
-
# Invert performance if configured.
|
286
|
-
if self.invert_perf and csv_leaf in self.intra_perf_csv:
|
287
|
-
csv_df = 1.0 / csv_df
|
288
|
-
|
289
|
-
# Because of the requirement that P(N) >= 0 for flexibility
|
290
|
-
# (1/0 = inf gives a crash with DTW), if the current level
|
291
|
-
# of performance is 0, it stays 0.
|
292
|
-
#
|
293
|
-
# This is a bit of a hack. But also not a hack at all,
|
294
|
-
# because infinite performance is not possible. This
|
295
|
-
# is... Schrodinger's Hack.
|
296
|
-
csv_df = csv_df.replace([-np.inf, np.inf], 0)
|
297
|
-
|
298
|
-
if (csv_leaf, col) not in collated:
|
299
|
-
collated[(csv_leaf, col)] = pd.DataFrame(index=csv_df.index,
|
300
|
-
columns=gathered_runs)
|
301
|
-
collated[(csv_leaf, col)][run] = csv_df
|
302
|
-
|
303
|
-
for (csv_leaf, col) in collated:
|
304
|
-
writer = storage.DataFrameWriter(self.storage_medium)
|
305
|
-
df = utils.df_fill(collated[(csv_leaf, col)], self.df_homogenize)
|
306
|
-
fname = f'{exp_leaf}-{csv_leaf}-{col}' + config.kStorageExt['csv']
|
307
|
-
opath = self.batch_stat_collate_root / fname
|
308
|
-
writer(df, opath, index=False)
|
309
|
-
|
310
|
-
|
311
|
-
__api__ = [
|
312
|
-
'ExperimentalRunParallelCollator',
|
313
|
-
'ExperimentalRunCSVGatherer',
|
314
|
-
'ExperimentalRunCollator'
|
315
|
-
|
316
|
-
|
317
|
-
]
|