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.
Files changed (254) hide show
  1. sierra/__init__.py +3 -3
  2. sierra/core/__init__.py +3 -3
  3. sierra/core/batchroot.py +223 -0
  4. sierra/core/cmdline.py +681 -1057
  5. sierra/core/compare.py +11 -0
  6. sierra/core/config.py +96 -88
  7. sierra/core/engine.py +306 -0
  8. sierra/core/execenv.py +380 -0
  9. sierra/core/expdef.py +11 -0
  10. sierra/core/experiment/__init__.py +1 -0
  11. sierra/core/experiment/bindings.py +150 -101
  12. sierra/core/experiment/definition.py +414 -245
  13. sierra/core/experiment/spec.py +83 -85
  14. sierra/core/exproot.py +44 -0
  15. sierra/core/generators/__init__.py +10 -0
  16. sierra/core/generators/experiment.py +528 -0
  17. sierra/core/generators/generator_factory.py +138 -137
  18. sierra/core/graphs/__init__.py +23 -0
  19. sierra/core/graphs/bcbridge.py +94 -0
  20. sierra/core/graphs/heatmap.py +245 -324
  21. sierra/core/graphs/pathset.py +27 -0
  22. sierra/core/graphs/schema.py +77 -0
  23. sierra/core/graphs/stacked_line.py +341 -0
  24. sierra/core/graphs/summary_line.py +506 -0
  25. sierra/core/logging.py +3 -2
  26. sierra/core/models/__init__.py +3 -1
  27. sierra/core/models/info.py +19 -0
  28. sierra/core/models/interface.py +52 -122
  29. sierra/core/pipeline/__init__.py +2 -5
  30. sierra/core/pipeline/pipeline.py +228 -126
  31. sierra/core/pipeline/stage1/__init__.py +10 -0
  32. sierra/core/pipeline/stage1/pipeline_stage1.py +45 -31
  33. sierra/core/pipeline/stage2/__init__.py +10 -0
  34. sierra/core/pipeline/stage2/pipeline_stage2.py +8 -11
  35. sierra/core/pipeline/stage2/runner.py +401 -0
  36. sierra/core/pipeline/stage3/__init__.py +12 -0
  37. sierra/core/pipeline/stage3/gather.py +321 -0
  38. sierra/core/pipeline/stage3/pipeline_stage3.py +37 -84
  39. sierra/core/pipeline/stage4/__init__.py +12 -2
  40. sierra/core/pipeline/stage4/pipeline_stage4.py +36 -354
  41. sierra/core/pipeline/stage5/__init__.py +12 -0
  42. sierra/core/pipeline/stage5/pipeline_stage5.py +33 -208
  43. sierra/core/pipeline/yaml.py +48 -0
  44. sierra/core/plugin.py +529 -62
  45. sierra/core/proc.py +11 -0
  46. sierra/core/prod.py +11 -0
  47. sierra/core/ros1/__init__.py +5 -1
  48. sierra/core/ros1/callbacks.py +22 -21
  49. sierra/core/ros1/cmdline.py +59 -88
  50. sierra/core/ros1/generators.py +159 -175
  51. sierra/core/ros1/variables/__init__.py +3 -0
  52. sierra/core/ros1/variables/exp_setup.py +122 -116
  53. sierra/core/startup.py +106 -76
  54. sierra/core/stat_kernels.py +4 -5
  55. sierra/core/storage.py +13 -32
  56. sierra/core/trampoline.py +30 -0
  57. sierra/core/types.py +116 -71
  58. sierra/core/utils.py +103 -106
  59. sierra/core/variables/__init__.py +1 -1
  60. sierra/core/variables/base_variable.py +12 -17
  61. sierra/core/variables/batch_criteria.py +387 -481
  62. sierra/core/variables/builtin.py +135 -0
  63. sierra/core/variables/exp_setup.py +19 -39
  64. sierra/core/variables/population_size.py +72 -76
  65. sierra/core/variables/variable_density.py +44 -68
  66. sierra/core/vector.py +1 -1
  67. sierra/main.py +256 -88
  68. sierra/plugins/__init__.py +119 -0
  69. sierra/plugins/compare/__init__.py +14 -0
  70. sierra/plugins/compare/graphs/__init__.py +19 -0
  71. sierra/plugins/compare/graphs/cmdline.py +120 -0
  72. sierra/plugins/compare/graphs/comparator.py +291 -0
  73. sierra/plugins/compare/graphs/inter_controller.py +531 -0
  74. sierra/plugins/compare/graphs/inter_scenario.py +297 -0
  75. sierra/plugins/compare/graphs/namecalc.py +53 -0
  76. sierra/plugins/compare/graphs/outputroot.py +73 -0
  77. sierra/plugins/compare/graphs/plugin.py +147 -0
  78. sierra/plugins/compare/graphs/preprocess.py +172 -0
  79. sierra/plugins/compare/graphs/schema.py +37 -0
  80. sierra/plugins/engine/__init__.py +14 -0
  81. sierra/plugins/engine/argos/__init__.py +18 -0
  82. sierra/plugins/{platform → engine}/argos/cmdline.py +144 -151
  83. sierra/plugins/{platform/argos/variables → engine/argos/generators}/__init__.py +5 -0
  84. sierra/plugins/engine/argos/generators/engine.py +394 -0
  85. sierra/plugins/engine/argos/plugin.py +393 -0
  86. sierra/plugins/{platform/argos/generators → engine/argos/variables}/__init__.py +5 -0
  87. sierra/plugins/engine/argos/variables/arena_shape.py +183 -0
  88. sierra/plugins/engine/argos/variables/cameras.py +240 -0
  89. sierra/plugins/engine/argos/variables/constant_density.py +112 -0
  90. sierra/plugins/engine/argos/variables/exp_setup.py +82 -0
  91. sierra/plugins/{platform → engine}/argos/variables/physics_engines.py +83 -87
  92. sierra/plugins/engine/argos/variables/population_constant_density.py +178 -0
  93. sierra/plugins/engine/argos/variables/population_size.py +115 -0
  94. sierra/plugins/engine/argos/variables/population_variable_density.py +123 -0
  95. sierra/plugins/engine/argos/variables/rendering.py +108 -0
  96. sierra/plugins/engine/ros1gazebo/__init__.py +18 -0
  97. sierra/plugins/engine/ros1gazebo/cmdline.py +175 -0
  98. sierra/plugins/{platform/ros1robot → engine/ros1gazebo}/generators/__init__.py +5 -0
  99. sierra/plugins/engine/ros1gazebo/generators/engine.py +125 -0
  100. sierra/plugins/engine/ros1gazebo/plugin.py +404 -0
  101. sierra/plugins/engine/ros1gazebo/variables/__init__.py +15 -0
  102. sierra/plugins/engine/ros1gazebo/variables/population_size.py +214 -0
  103. sierra/plugins/engine/ros1robot/__init__.py +18 -0
  104. sierra/plugins/engine/ros1robot/cmdline.py +159 -0
  105. sierra/plugins/{platform/ros1gazebo → engine/ros1robot}/generators/__init__.py +4 -0
  106. sierra/plugins/engine/ros1robot/generators/engine.py +95 -0
  107. sierra/plugins/engine/ros1robot/plugin.py +410 -0
  108. sierra/plugins/{hpc/local → engine/ros1robot/variables}/__init__.py +5 -0
  109. sierra/plugins/engine/ros1robot/variables/population_size.py +146 -0
  110. sierra/plugins/execenv/__init__.py +11 -0
  111. sierra/plugins/execenv/hpc/__init__.py +18 -0
  112. sierra/plugins/execenv/hpc/adhoc/__init__.py +18 -0
  113. sierra/plugins/execenv/hpc/adhoc/cmdline.py +30 -0
  114. sierra/plugins/execenv/hpc/adhoc/plugin.py +131 -0
  115. sierra/plugins/execenv/hpc/cmdline.py +137 -0
  116. sierra/plugins/execenv/hpc/local/__init__.py +18 -0
  117. sierra/plugins/execenv/hpc/local/cmdline.py +31 -0
  118. sierra/plugins/execenv/hpc/local/plugin.py +145 -0
  119. sierra/plugins/execenv/hpc/pbs/__init__.py +18 -0
  120. sierra/plugins/execenv/hpc/pbs/cmdline.py +30 -0
  121. sierra/plugins/execenv/hpc/pbs/plugin.py +121 -0
  122. sierra/plugins/execenv/hpc/slurm/__init__.py +18 -0
  123. sierra/plugins/execenv/hpc/slurm/cmdline.py +30 -0
  124. sierra/plugins/execenv/hpc/slurm/plugin.py +133 -0
  125. sierra/plugins/execenv/prefectserver/__init__.py +18 -0
  126. sierra/plugins/execenv/prefectserver/cmdline.py +66 -0
  127. sierra/plugins/execenv/prefectserver/dockerremote/__init__.py +18 -0
  128. sierra/plugins/execenv/prefectserver/dockerremote/cmdline.py +66 -0
  129. sierra/plugins/execenv/prefectserver/dockerremote/plugin.py +132 -0
  130. sierra/plugins/execenv/prefectserver/flow.py +66 -0
  131. sierra/plugins/execenv/prefectserver/local/__init__.py +18 -0
  132. sierra/plugins/execenv/prefectserver/local/cmdline.py +29 -0
  133. sierra/plugins/execenv/prefectserver/local/plugin.py +133 -0
  134. sierra/plugins/{hpc/adhoc → execenv/robot}/__init__.py +1 -0
  135. sierra/plugins/execenv/robot/turtlebot3/__init__.py +18 -0
  136. sierra/plugins/execenv/robot/turtlebot3/plugin.py +204 -0
  137. sierra/plugins/expdef/__init__.py +14 -0
  138. sierra/plugins/expdef/json/__init__.py +14 -0
  139. sierra/plugins/expdef/json/plugin.py +504 -0
  140. sierra/plugins/expdef/xml/__init__.py +14 -0
  141. sierra/plugins/expdef/xml/plugin.py +386 -0
  142. sierra/{core/hpc → plugins/proc}/__init__.py +1 -1
  143. sierra/plugins/proc/collate/__init__.py +15 -0
  144. sierra/plugins/proc/collate/cmdline.py +47 -0
  145. sierra/plugins/proc/collate/plugin.py +271 -0
  146. sierra/plugins/proc/compress/__init__.py +18 -0
  147. sierra/plugins/proc/compress/cmdline.py +47 -0
  148. sierra/plugins/proc/compress/plugin.py +123 -0
  149. sierra/plugins/proc/decompress/__init__.py +18 -0
  150. sierra/plugins/proc/decompress/plugin.py +96 -0
  151. sierra/plugins/proc/imagize/__init__.py +15 -0
  152. sierra/plugins/proc/imagize/cmdline.py +49 -0
  153. sierra/plugins/proc/imagize/plugin.py +270 -0
  154. sierra/plugins/proc/modelrunner/__init__.py +16 -0
  155. sierra/plugins/proc/modelrunner/plugin.py +250 -0
  156. sierra/plugins/proc/statistics/__init__.py +15 -0
  157. sierra/plugins/proc/statistics/cmdline.py +64 -0
  158. sierra/plugins/proc/statistics/plugin.py +390 -0
  159. sierra/plugins/{hpc → prod}/__init__.py +1 -0
  160. sierra/plugins/prod/graphs/__init__.py +18 -0
  161. sierra/plugins/prod/graphs/cmdline.py +269 -0
  162. sierra/plugins/prod/graphs/collate.py +279 -0
  163. sierra/plugins/prod/graphs/inter/__init__.py +13 -0
  164. sierra/plugins/prod/graphs/inter/generate.py +83 -0
  165. sierra/plugins/prod/graphs/inter/heatmap.py +86 -0
  166. sierra/plugins/prod/graphs/inter/line.py +134 -0
  167. sierra/plugins/prod/graphs/intra/__init__.py +15 -0
  168. sierra/plugins/prod/graphs/intra/generate.py +202 -0
  169. sierra/plugins/prod/graphs/intra/heatmap.py +74 -0
  170. sierra/plugins/prod/graphs/intra/line.py +114 -0
  171. sierra/plugins/prod/graphs/plugin.py +103 -0
  172. sierra/plugins/prod/graphs/targets.py +63 -0
  173. sierra/plugins/prod/render/__init__.py +18 -0
  174. sierra/plugins/prod/render/cmdline.py +72 -0
  175. sierra/plugins/prod/render/plugin.py +282 -0
  176. sierra/plugins/storage/__init__.py +5 -0
  177. sierra/plugins/storage/arrow/__init__.py +18 -0
  178. sierra/plugins/storage/arrow/plugin.py +38 -0
  179. sierra/plugins/storage/csv/__init__.py +9 -0
  180. sierra/plugins/storage/csv/plugin.py +12 -5
  181. sierra/version.py +3 -2
  182. sierra_research-1.5.0.dist-info/METADATA +238 -0
  183. sierra_research-1.5.0.dist-info/RECORD +186 -0
  184. {sierra_research-1.3.6.dist-info → sierra_research-1.5.0.dist-info}/WHEEL +1 -2
  185. sierra/core/experiment/xml.py +0 -454
  186. sierra/core/generators/controller_generator_parser.py +0 -34
  187. sierra/core/generators/exp_creator.py +0 -351
  188. sierra/core/generators/exp_generators.py +0 -142
  189. sierra/core/graphs/scatterplot2D.py +0 -109
  190. sierra/core/graphs/stacked_line_graph.py +0 -249
  191. sierra/core/graphs/stacked_surface_graph.py +0 -220
  192. sierra/core/graphs/summary_line_graph.py +0 -369
  193. sierra/core/hpc/cmdline.py +0 -142
  194. sierra/core/models/graphs.py +0 -87
  195. sierra/core/pipeline/stage2/exp_runner.py +0 -286
  196. sierra/core/pipeline/stage3/imagizer.py +0 -149
  197. sierra/core/pipeline/stage3/run_collator.py +0 -317
  198. sierra/core/pipeline/stage3/statistics_calculator.py +0 -478
  199. sierra/core/pipeline/stage4/graph_collator.py +0 -319
  200. sierra/core/pipeline/stage4/inter_exp_graph_generator.py +0 -240
  201. sierra/core/pipeline/stage4/intra_exp_graph_generator.py +0 -317
  202. sierra/core/pipeline/stage4/model_runner.py +0 -168
  203. sierra/core/pipeline/stage4/rendering.py +0 -283
  204. sierra/core/pipeline/stage4/yaml_config_loader.py +0 -103
  205. sierra/core/pipeline/stage5/inter_scenario_comparator.py +0 -328
  206. sierra/core/pipeline/stage5/intra_scenario_comparator.py +0 -989
  207. sierra/core/platform.py +0 -493
  208. sierra/core/plugin_manager.py +0 -369
  209. sierra/core/root_dirpath_generator.py +0 -241
  210. sierra/plugins/hpc/adhoc/plugin.py +0 -125
  211. sierra/plugins/hpc/local/plugin.py +0 -81
  212. sierra/plugins/hpc/pbs/__init__.py +0 -9
  213. sierra/plugins/hpc/pbs/plugin.py +0 -126
  214. sierra/plugins/hpc/slurm/__init__.py +0 -9
  215. sierra/plugins/hpc/slurm/plugin.py +0 -130
  216. sierra/plugins/platform/__init__.py +0 -9
  217. sierra/plugins/platform/argos/__init__.py +0 -9
  218. sierra/plugins/platform/argos/generators/platform_generators.py +0 -383
  219. sierra/plugins/platform/argos/plugin.py +0 -337
  220. sierra/plugins/platform/argos/variables/arena_shape.py +0 -145
  221. sierra/plugins/platform/argos/variables/cameras.py +0 -243
  222. sierra/plugins/platform/argos/variables/constant_density.py +0 -136
  223. sierra/plugins/platform/argos/variables/exp_setup.py +0 -113
  224. sierra/plugins/platform/argos/variables/population_constant_density.py +0 -175
  225. sierra/plugins/platform/argos/variables/population_size.py +0 -102
  226. sierra/plugins/platform/argos/variables/population_variable_density.py +0 -132
  227. sierra/plugins/platform/argos/variables/rendering.py +0 -104
  228. sierra/plugins/platform/ros1gazebo/__init__.py +0 -9
  229. sierra/plugins/platform/ros1gazebo/cmdline.py +0 -213
  230. sierra/plugins/platform/ros1gazebo/generators/platform_generators.py +0 -137
  231. sierra/plugins/platform/ros1gazebo/plugin.py +0 -335
  232. sierra/plugins/platform/ros1gazebo/variables/__init__.py +0 -10
  233. sierra/plugins/platform/ros1gazebo/variables/population_size.py +0 -204
  234. sierra/plugins/platform/ros1robot/__init__.py +0 -9
  235. sierra/plugins/platform/ros1robot/cmdline.py +0 -175
  236. sierra/plugins/platform/ros1robot/generators/platform_generators.py +0 -112
  237. sierra/plugins/platform/ros1robot/plugin.py +0 -373
  238. sierra/plugins/platform/ros1robot/variables/__init__.py +0 -10
  239. sierra/plugins/platform/ros1robot/variables/population_size.py +0 -146
  240. sierra/plugins/robot/__init__.py +0 -9
  241. sierra/plugins/robot/turtlebot3/__init__.py +0 -9
  242. sierra/plugins/robot/turtlebot3/plugin.py +0 -194
  243. sierra_research-1.3.6.data/data/share/man/man1/sierra-cli.1 +0 -2349
  244. sierra_research-1.3.6.data/data/share/man/man7/sierra-examples.7 +0 -488
  245. sierra_research-1.3.6.data/data/share/man/man7/sierra-exec-envs.7 +0 -331
  246. sierra_research-1.3.6.data/data/share/man/man7/sierra-glossary.7 +0 -285
  247. sierra_research-1.3.6.data/data/share/man/man7/sierra-platforms.7 +0 -358
  248. sierra_research-1.3.6.data/data/share/man/man7/sierra-usage.7 +0 -725
  249. sierra_research-1.3.6.data/data/share/man/man7/sierra.7 +0 -78
  250. sierra_research-1.3.6.dist-info/METADATA +0 -500
  251. sierra_research-1.3.6.dist-info/RECORD +0 -133
  252. sierra_research-1.3.6.dist-info/top_level.txt +0 -1
  253. {sierra_research-1.3.6.dist-info → sierra_research-1.5.0.dist-info}/entry_points.txt +0 -0
  254. {sierra_research-1.3.6.dist-info → sierra_research-1.5.0.dist-info/licenses}/LICENSE +0 -0
@@ -1,10 +1,11 @@
1
1
  # Copyright 2020 John Harwell, All rights reserved.
2
2
  #
3
3
  # SPDX-License-Identifier: MIT
4
- """Interface classes for the mathematical models framework in SIERRA.
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 IConcreteIntraExpModel1D(implements.Interface):
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`. Models will be
27
- rendered as lines on a
28
- :class:`~sierra.core.graphs.stacked_line_graph.StackedLineGraph`. Models
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 run(self,
35
- criteria: bc.IConcreteBatchCriteria,
36
- exp_num: int,
37
- cmdopts: types.Cmdopts) -> tp.List[pd.DataFrame]:
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 run_for_exp(self,
50
- criteria: bc.IConcreteBatchCriteria,
51
- cmdopts: types.Cmdopts,
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 IConcreteIntraExpModel2D(implements.Interface):
87
- """Interface for two-dimensional models.
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 run(self,
98
- criteria: bc.IConcreteBatchCriteria,
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
- class IConcreteInterExpModel1D(implements.Interface):
140
- """Interface for one-dimensional models.
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
- 1D models are those that generate a single time series from any number of
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
- def run(self,
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. Each
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 run_for_batch(self,
164
- criteria: bc.IConcreteBatchCriteria,
165
- cmdopts: types.Cmdopts) -> bool:
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
- __api__ = ['IConcreteIntraExpModel1D',
199
- 'IConcreteIntraExpModel2D',
200
- 'IConcreteInterExpModel1D']
127
+ __all__ = [
128
+ "IIntraExpModel1D",
129
+ "IInterExpModel1D",
130
+ ]
@@ -1,8 +1,5 @@
1
1
  # Copyright 2022 John Harwell, All rights reserved.
2
2
  #
3
3
  # SPDX-License-Identifier: MIT
4
- # import sierra.core.pipeline.stage1
5
- # import sierra.core.pipeline.stage2
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."""
@@ -3,7 +3,7 @@
3
3
  # SPDX-License-Identifier: MIT
4
4
  """The 5 pipeline stages implemented by SIERRA.
5
5
 
6
- See :ref:`ln-sierra-usage-pipeline` for high-level documentation.
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.plugin_manager as pm
21
- from sierra.core import types, config, utils
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__(self,
34
- args: argparse.Namespace,
35
- controller: tp.Optional[str],
36
- rdg_opts: types.Cmdopts) -> None:
37
- self.args = args
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
- assert all(stage in [1, 2, 3, 4, 5] for stage in args.pipeline), \
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
- project = pm.pipeline.get_plugin(self.cmdopts['project'])
123
- path = project['parent_dir'] / self.cmdopts['project']
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
- self.cmdopts['project_root'] = str(path)
126
- self.cmdopts['project_config_root'] = str(path / 'config')
127
- self.cmdopts['project_model_root'] = str(path / 'models')
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(project=self.cmdopts['project'],
133
- path='variables.batch_criteria')
134
- self.batch_criteria = bc.factory(self.main_config,
135
- self.cmdopts,
136
- self.args)
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(self.cmdopts,
146
- self.controller, # type: ignore
147
- self.batch_criteria).run()
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
- self.cmdopts).run(self.batch_criteria)
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
- self.cmdopts).run(self.batch_criteria)
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
- self.cmdopts).run(self.args)
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("Loading project config from '%s'",
167
- self.cmdopts['project_config_root'])
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['project_config_root'],
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
- __api__ = [
191
- 'Pipeline'
192
- ]
294
+ __all__ = ["Pipeline"]
@@ -0,0 +1,10 @@
1
+ # Copyright 2021 John Harwell, All rights reserved.
2
+ #
3
+ # SPDX-License-Identifier: MIT
4
+ """Container module for things stage 1 of the pipeline."""
5
+
6
+ # Core packages
7
+
8
+ # 3rd party packages
9
+
10
+ # Project packages