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,283 +0,0 @@
|
|
1
|
-
# Copyright 2019 John Harwell, All rights reserved.
|
2
|
-
#
|
3
|
-
# SPDX-License-Identifier: MIT
|
4
|
-
|
5
|
-
"""Classes for rendering frames (images) into videos.
|
6
|
-
|
7
|
-
Frames can be:
|
8
|
-
|
9
|
-
- Captured by by the ``--platform`` during stage 2.
|
10
|
-
|
11
|
-
- Generated during stage 3 of SIERRA via imagizing.
|
12
|
-
|
13
|
-
- Generated inter-experiment heatmaps from bivariate experiments.
|
14
|
-
|
15
|
-
"""
|
16
|
-
|
17
|
-
# Core packages
|
18
|
-
import subprocess
|
19
|
-
import typing as tp
|
20
|
-
import multiprocessing as mp
|
21
|
-
import queue
|
22
|
-
import copy
|
23
|
-
import shutil
|
24
|
-
import logging
|
25
|
-
import pathlib
|
26
|
-
|
27
|
-
# 3rd party packages
|
28
|
-
import psutil
|
29
|
-
|
30
|
-
# Project packages
|
31
|
-
import sierra.core.variables.batch_criteria as bc
|
32
|
-
from sierra.core import types, config, utils
|
33
|
-
|
34
|
-
|
35
|
-
class ParallelRenderer:
|
36
|
-
"""Base class for performing the requested rendering in parallel.
|
37
|
-
|
38
|
-
Unless disabled with ``--proccessing-serial``, then it is done serially.
|
39
|
-
|
40
|
-
"""
|
41
|
-
|
42
|
-
def __init__(self,
|
43
|
-
main_config: types.YAMLDict,
|
44
|
-
cmdopts: types.Cmdopts) -> None:
|
45
|
-
self.main_config = main_config
|
46
|
-
self.cmdopts = cmdopts
|
47
|
-
|
48
|
-
def do_rendering(self, inputs: tp.List[types.SimpleDict]) -> None:
|
49
|
-
"""
|
50
|
-
Do the rendering.
|
51
|
-
|
52
|
-
"""
|
53
|
-
q = mp.JoinableQueue() # type: mp.JoinableQueue
|
54
|
-
|
55
|
-
for spec in inputs:
|
56
|
-
q.put(spec)
|
57
|
-
|
58
|
-
# Render videos in parallel--waaayyyy faster
|
59
|
-
if self.cmdopts['processing_serial']:
|
60
|
-
parallelism = 1
|
61
|
-
else:
|
62
|
-
parallelism = psutil.cpu_count()
|
63
|
-
|
64
|
-
for _ in range(0, parallelism):
|
65
|
-
p = mp.Process(target=ParallelRenderer._thread_worker,
|
66
|
-
args=(q, self.main_config))
|
67
|
-
p.start()
|
68
|
-
|
69
|
-
q.join()
|
70
|
-
|
71
|
-
@staticmethod
|
72
|
-
def _thread_worker(q: mp.Queue, main_config: types.YAMLDict) -> None:
|
73
|
-
while True:
|
74
|
-
# Wait for 3 seconds after the queue is empty before bailing
|
75
|
-
try:
|
76
|
-
render_opts = q.get(True, 3)
|
77
|
-
ExpRenderer()(main_config, render_opts)
|
78
|
-
q.task_done()
|
79
|
-
except queue.Empty:
|
80
|
-
break
|
81
|
-
|
82
|
-
|
83
|
-
class PlatformFramesRenderer(ParallelRenderer):
|
84
|
-
"""Renders frames (images) captured in each experimental run by a platform.
|
85
|
-
|
86
|
-
"""
|
87
|
-
|
88
|
-
def __init__(self,
|
89
|
-
main_config: types.YAMLDict,
|
90
|
-
cmdopts: types.Cmdopts) -> None:
|
91
|
-
super().__init__(main_config, cmdopts)
|
92
|
-
self.main_config = main_config
|
93
|
-
self.cmdopts = cmdopts
|
94
|
-
self.logger = logging.getLogger(__name__)
|
95
|
-
|
96
|
-
def __call__(self, criteria: bc.IConcreteBatchCriteria) -> None:
|
97
|
-
exp_to_render = utils.exp_range_calc(self.cmdopts,
|
98
|
-
self.cmdopts['batch_output_root'],
|
99
|
-
criteria)
|
100
|
-
|
101
|
-
inputs = []
|
102
|
-
for exp in exp_to_render:
|
103
|
-
inputs.extend(self._calc_rendering_inputs(exp))
|
104
|
-
|
105
|
-
self.do_rendering(inputs)
|
106
|
-
|
107
|
-
def _calc_rendering_inputs(self,
|
108
|
-
exp: pathlib.Path) -> tp.List[types.SimpleDict]:
|
109
|
-
# Render targets are in
|
110
|
-
# <batch_output_root>/<exp>/<sim>/<frames_leaf>, for all
|
111
|
-
# runs in a given experiment (which can be a lot!).
|
112
|
-
output_dir = pathlib.Path(self.cmdopts['batch_video_root'], exp.name)
|
113
|
-
|
114
|
-
inputs = []
|
115
|
-
|
116
|
-
for run in exp.iterdir():
|
117
|
-
platform = self.cmdopts['platform'].split('.')[1]
|
118
|
-
frames_leaf = config.kRendering[platform]['frames_leaf']
|
119
|
-
opts = {
|
120
|
-
'ofile_name': run.name + config.kRenderFormat,
|
121
|
-
'input_dir': str(exp / run / frames_leaf),
|
122
|
-
'output_dir': str(output_dir),
|
123
|
-
'ffmpeg_opts': self.cmdopts['render_cmd_opts']
|
124
|
-
}
|
125
|
-
inputs.append(copy.deepcopy(opts))
|
126
|
-
|
127
|
-
return inputs
|
128
|
-
|
129
|
-
|
130
|
-
class ProjectFramesRenderer(ParallelRenderer):
|
131
|
-
"""Render the video for each experimental run in each experiment.
|
132
|
-
"""
|
133
|
-
|
134
|
-
def __init__(self,
|
135
|
-
main_config: types.YAMLDict,
|
136
|
-
cmdopts: types.Cmdopts) -> None:
|
137
|
-
super().__init__(main_config, cmdopts)
|
138
|
-
self.main_config = main_config
|
139
|
-
self.cmdopts = cmdopts
|
140
|
-
self.logger = logging.getLogger(__name__)
|
141
|
-
|
142
|
-
def __call__(self, criteria: bc.IConcreteBatchCriteria) -> None:
|
143
|
-
|
144
|
-
exp_to_render = utils.exp_range_calc(self.cmdopts,
|
145
|
-
self.cmdopts['batch_output_root'],
|
146
|
-
criteria)
|
147
|
-
|
148
|
-
inputs = []
|
149
|
-
for exp in exp_to_render:
|
150
|
-
inputs.extend(self._calc_rendering_inputs(exp))
|
151
|
-
|
152
|
-
self.do_rendering(inputs)
|
153
|
-
|
154
|
-
def _calc_rendering_inputs(self, exp: pathlib.Path) -> tp.List[types.SimpleDict]:
|
155
|
-
exp_imagize_root = pathlib.Path(self.cmdopts['batch_imagize_root'],
|
156
|
-
exp.name)
|
157
|
-
if not exp_imagize_root.exists():
|
158
|
-
return []
|
159
|
-
|
160
|
-
# Project render targets are in
|
161
|
-
# <batch_video_root>/<exp_name>, for all directories
|
162
|
-
# in <exp_imagize_root>.
|
163
|
-
output_dir = pathlib.Path(self.cmdopts['batch_video_root'], exp.name)
|
164
|
-
|
165
|
-
inputs = []
|
166
|
-
|
167
|
-
for candidate in exp_imagize_root.iterdir():
|
168
|
-
if candidate.is_dir():
|
169
|
-
opts = {
|
170
|
-
'input_dir': str(candidate),
|
171
|
-
'output_dir': str(output_dir),
|
172
|
-
'ofile_name': candidate.name + config.kRenderFormat,
|
173
|
-
'ffmpeg_opts': self.cmdopts['render_cmd_opts']
|
174
|
-
}
|
175
|
-
inputs.append(copy.deepcopy(opts))
|
176
|
-
|
177
|
-
return inputs
|
178
|
-
|
179
|
-
|
180
|
-
class BivarHeatmapRenderer(ParallelRenderer):
|
181
|
-
"""Render videos from generated inter-experiment heatmaps.
|
182
|
-
|
183
|
-
versionadded:: 1.2.20
|
184
|
-
"""
|
185
|
-
|
186
|
-
def __init__(self,
|
187
|
-
main_config: types.YAMLDict,
|
188
|
-
cmdopts: types.Cmdopts) -> None:
|
189
|
-
super().__init__(main_config, cmdopts)
|
190
|
-
self.main_config = main_config
|
191
|
-
self.cmdopts = cmdopts
|
192
|
-
self.logger = logging.getLogger(__name__)
|
193
|
-
|
194
|
-
def __call__(self, criteria: bc.IConcreteBatchCriteria) -> None:
|
195
|
-
inputs = self._calc_rendering_inputs()
|
196
|
-
self.do_rendering(inputs)
|
197
|
-
|
198
|
-
def _calc_rendering_inputs(self) -> tp.List[types.SimpleDict]:
|
199
|
-
graph_root = pathlib.Path(self.cmdopts['batch_graph_collate_root'])
|
200
|
-
|
201
|
-
inputs = []
|
202
|
-
|
203
|
-
for candidate in graph_root.iterdir():
|
204
|
-
if "HM-" in candidate.name and candidate.is_dir():
|
205
|
-
# Project render targets are in <batch_video_root>/<graph name>.
|
206
|
-
output_dir = pathlib.Path(self.cmdopts['batch_video_root'],
|
207
|
-
candidate.name)
|
208
|
-
|
209
|
-
opts = {
|
210
|
-
'input_dir': str(candidate),
|
211
|
-
'output_dir': str(output_dir),
|
212
|
-
'ofile_name': candidate.name + config.kRenderFormat,
|
213
|
-
'ffmpeg_opts': self.cmdopts['render_cmd_opts']
|
214
|
-
}
|
215
|
-
inputs.append(copy.deepcopy(opts))
|
216
|
-
|
217
|
-
return inputs
|
218
|
-
|
219
|
-
|
220
|
-
class ExpRenderer:
|
221
|
-
"""Render all images in the input directory to a video via :program:`ffmpeg`.
|
222
|
-
|
223
|
-
"""
|
224
|
-
|
225
|
-
def __init__(self) -> None:
|
226
|
-
self.logger = logging.getLogger(__name__)
|
227
|
-
assert shutil.which('ffmpeg') is not None, "ffmpeg not found"
|
228
|
-
|
229
|
-
def __call__(self,
|
230
|
-
main_config: types.YAMLDict,
|
231
|
-
render_opts: tp.Dict[str, str]) -> None:
|
232
|
-
output_dir = pathlib.Path(render_opts['output_dir'])
|
233
|
-
|
234
|
-
self.logger.info("Rendering images in %s...", output_dir.name)
|
235
|
-
|
236
|
-
opts = render_opts['ffmpeg_opts'].split(' ')
|
237
|
-
|
238
|
-
ipaths = "'{0}/*{1}'".format(render_opts['input_dir'],
|
239
|
-
config.kImageExt)
|
240
|
-
opath = pathlib.Path(render_opts['output_dir'],
|
241
|
-
render_opts['ofile_name'])
|
242
|
-
cmd = ["ffmpeg",
|
243
|
-
"-y",
|
244
|
-
"-pattern_type",
|
245
|
-
"glob",
|
246
|
-
"-i",
|
247
|
-
ipaths]
|
248
|
-
cmd.extend(opts)
|
249
|
-
cmd.extend([str(opath)])
|
250
|
-
|
251
|
-
to_run = ' '.join(cmd)
|
252
|
-
self.logger.trace('Run cmd: %s', to_run) # type: ignore
|
253
|
-
|
254
|
-
utils.dir_create_checked(render_opts['output_dir'],
|
255
|
-
exist_ok=True)
|
256
|
-
|
257
|
-
with subprocess.Popen(to_run,
|
258
|
-
shell=True,
|
259
|
-
stderr=subprocess.PIPE,
|
260
|
-
stdout=subprocess.PIPE) as proc:
|
261
|
-
proc.wait()
|
262
|
-
|
263
|
-
# We use communicate(), not wait() to avoid issues with IO buffers
|
264
|
-
# becoming full (i.e., you get deadlocks with wait() regularly).
|
265
|
-
stdout_raw, stderr_raw = proc.communicate()
|
266
|
-
|
267
|
-
# Only show output if the process failed (i.e., did not return 0)
|
268
|
-
if proc.returncode != 0:
|
269
|
-
self.logger.error("Cmd '%s' failed!", to_run)
|
270
|
-
stdout_str = stdout_raw.decode("ascii")
|
271
|
-
stderr_str = stderr_raw.decode("ascii")
|
272
|
-
|
273
|
-
self.logger.error(stdout_str)
|
274
|
-
self.logger.error(stderr_str)
|
275
|
-
|
276
|
-
|
277
|
-
__api__ = [
|
278
|
-
'ParallelRenderer',
|
279
|
-
'PlatformFramesRenderer',
|
280
|
-
'ProjectFramesRenderer',
|
281
|
-
'BivarHeatmapRenderer',
|
282
|
-
'ExpRenderer'
|
283
|
-
]
|
@@ -1,103 +0,0 @@
|
|
1
|
-
# Copyright 2021 John Harwell, All rights reserved.
|
2
|
-
#
|
3
|
-
# SPDX-License-Identifier: MIT
|
4
|
-
|
5
|
-
# Core packages
|
6
|
-
import typing as tp
|
7
|
-
import logging
|
8
|
-
import pathlib
|
9
|
-
|
10
|
-
# 3rd party packages
|
11
|
-
import yaml
|
12
|
-
|
13
|
-
# Project packages
|
14
|
-
from sierra.core import types, utils
|
15
|
-
|
16
|
-
|
17
|
-
class YAMLConfigLoader():
|
18
|
-
"""Load YAML configuration for :term:`Project` graphs to be generated.
|
19
|
-
|
20
|
-
This class can be extended/overriden using a :term:`Project` hook. See
|
21
|
-
:ref:`ln-sierra-tutorials-project-hooks` for details.
|
22
|
-
|
23
|
-
Attributes:
|
24
|
-
logger: The handle to the logger for this class. If you extend this
|
25
|
-
class, you should save/restore this variable in tandem with
|
26
|
-
overriding it in order to get loggingmessages have unique
|
27
|
-
logger names between this class and your derived class, in order
|
28
|
-
to reduce confusion.
|
29
|
-
|
30
|
-
"""
|
31
|
-
|
32
|
-
def __init__(self) -> None:
|
33
|
-
self.logger = logging.getLogger(__name__)
|
34
|
-
|
35
|
-
def __call__(self, cmdopts: types.Cmdopts) -> tp.Dict[str, types.YAMLDict]:
|
36
|
-
"""
|
37
|
-
Load YAML configuratoin for graphs.
|
38
|
-
|
39
|
-
This includes:
|
40
|
-
|
41
|
-
- intra-experiment linegraphs
|
42
|
-
|
43
|
-
- inter-experiment linegraphs
|
44
|
-
|
45
|
-
- intra-experiment heatmaps
|
46
|
-
|
47
|
-
- inter-experiment heatmaps (bivariate batch criteria only)
|
48
|
-
|
49
|
-
Returns:
|
50
|
-
|
51
|
-
Dictionary of loaded configuration with keys for ``intra_LN,
|
52
|
-
inter_LN, intra_HM, inter_HM``.
|
53
|
-
"""
|
54
|
-
inter_LN_config = {}
|
55
|
-
intra_LN_config = {}
|
56
|
-
intra_HM_config = {}
|
57
|
-
inter_HM_config = {}
|
58
|
-
|
59
|
-
root = pathlib.Path(cmdopts['project_config_root'])
|
60
|
-
project_inter_LN = root / 'inter-graphs-line.yaml'
|
61
|
-
project_intra_LN = root / 'intra-graphs-line.yaml'
|
62
|
-
project_intra_HM = root / 'intra-graphs-hm.yaml'
|
63
|
-
project_inter_HM = root / 'inter-graphs-hm.yaml'
|
64
|
-
|
65
|
-
if utils.path_exists(project_intra_LN):
|
66
|
-
self.logger.info("Intra-experiment linegraph config for project '%s' from %s",
|
67
|
-
cmdopts['project'],
|
68
|
-
project_intra_LN)
|
69
|
-
with utils.utf8open(project_intra_LN) as f:
|
70
|
-
intra_LN_config = yaml.load(f, yaml.FullLoader)
|
71
|
-
|
72
|
-
if utils.path_exists(project_inter_LN):
|
73
|
-
self.logger.info("Inter-experiment linegraph config for project '%s' from %s",
|
74
|
-
cmdopts['project'],
|
75
|
-
project_inter_LN)
|
76
|
-
with utils.utf8open(project_inter_LN) as f:
|
77
|
-
inter_LN_config = yaml.load(f, yaml.FullLoader)
|
78
|
-
|
79
|
-
if utils.path_exists(project_intra_HM):
|
80
|
-
self.logger.info("Intra-experiment heatmap config for project '%s' from %s",
|
81
|
-
cmdopts['project'],
|
82
|
-
project_intra_HM)
|
83
|
-
with utils.utf8open(project_intra_HM) as f:
|
84
|
-
intra_HM_config = yaml.load(f, yaml.FullLoader)
|
85
|
-
|
86
|
-
if utils.path_exists(project_inter_HM):
|
87
|
-
self.logger.info("Inter-experiment heatmap config for project '%s' from %s",
|
88
|
-
cmdopts['project'],
|
89
|
-
project_inter_HM)
|
90
|
-
with utils.utf8open(project_inter_HM) as f:
|
91
|
-
inter_HM_config = yaml.load(f, yaml.FullLoader)
|
92
|
-
|
93
|
-
return {
|
94
|
-
'intra_LN': intra_LN_config,
|
95
|
-
'intra_HM': intra_HM_config,
|
96
|
-
'inter_LN': inter_LN_config,
|
97
|
-
'inter_HM': inter_HM_config
|
98
|
-
}
|
99
|
-
|
100
|
-
|
101
|
-
__api__ = [
|
102
|
-
'YAMLConfigLoader'
|
103
|
-
]
|