sierra-research 1.3.6__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.6.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 -249
- sierra/core/graphs/stacked_surface_graph.py +0 -220
- sierra/core/graphs/summary_line_graph.py +0 -369
- 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 -319
- 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.6.data/data/share/man/man1/sierra-cli.1 +0 -2349
- sierra_research-1.3.6.data/data/share/man/man7/sierra-examples.7 +0 -488
- sierra_research-1.3.6.data/data/share/man/man7/sierra-exec-envs.7 +0 -331
- sierra_research-1.3.6.data/data/share/man/man7/sierra-glossary.7 +0 -285
- sierra_research-1.3.6.data/data/share/man/man7/sierra-platforms.7 +0 -358
- sierra_research-1.3.6.data/data/share/man/man7/sierra-usage.7 +0 -725
- sierra_research-1.3.6.data/data/share/man/man7/sierra.7 +0 -78
- sierra_research-1.3.6.dist-info/METADATA +0 -500
- sierra_research-1.3.6.dist-info/RECORD +0 -133
- sierra_research-1.3.6.dist-info/top_level.txt +0 -1
- {sierra_research-1.3.6.dist-info → sierra_research-1.5.0.dist-info}/entry_points.txt +0 -0
- {sierra_research-1.3.6.dist-info → sierra_research-1.5.0.dist-info/licenses}/LICENSE +0 -0
sierra/core/models/interface.py
CHANGED
@@ -1,10 +1,11 @@
|
|
1
1
|
# Copyright 2020 John Harwell, All rights reserved.
|
2
2
|
#
|
3
3
|
# SPDX-License-Identifier: MIT
|
4
|
-
"""
|
5
|
-
|
6
|
-
Models can be run and added to any configured graph during stage 4.
|
4
|
+
"""
|
5
|
+
Interface classes for the mathematical models framework in SIERRA.
|
7
6
|
|
7
|
+
Models can be run during stage 3 and added to any configured graph during stage
|
8
|
+
4.
|
8
9
|
"""
|
9
10
|
|
10
11
|
# Core packages
|
@@ -16,25 +17,32 @@ import implements
|
|
16
17
|
|
17
18
|
# Project packages
|
18
19
|
from sierra.core.variables import batch_criteria as bc
|
19
|
-
from sierra.core import types
|
20
|
+
from sierra.core import types, exproot, batchroot
|
20
21
|
|
21
22
|
|
22
|
-
class
|
23
|
+
class IIntraExpModel1D(implements.Interface):
|
23
24
|
"""Interface for one-dimensional models.
|
24
25
|
|
25
26
|
1D models are those that generate a single time series from zero or more
|
26
|
-
experimental outputs within a *single* :term:`Experiment`.
|
27
|
-
rendered as lines on a
|
28
|
-
|
29
|
-
"target" one or more CSV files which are already configured to be generated,
|
27
|
+
experimental outputs within a *single* :term:`Experiment`. Models will be
|
28
|
+
rendered as lines on a :func:`~sierra.core.graphs.stacked_line`. Models
|
29
|
+
"target" one or more graphs which are already configured to be generated,
|
30
30
|
and will show up as additional lines on the generated graph.
|
31
31
|
|
32
|
+
The dataframes generated by models implement this interface MUST have
|
33
|
+
indices of the same length as those in the graphs they target.
|
32
34
|
"""
|
33
35
|
|
34
|
-
def
|
35
|
-
|
36
|
-
|
37
|
-
|
36
|
+
def __init__(self, params: types.YAMLDict) -> None:
|
37
|
+
pass
|
38
|
+
|
39
|
+
def run(
|
40
|
+
self,
|
41
|
+
criteria: bc.XVarBatchCriteria,
|
42
|
+
exp_num: int,
|
43
|
+
cmdopts: types.Cmdopts,
|
44
|
+
pathset: exproot.PathSet,
|
45
|
+
) -> tp.List[pd.DataFrame]:
|
38
46
|
"""Run the model and generate a list of dataframes.
|
39
47
|
|
40
48
|
Each dataframe can (potentially) target different graphs. All dataframes
|
@@ -46,10 +54,9 @@ class IConcreteIntraExpModel1D(implements.Interface):
|
|
46
54
|
"""
|
47
55
|
raise NotImplementedError
|
48
56
|
|
49
|
-
def
|
50
|
-
|
51
|
-
|
52
|
-
exp_num: int) -> bool:
|
57
|
+
def should_run(
|
58
|
+
self, criteria: bc.XVarBatchCriteria, cmdopts: types.Cmdopts, exp_num: int
|
59
|
+
) -> bool:
|
53
60
|
"""
|
54
61
|
Determine if the model should be run for the specified experiment.
|
55
62
|
|
@@ -59,23 +66,6 @@ class IConcreteIntraExpModel1D(implements.Interface):
|
|
59
66
|
"""
|
60
67
|
raise NotImplementedError
|
61
68
|
|
62
|
-
def target_csv_stems(self) -> tp.List[str]:
|
63
|
-
"""Return a list of CSV file stems that the model is targeting.
|
64
|
-
|
65
|
-
File stem = path sans directory path and extension.
|
66
|
-
"""
|
67
|
-
raise NotImplementedError
|
68
|
-
|
69
|
-
def legend_names(self) -> tp.List[str]:
|
70
|
-
"""Compute names for the model predictions for the target graph legend.
|
71
|
-
|
72
|
-
Applicable to:
|
73
|
-
|
74
|
-
- :class:`~sierra.core.graphs.stacked_line_graph.StackedLineGraph`
|
75
|
-
|
76
|
-
"""
|
77
|
-
raise NotImplementedError
|
78
|
-
|
79
69
|
def __repr__(self) -> str:
|
80
70
|
"""
|
81
71
|
Return the UUID string of the model name.
|
@@ -83,86 +73,42 @@ class IConcreteIntraExpModel1D(implements.Interface):
|
|
83
73
|
raise NotImplementedError
|
84
74
|
|
85
75
|
|
86
|
-
class
|
87
|
-
"""Interface for
|
88
|
-
|
89
|
-
2D models are those that generate a list of 2D matrices, forming a 2D time
|
90
|
-
series. Can be built from zero or more experimental outputs from a *single*
|
91
|
-
:term:`Experiment`. Models "target" one or more CSV files which are already
|
92
|
-
configured to be generated, and will show up as additional lines on the
|
93
|
-
generated graph.
|
76
|
+
class IInterExpModel1D(implements.Interface):
|
77
|
+
"""Interface for one-dimensional models.
|
94
78
|
|
79
|
+
1D models are those that generate a single time series from any number of
|
80
|
+
experimental outputs across *all* experiments in a batch (or from another
|
81
|
+
source). Models will be rendered as lines on a
|
82
|
+
:func:`~sierra.core.graphs.summary_line`. Models "target" one or more
|
83
|
+
:term:`Collated Output Data` files which are already configured to be
|
84
|
+
generated, and will show up as additional lines on the generated graph.
|
95
85
|
"""
|
96
86
|
|
97
|
-
def
|
98
|
-
|
99
|
-
exp_num: int,
|
100
|
-
cmdopts: types.Cmdopts) -> tp.List[pd.DataFrame]:
|
101
|
-
"""Run the model and generate a list of dataframes.
|
102
|
-
|
103
|
-
Each dataframe can (potentially) target a different graph. Each
|
104
|
-
dataframe should be a NxM grid (with N not necessarily equal to M). All
|
105
|
-
dataframes do not have to be the same dimensions. The index of a given
|
106
|
-
dataframe in a list should correspond to the model value for
|
107
|
-
interval/timestep.
|
108
|
-
|
109
|
-
"""
|
110
|
-
raise NotImplementedError
|
111
|
-
|
112
|
-
def run_for_exp(self,
|
113
|
-
criteria: bc.IConcreteBatchCriteria,
|
114
|
-
cmdopts: types.Cmdopts,
|
115
|
-
exp_num: int) -> bool:
|
116
|
-
"""Determine if a model should be run for the specified experiment.
|
117
|
-
|
118
|
-
Some models may only be valid/make sense to run for a subset of
|
119
|
-
experiments within a batch, so models can be selectively executed with
|
120
|
-
this function.
|
121
|
-
|
122
|
-
"""
|
123
|
-
raise NotImplementedError
|
124
|
-
|
125
|
-
def target_csv_stems(self) -> tp.List[str]:
|
126
|
-
"""Return a list of CSV file stems that the model is targeting.
|
127
|
-
|
128
|
-
File stem = path sans directory path and extension.
|
129
|
-
"""
|
130
|
-
raise NotImplementedError
|
131
|
-
|
132
|
-
def __repr__(self) -> str:
|
133
|
-
"""
|
134
|
-
Return the UUID string of the model name.
|
135
|
-
"""
|
136
|
-
raise NotImplementedError
|
137
|
-
|
87
|
+
def __init__(self, params: types.YAMLDict) -> None:
|
88
|
+
pass
|
138
89
|
|
139
|
-
|
140
|
-
|
90
|
+
def run(
|
91
|
+
self,
|
92
|
+
criteria: bc.XVarBatchCriteria,
|
93
|
+
cmdopts: types.Cmdopts,
|
94
|
+
pathset: batchroot.PathSet,
|
95
|
+
) -> tp.List[pd.DataFrame]:
|
96
|
+
"""Run the model and generate list of dataframes.
|
141
97
|
|
142
|
-
|
143
|
-
experimental outputs across *all* experiments in a batch(or from another
|
144
|
-
source). Models will be rendered as lines on a
|
145
|
-
:class:`~sierra.core.graphs.summary_line_graph.SummaryLineGraph`. Models
|
146
|
-
"target" one or more CSV files which are already configured to be generated,
|
147
|
-
and will show up as additional lines on the generated graph.
|
98
|
+
Each returned dataframe must have:
|
148
99
|
|
149
|
-
|
100
|
+
- The index named ``Experiment ID``
|
150
101
|
|
151
|
-
|
152
|
-
criteria: bc.IConcreteBatchCriteria,
|
153
|
-
cmdopts: types.Cmdopts) -> tp.List[pd.DataFrame]:
|
154
|
-
"""Run the model and generate list of dataframes.
|
102
|
+
- Indices which correspond to ``criteria.gen_exp_names()``
|
155
103
|
|
156
|
-
Each dataframe can (potentially) target a different graph.
|
157
|
-
dataframe should contain a single row, with one column for the predicted
|
158
|
-
value of the model for each experiment in the batch.
|
104
|
+
Each dataframe can (potentially) target a different graph.
|
159
105
|
|
160
106
|
"""
|
161
107
|
raise NotImplementedError
|
162
108
|
|
163
|
-
def
|
164
|
-
|
165
|
-
|
109
|
+
def should_run(
|
110
|
+
self, criteria: bc.XVarBatchCriteria, cmdopts: types.Cmdopts
|
111
|
+
) -> bool:
|
166
112
|
"""
|
167
113
|
Determine if the model should be run for the specified batch criteria.
|
168
114
|
|
@@ -171,23 +117,6 @@ class IConcreteInterExpModel1D(implements.Interface):
|
|
171
117
|
"""
|
172
118
|
raise NotImplementedError
|
173
119
|
|
174
|
-
def target_csv_stems(self) -> tp.List[str]:
|
175
|
-
"""Return a list of CSV file stems that the model is targeting.
|
176
|
-
|
177
|
-
File stem = path sans directory path and extension.
|
178
|
-
"""
|
179
|
-
raise NotImplementedError
|
180
|
-
|
181
|
-
def legend_names(self) -> tp.List[str]:
|
182
|
-
"""Compute names for the model predictions for the target graph legend.
|
183
|
-
|
184
|
-
Applicable to:
|
185
|
-
|
186
|
-
- ~sierra.core.graphs.summary_line_graph.SummaryLineGraph`
|
187
|
-
|
188
|
-
"""
|
189
|
-
raise NotImplementedError
|
190
|
-
|
191
120
|
def __repr__(self) -> str:
|
192
121
|
"""
|
193
122
|
Return the UUID string of the model name.
|
@@ -195,6 +124,7 @@ class IConcreteInterExpModel1D(implements.Interface):
|
|
195
124
|
raise NotImplementedError
|
196
125
|
|
197
126
|
|
198
|
-
|
199
|
-
|
200
|
-
|
127
|
+
__all__ = [
|
128
|
+
"IIntraExpModel1D",
|
129
|
+
"IInterExpModel1D",
|
130
|
+
]
|
sierra/core/pipeline/__init__.py
CHANGED
@@ -1,8 +1,5 @@
|
|
1
1
|
# Copyright 2022 John Harwell, All rights reserved.
|
2
2
|
#
|
3
3
|
# SPDX-License-Identifier: MIT
|
4
|
-
|
5
|
-
|
6
|
-
# import sierra.core.pipeline.stage3
|
7
|
-
# import sierra.core.pipeline.stage4
|
8
|
-
# import sierra.core.pipeline.stage5
|
4
|
+
|
5
|
+
"""Container module for main pipeline."""
|
sierra/core/pipeline/pipeline.py
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
# SPDX-License-Identifier: MIT
|
4
4
|
"""The 5 pipeline stages implemented by SIERRA.
|
5
5
|
|
6
|
-
See :ref:`
|
6
|
+
See :ref:`usage/pipeline` for high-level documentation.
|
7
7
|
|
8
8
|
"""
|
9
9
|
|
@@ -12,13 +12,14 @@ import typing as tp
|
|
12
12
|
import logging
|
13
13
|
import argparse
|
14
14
|
import pathlib
|
15
|
+
import os
|
15
16
|
|
16
17
|
# 3rd party packages
|
17
18
|
import yaml
|
18
19
|
|
19
20
|
# Project packages
|
20
|
-
import sierra.core.
|
21
|
-
from sierra.core import
|
21
|
+
import sierra.core.plugin as pm
|
22
|
+
from sierra.core import config, utils, batchroot, types
|
22
23
|
|
23
24
|
from sierra.core.pipeline.stage1.pipeline_stage1 import PipelineStage1
|
24
25
|
from sierra.core.pipeline.stage2.pipeline_stage2 import PipelineStage2
|
@@ -30,110 +31,54 @@ from sierra.core.pipeline.stage5.pipeline_stage5 import PipelineStage5
|
|
30
31
|
class Pipeline:
|
31
32
|
"Implements SIERRA's 5 stage pipeline."
|
32
33
|
|
33
|
-
def __init__(
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
34
|
+
def __init__(
|
35
|
+
self,
|
36
|
+
args: argparse.Namespace,
|
37
|
+
controller: tp.Optional[str],
|
38
|
+
pathset: tp.Optional[batchroot.PathSet] = None,
|
39
|
+
) -> None:
|
38
40
|
self.logger = logging.getLogger(__name__)
|
41
|
+
self.pathset = pathset
|
39
42
|
|
40
|
-
|
41
|
-
f"Invalid pipeline stage in {args.pipeline}: Only 1-5 valid"
|
42
|
-
|
43
|
-
self.cmdopts = {
|
44
|
-
# multistage
|
45
|
-
'pipeline': self.args.pipeline,
|
46
|
-
'sierra_root': self.args.sierra_root,
|
47
|
-
'scenario': self.args.scenario,
|
48
|
-
'template_input_file': self.args.template_input_file,
|
49
|
-
'project': self.args.project,
|
50
|
-
'exec_env': args.exec_env,
|
51
|
-
'platform_vc': self.args.platform_vc,
|
52
|
-
"n_runs": args.n_runs,
|
53
|
-
'project_imagizing': self.args.project_imagizing,
|
54
|
-
'exp_overwrite': self.args.exp_overwrite,
|
55
|
-
'exp_range': self.args.exp_range,
|
56
|
-
'dist_stats': self.args.dist_stats,
|
57
|
-
'skip_collate': self.args.skip_collate,
|
58
|
-
'platform': self.args.platform,
|
59
|
-
'processing_serial': self.args.processing_serial,
|
60
|
-
|
61
|
-
'plot_log_xscale': self.args.plot_log_xscale,
|
62
|
-
'plot_enumerated_xscale': self.args.plot_enumerated_xscale,
|
63
|
-
'plot_log_yscale': self.args.plot_log_yscale,
|
64
|
-
'plot_regression_lines': self.args.plot_regression_lines,
|
65
|
-
'plot_primary_axis': self.args.plot_primary_axis,
|
66
|
-
'plot_large_text': self.args.plot_large_text,
|
67
|
-
'plot_transpose_graphs': self.args.plot_transpose_graphs,
|
68
|
-
|
69
|
-
# stage 1
|
70
|
-
'preserve_seeds': self.args.preserve_seeds,
|
71
|
-
|
72
|
-
# stage 2
|
73
|
-
'nodefile': self.args.nodefile,
|
74
|
-
|
75
|
-
# stage 3
|
76
|
-
'df_skip_verify': self.args.df_skip_verify,
|
77
|
-
'df_homogenize': self.args.df_homogenize,
|
78
|
-
'render_cmd_opts': self.args.render_cmd_opts,
|
79
|
-
'processing_mem_limit': self.args.processing_mem_limit,
|
80
|
-
'storage_medium': self.args.storage_medium,
|
81
|
-
|
82
|
-
# stage 4
|
83
|
-
'exp_graphs': self.args.exp_graphs,
|
84
|
-
|
85
|
-
'project_no_LN': self.args.project_no_LN,
|
86
|
-
'project_no_HM': self.args.project_no_HM,
|
87
|
-
'project_rendering': self.args.project_rendering,
|
88
|
-
'bc_rendering': self.args.bc_rendering,
|
89
|
-
|
90
|
-
'models_enable': self.args.models_enable,
|
91
|
-
|
92
|
-
# stage 5
|
93
|
-
'controllers_list': self.args.controllers_list,
|
94
|
-
'controllers_legend': self.args.controllers_legend,
|
95
|
-
'scenarios_list': self.args.scenarios_list,
|
96
|
-
'scenarios_legend': self.args.scenarios_legend,
|
97
|
-
'scenario_comparison': self.args.scenario_comparison,
|
98
|
-
'controller_comparison': self.args.controller_comparison,
|
99
|
-
'comparison_type': self.args.comparison_type,
|
100
|
-
}
|
101
|
-
|
102
|
-
# Load additional cmdline options from platform
|
103
|
-
self.logger.debug("Updating cmdopts with extensions from '%s'",
|
104
|
-
self.cmdopts['platform'])
|
105
|
-
module = pm.module_load_tiered("cmdline",
|
106
|
-
platform=self.cmdopts['platform'])
|
107
|
-
module.PlatformCmdline.cmdopts_update(self.args, self.cmdopts)
|
108
|
-
|
109
|
-
if rdg_opts is not None:
|
110
|
-
self.cmdopts.update(rdg_opts)
|
111
|
-
|
112
|
-
# Load additional cmdline options from project. This is mandatory,
|
113
|
-
# because all projects have to define --controller and --scenario
|
114
|
-
# at a minimum.
|
115
|
-
self.logger.debug("Updating cmdopts with extensions from '%s'",
|
116
|
-
self.cmdopts['project'])
|
117
|
-
path = "{0}.cmdline".format(self.cmdopts['project'])
|
118
|
-
module = pm.module_load(path)
|
119
|
-
|
120
|
-
module.Cmdline.cmdopts_update(self.args, self.cmdopts)
|
43
|
+
self.logger.info("Computed run-time tree:\n%s", self.pathset)
|
121
44
|
|
122
|
-
|
123
|
-
|
45
|
+
assert all(
|
46
|
+
stage in [1, 2, 3, 4, 5] for stage in args.pipeline
|
47
|
+
), f"Invalid pipeline stage in {args.pipeline}: Only 1-5 valid"
|
124
48
|
|
125
|
-
|
126
|
-
|
127
|
-
|
49
|
+
# The namespace passed in contains arguments for the core and all
|
50
|
+
# plugins, so its OK to handle shortforms which aren't in the SIERRA
|
51
|
+
# core at this point. This also preserves the "longforms trump
|
52
|
+
# shortforms if both are passed" policy because their converted
|
53
|
+
# shortforms are overwritten below.
|
54
|
+
self.args = args
|
55
|
+
shortforms = self._handle_shortforms()
|
56
|
+
|
57
|
+
# Check for problematic characters in arguments used to create directory
|
58
|
+
# paths.
|
59
|
+
if any(
|
60
|
+
"+" in arg
|
61
|
+
for arg in [
|
62
|
+
self.args.scenario or [],
|
63
|
+
self.args.controller or [],
|
64
|
+
self.args.batch_criteria,
|
65
|
+
]
|
66
|
+
):
|
67
|
+
raise RuntimeError(
|
68
|
+
"{--scenario, --controller, --batch-criteria} cannot contain '+'."
|
69
|
+
)
|
70
|
+
|
71
|
+
self.cmdopts = self._init_cmdopts(shortforms)
|
128
72
|
|
129
73
|
self._load_config()
|
130
74
|
|
131
75
|
if 5 not in self.args.pipeline:
|
132
|
-
bc = pm.module_load_tiered(
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
76
|
+
bc = pm.module_load_tiered(
|
77
|
+
project=self.cmdopts["project"], path="variables.batch_criteria"
|
78
|
+
)
|
79
|
+
self.batch_criteria = bc.factory(
|
80
|
+
self.main_config, self.cmdopts, self.pathset.input_root, self.args
|
81
|
+
)
|
137
82
|
|
138
83
|
self.controller = controller
|
139
84
|
|
@@ -142,32 +87,201 @@ class Pipeline:
|
|
142
87
|
Run pipeline stages 1-5 as configured.
|
143
88
|
"""
|
144
89
|
if 1 in self.args.pipeline:
|
145
|
-
PipelineStage1(
|
146
|
-
|
147
|
-
|
90
|
+
PipelineStage1(
|
91
|
+
self.cmdopts,
|
92
|
+
self.pathset,
|
93
|
+
self.controller, # type: ignore
|
94
|
+
self.batch_criteria,
|
95
|
+
).run()
|
148
96
|
|
149
97
|
if 2 in self.args.pipeline:
|
150
|
-
PipelineStage2(self.cmdopts).run(self.batch_criteria)
|
98
|
+
PipelineStage2(self.cmdopts, self.pathset).run(self.batch_criteria)
|
151
99
|
|
152
100
|
if 3 in self.args.pipeline:
|
153
|
-
PipelineStage3(self.main_config,
|
154
|
-
|
101
|
+
PipelineStage3(self.main_config, self.cmdopts, self.pathset).run(
|
102
|
+
self.batch_criteria
|
103
|
+
)
|
155
104
|
|
156
105
|
if 4 in self.args.pipeline:
|
157
|
-
PipelineStage4(self.main_config,
|
158
|
-
|
106
|
+
PipelineStage4(self.main_config, self.cmdopts, self.pathset).run(
|
107
|
+
self.batch_criteria
|
108
|
+
)
|
159
109
|
|
160
110
|
# not part of default pipeline
|
161
111
|
if 5 in self.args.pipeline:
|
162
|
-
PipelineStage5(self.main_config,
|
163
|
-
|
112
|
+
PipelineStage5(self.main_config, self.cmdopts).run(self.args)
|
113
|
+
|
114
|
+
def _init_cmdopts(self, shortforms: types.Cmdopts) -> types.Cmdopts:
|
115
|
+
longforms = {
|
116
|
+
# multistage
|
117
|
+
"pipeline": self.args.pipeline,
|
118
|
+
"sierra_root": os.path.expanduser(self.args.sierra_root),
|
119
|
+
"scenario": self.args.scenario,
|
120
|
+
"expdef_template": self.args.expdef_template,
|
121
|
+
"project": self.args.project,
|
122
|
+
"execenv": self.args.execenv,
|
123
|
+
"engine_vc": self.args.engine_vc,
|
124
|
+
"n_runs": self.args.n_runs,
|
125
|
+
"exp_overwrite": self.args.exp_overwrite,
|
126
|
+
"exp_range": self.args.exp_range,
|
127
|
+
"engine": self.args.engine,
|
128
|
+
"processing_parallelism": self.args.processing_parallelism,
|
129
|
+
"exec_parallelism_paradigm": self.args.exec_parallelism_paradigm,
|
130
|
+
"expdef": self.args.expdef,
|
131
|
+
# stage 1
|
132
|
+
"preserve_seeds": self.args.preserve_seeds,
|
133
|
+
# stage 2
|
134
|
+
"nodefile": self.args.nodefile,
|
135
|
+
# stage 3
|
136
|
+
"proc": self.args.proc,
|
137
|
+
"df_verify": self.args.df_verify,
|
138
|
+
"df_homogenize": self.args.df_homogenize,
|
139
|
+
"processing_mem_limit": self.args.processing_mem_limit,
|
140
|
+
"storage": self.args.storage,
|
141
|
+
# stage 4
|
142
|
+
"prod": self.args.prod,
|
143
|
+
# stage 5
|
144
|
+
"compare": self.args.compare,
|
145
|
+
}
|
146
|
+
cmdopts = longforms
|
147
|
+
|
148
|
+
# Load additional cmdline options from --engine
|
149
|
+
self.logger.debug("Updating cmdopts from --engine=%s", cmdopts["engine"])
|
150
|
+
module = pm.module_load_tiered("cmdline", engine=cmdopts["engine"])
|
151
|
+
cmdopts |= module.to_cmdopts(self.args)
|
152
|
+
|
153
|
+
# Load additional cmdline options from --execenv
|
154
|
+
path = "{0}.cmdline".format(cmdopts["execenv"])
|
155
|
+
if pm.module_exists(path):
|
156
|
+
self.logger.debug("Updating cmdopts from --execenv=%s", cmdopts["execenv"])
|
157
|
+
module = pm.module_load_tiered(path)
|
158
|
+
cmdopts |= module.to_cmdopts(self.args)
|
159
|
+
|
160
|
+
# Load additional cmdline options from --expdef
|
161
|
+
path = "{0}.cmdline".format(cmdopts["expdef"])
|
162
|
+
if pm.module_exists(path):
|
163
|
+
self.logger.debug("Updating cmdopts from --expdef=%s", cmdopts["expdef"])
|
164
|
+
module = pm.module_load_tiered(path)
|
165
|
+
cmdopts |= module.to_cmdopts(self.args)
|
166
|
+
|
167
|
+
# Load additional cmdline options from --proc plugins
|
168
|
+
for p in cmdopts["proc"]:
|
169
|
+
path = "{0}.cmdline".format(p)
|
170
|
+
if pm.module_exists(path):
|
171
|
+
self.logger.debug("Updating cmdopts from --proc=%s", p)
|
172
|
+
module = pm.module_load_tiered(path)
|
173
|
+
cmdopts |= module.to_cmdopts(self.args)
|
174
|
+
|
175
|
+
for p in cmdopts["prod"]:
|
176
|
+
path = "{0}.cmdline".format(p)
|
177
|
+
if pm.module_exists(path):
|
178
|
+
self.logger.debug("Updating cmdopts from --prod=%s", p)
|
179
|
+
module = pm.module_load_tiered(path)
|
180
|
+
cmdopts |= module.to_cmdopts(self.args)
|
181
|
+
|
182
|
+
for p in cmdopts["compare"]:
|
183
|
+
path = "{0}.cmdline".format(p)
|
184
|
+
if pm.module_exists(path):
|
185
|
+
self.logger.debug("Updating cmdopts from --compare=%s", p)
|
186
|
+
module = pm.module_load_tiered(path)
|
187
|
+
cmdopts |= module.to_cmdopts(self.args)
|
188
|
+
|
189
|
+
# Load additional cmdline options from --storage
|
190
|
+
path = "{0}.cmdline".format(cmdopts["storage"])
|
191
|
+
if pm.module_exists(path):
|
192
|
+
self.logger.debug("Updating cmdopts from --storage=%s", cmdopts["storage"])
|
193
|
+
module = pm.module_load_tiered(path)
|
194
|
+
cmdopts |= module.to_cmdopts(self.args)
|
195
|
+
|
196
|
+
# Load additional cmdline options from project. This is mandatory,
|
197
|
+
# because all projects have to define --controller and --scenario
|
198
|
+
# at a minimum.
|
199
|
+
self.logger.debug("Updating cmdopts from --project=%s", cmdopts["project"])
|
200
|
+
path = "{0}.cmdline".format(cmdopts["project"])
|
201
|
+
module = pm.module_load(path)
|
202
|
+
cmdopts |= module.to_cmdopts(self.args)
|
203
|
+
|
204
|
+
# This has to be AFTER loading cmdopts from all plugins so that any
|
205
|
+
# unset/defaulted options don't override the shortform. This also means
|
206
|
+
# that shortforms override longforms if both are passed.
|
207
|
+
cmdopts |= shortforms
|
208
|
+
|
209
|
+
# Projects are specified as X.Y on cmdline so to get the path to the
|
210
|
+
# project dir we combine the parent_dir (which is already a path) and
|
211
|
+
# the name of the project (Y component).
|
212
|
+
project = pm.pipeline.get_plugin(cmdopts["project"])
|
213
|
+
path = project["parent_dir"] / "/".join(cmdopts["project"].split("."))
|
214
|
+
cmdopts["project_root"] = str(path)
|
215
|
+
cmdopts["project_config_root"] = str(path / "config")
|
216
|
+
cmdopts["project_model_root"] = str(path / "models")
|
217
|
+
|
218
|
+
return cmdopts
|
219
|
+
|
220
|
+
def _handle_shortforms(self) -> types.Cmdopts:
|
221
|
+
"""
|
222
|
+
Replace all shortform arguments in with their longform counterparts.
|
223
|
+
|
224
|
+
SIERRA always references arguments internally via longform if needed, so
|
225
|
+
this is required.
|
226
|
+
|
227
|
+
"""
|
228
|
+
|
229
|
+
shortform_map = {
|
230
|
+
"p": "plot",
|
231
|
+
"e": "exp",
|
232
|
+
"x": "exec",
|
233
|
+
"s": "skip",
|
234
|
+
}
|
235
|
+
ret = {}
|
236
|
+
|
237
|
+
for k in shortform_map:
|
238
|
+
passed = getattr(self.args, k, None)
|
239
|
+
if not passed:
|
240
|
+
self.logger.trace(
|
241
|
+
("No shortform args for -%s -> --%s passed to SIERRA"),
|
242
|
+
k,
|
243
|
+
shortform_map[k],
|
244
|
+
)
|
245
|
+
continue
|
246
|
+
|
247
|
+
self.logger.trace(
|
248
|
+
"Collected shortform args for -%s -> --%s: %s",
|
249
|
+
k,
|
250
|
+
shortform_map[k],
|
251
|
+
passed,
|
252
|
+
)
|
253
|
+
|
254
|
+
# There are 3 ways to pass shortform arguments, assuming a shortform
|
255
|
+
# of 'X:
|
256
|
+
#
|
257
|
+
# 1. -Xarg
|
258
|
+
# 2. -Xarg=foo
|
259
|
+
# 3. -Xarg foo
|
260
|
+
for p in passed:
|
261
|
+
if len(p) == 1 and "=" not in p[0]: # boolean
|
262
|
+
# Boolean shortfrom flags should store False if they contain
|
263
|
+
# "no", as a user would expect.
|
264
|
+
key = "{0}_{1}".format(
|
265
|
+
shortform_map[k], p[0].replace("-", "_").replace("no_", "")
|
266
|
+
)
|
267
|
+
ret[key] = "no" not in p[0]
|
268
|
+
|
269
|
+
elif len(p) == 1 and "=" in p[0]:
|
270
|
+
arg, value = p[0].split("=")
|
271
|
+
key = "{0}_{1}".format(shortform_map[k], arg.replace("-", "_"))
|
272
|
+
ret[key] = value
|
273
|
+
else:
|
274
|
+
key = "{0}_{1}".format(shortform_map[k], p[1:].replace("-", "_"))
|
275
|
+
ret[key] = p[1:]
|
276
|
+
|
277
|
+
return ret
|
164
278
|
|
165
279
|
def _load_config(self) -> None:
|
166
|
-
self.logger.debug(
|
167
|
-
|
280
|
+
self.logger.debug(
|
281
|
+
"Loading project config from '%s'", self.cmdopts["project_config_root"]
|
282
|
+
)
|
168
283
|
|
169
|
-
main_path = pathlib.Path(self.cmdopts[
|
170
|
-
config.kYAML.main)
|
284
|
+
main_path = pathlib.Path(self.cmdopts["project_config_root"], config.kYAML.main)
|
171
285
|
try:
|
172
286
|
with utils.utf8open(main_path) as f:
|
173
287
|
self.main_config = yaml.load(f, yaml.FullLoader)
|
@@ -176,17 +290,5 @@ class Pipeline:
|
|
176
290
|
self.logger.fatal("%s must exist!", main_path)
|
177
291
|
raise
|
178
292
|
|
179
|
-
perf_path = pathlib.Path(self.cmdopts['project_config_root'],
|
180
|
-
self.main_config['sierra']['perf'])
|
181
|
-
try:
|
182
|
-
perf_config = yaml.load(utils.utf8open(perf_path), yaml.FullLoader)
|
183
|
-
|
184
|
-
except FileNotFoundError:
|
185
|
-
self.logger.warning("%s does not exist!", perf_path)
|
186
|
-
perf_config = {}
|
187
|
-
self.main_config['sierra'].update(perf_config)
|
188
|
-
|
189
293
|
|
190
|
-
|
191
|
-
'Pipeline'
|
192
|
-
]
|
294
|
+
__all__ = ["Pipeline"]
|