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
@@ -0,0 +1,30 @@
|
|
1
|
+
#
|
2
|
+
# Copyright 2025 John Harwell, All rights reserved.
|
3
|
+
#
|
4
|
+
# SPDX-License Identifier: MIT
|
5
|
+
#
|
6
|
+
|
7
|
+
# Core packages
|
8
|
+
import typing as tp
|
9
|
+
import argparse
|
10
|
+
|
11
|
+
# 3rd party packages
|
12
|
+
|
13
|
+
# Project packages
|
14
|
+
from sierra.core import plugin as pm
|
15
|
+
|
16
|
+
|
17
|
+
def cmdline_parser(
|
18
|
+
plugin: str, parents: tp.List[argparse.ArgumentParser], stages: tp.List[int]
|
19
|
+
) -> tp.Optional[argparse.ArgumentParser]:
|
20
|
+
"""
|
21
|
+
Dispatches cmdline parser creation to selected plugin.
|
22
|
+
|
23
|
+
If the selected plugin does not define a cmdline, None is returned.
|
24
|
+
"""
|
25
|
+
path = "{0}.cmdline".format(plugin)
|
26
|
+
if pm.module_exists(path):
|
27
|
+
module = pm.module_load_tiered(path)
|
28
|
+
return module.build(parents, stages).parser
|
29
|
+
|
30
|
+
return None
|
sierra/core/types.py
CHANGED
@@ -1,14 +1,21 @@
|
|
1
1
|
# Copyright 2021 John Harwell, All rights reserved.
|
2
2
|
#
|
3
3
|
# SPDX-License-Identifier: MIT
|
4
|
-
"""Custom types defined by SIERRA for more readable type hints.
|
5
|
-
|
6
|
-
"""
|
4
|
+
"""Custom types defined by SIERRA for more readable type hints."""
|
7
5
|
# Core packages
|
8
6
|
import typing as tp
|
9
|
-
|
7
|
+
import sys
|
8
|
+
from types import ModuleType # noqa: F401 pylint: disable=unused-import
|
9
|
+
from dataclasses import dataclass
|
10
10
|
import pathlib
|
11
11
|
|
12
|
+
# 2024-12-03 [JRH]: Once SIERRA moves to 3.10+ this (and many other instances)
|
13
|
+
# can be replaced unilaterally with tp.TypeAlias.
|
14
|
+
if sys.version_info < (3, 10):
|
15
|
+
from typing_extensions import TypeAlias
|
16
|
+
else:
|
17
|
+
from typing import TypeAlias
|
18
|
+
|
12
19
|
# 3rd party packages
|
13
20
|
|
14
21
|
# Project packages
|
@@ -17,71 +24,109 @@ import pathlib
|
|
17
24
|
# Type Definitions
|
18
25
|
################################################################################
|
19
26
|
|
20
|
-
Cmdopts = tp.Dict[str, tp.Any]
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
27
|
+
Cmdopts: TypeAlias = tp.Dict[str, tp.Any]
|
28
|
+
"""Dictionary of parsed cmdline options."""
|
29
|
+
|
30
|
+
YAMLDict: TypeAlias = tp.Union[None, bool, str, float, int, tp.Dict[str, "YAMLDict"]]
|
31
|
+
"""Parsed YAML dictionary."""
|
32
|
+
|
33
|
+
SimpleDict: TypeAlias = tp.Dict[str, tp.Union[str, int]]
|
34
|
+
"""Dictionary str -> {str|int} mappings."""
|
35
|
+
|
36
|
+
# 2024-12-03 [JRH]: Once SIERRA moves to 3.10+ this (and many other instances)
|
37
|
+
# can be replaced with the '|' syntax, which is much nicer. Also the TypeAlias
|
38
|
+
# import from extensions won't be needed/will be part of the tying module.
|
39
|
+
JSON: TypeAlias = tp.Union[dict[str, "JSON"], list["JSON"], str, int, float, bool, None]
|
40
|
+
"""Dictionary of parsed JSON."""
|
41
|
+
|
42
|
+
StrDict: TypeAlias = tp.Dict[str, str]
|
43
|
+
"""Dictionary containing str -> str mappings."""
|
44
|
+
|
45
|
+
IntDict: TypeAlias = tp.Dict[str, int]
|
46
|
+
"""Dictionary containing str -> int mappings."""
|
47
|
+
|
48
|
+
CLIArgSpec: TypeAlias = tp.Dict[str, tp.Any]
|
49
|
+
"""Dictionary containing str -> anything mappings for parsing stuff from the
|
50
|
+
cmdline into components."""
|
51
|
+
|
52
|
+
PathList: TypeAlias = tp.List[pathlib.Path]
|
53
|
+
"""List of paths."""
|
54
|
+
|
55
|
+
|
56
|
+
@dataclass
|
57
|
+
class ShellCmdSpec:
|
58
|
+
"""
|
59
|
+
Dataclass containing info to run shell cmds.
|
60
|
+
|
61
|
+
Contains:
|
62
|
+
|
63
|
+
- The cmd to run. This should end in a ';' so that multiple commands can
|
64
|
+
be specified to run in sequence.
|
65
|
+
|
66
|
+
- Whether or not it should be strictly run in a shell via
|
67
|
+
``shell=True``.
|
68
|
+
|
69
|
+
- Whether to wait for it to finish before returning.
|
70
|
+
|
71
|
+
- Whether to inherit the environment from the calling process.
|
72
|
+
"""
|
73
|
+
|
74
|
+
cmd: str
|
75
|
+
shell: bool
|
76
|
+
wait: bool
|
77
|
+
env: tp.Optional[bool] = False
|
78
|
+
|
79
|
+
|
80
|
+
@dataclass
|
81
|
+
class YAMLConfigFileSpec:
|
82
|
+
"""Spec for all the .yaml files available for :term:`Projects <Project>`."""
|
83
|
+
|
84
|
+
main: str
|
85
|
+
graphs: str
|
86
|
+
collate: str
|
87
|
+
controllers: str
|
88
|
+
scenarios: str
|
89
|
+
models: str
|
90
|
+
|
91
|
+
|
92
|
+
@dataclass
|
93
|
+
class ParsedNodefileSpec:
|
94
|
+
"""Per line in a GNU parallel style nodefil, containing info a single resource."""
|
95
|
+
|
96
|
+
hostname: str
|
97
|
+
n_cores: int
|
98
|
+
login: str
|
99
|
+
port: int
|
100
|
+
|
101
|
+
|
102
|
+
@dataclass
|
103
|
+
class OSPackagesSpec:
|
104
|
+
"""Info about what packages are required/optional on a given OS."""
|
105
|
+
|
106
|
+
kernel: str
|
107
|
+
name: str
|
108
|
+
pkgs: tp.Dict[str, bool]
|
109
|
+
|
110
|
+
|
111
|
+
@dataclass
|
112
|
+
class StatisticsSpec:
|
113
|
+
"""Spec mapping file types of statistics to file extensions to contain said stats."""
|
114
|
+
|
115
|
+
exts: StrDict
|
116
|
+
|
117
|
+
|
118
|
+
__all__ = [
|
119
|
+
"ShellCmdSpec",
|
120
|
+
"YAMLConfigFileSpec",
|
121
|
+
"ParsedNodefileSpec",
|
122
|
+
"OSPackagesSpec",
|
123
|
+
"StatisticsSpec",
|
124
|
+
"Cmdopts",
|
125
|
+
"YAMLDict",
|
126
|
+
"SimpleDict",
|
127
|
+
"JSON",
|
128
|
+
"StrDict",
|
129
|
+
"IntDict",
|
130
|
+
"CLIArgSpec",
|
131
|
+
"PathList",
|
87
132
|
]
|
sierra/core/utils.py
CHANGED
@@ -2,9 +2,7 @@
|
|
2
2
|
#
|
3
3
|
# SPDX-License-Identifier: MIT
|
4
4
|
|
5
|
-
"""Miscellaneous bits used in mutiple places but that don't fit anywhere else.
|
6
|
-
|
7
|
-
"""
|
5
|
+
"""Miscellaneous bits used in mutiple places but that don't fit anywhere else."""
|
8
6
|
|
9
7
|
# Core packages
|
10
8
|
import typing as tp
|
@@ -21,15 +19,16 @@ from retry import retry
|
|
21
19
|
|
22
20
|
# Project packages
|
23
21
|
from sierra.core.vector import Vector3D
|
24
|
-
from sierra.core.experiment import
|
22
|
+
from sierra.core.experiment import definition
|
25
23
|
from sierra.core import types, config
|
26
|
-
from sierra.core import
|
24
|
+
from sierra.core import plugin as pm
|
27
25
|
|
28
26
|
|
29
|
-
class ArenaExtent
|
27
|
+
class ArenaExtent:
|
30
28
|
"""Representation of a 2D or 3D section/chunk/volume of the arena."""
|
29
|
+
|
31
30
|
@staticmethod
|
32
|
-
def from_corners(ll: Vector3D, ur: Vector3D) ->
|
31
|
+
def from_corners(ll: Vector3D, ur: Vector3D) -> "ArenaExtent":
|
33
32
|
"""Initialize an extent via LL and UR corners.
|
34
33
|
|
35
34
|
As opposed to an origin and a set of dimensions.
|
@@ -64,11 +63,11 @@ class ArenaExtent():
|
|
64
63
|
return self._origin
|
65
64
|
|
66
65
|
def __str__(self) -> str:
|
67
|
-
return str(self.dims) +
|
66
|
+
return str(self.dims) + "@" + str(self._origin)
|
68
67
|
|
69
68
|
|
70
|
-
class Sigmoid
|
71
|
-
"""
|
69
|
+
class Sigmoid:
|
70
|
+
r"""
|
72
71
|
Sigmoid activation function.
|
73
72
|
|
74
73
|
.. math::
|
@@ -89,7 +88,7 @@ class Sigmoid():
|
|
89
88
|
return 1.0 / (1 + np.exp(-self.x)) # type: ignore
|
90
89
|
|
91
90
|
|
92
|
-
class ReLu
|
91
|
+
class ReLu:
|
93
92
|
r"""
|
94
93
|
Rectified Linear Unit (ReLU) activation function.
|
95
94
|
|
@@ -118,8 +117,7 @@ def scale_minmax(minval: float, maxval: float, val: float) -> float:
|
|
118
117
|
return -1.0 + (val - minval) * (1 - (-1)) / (maxval - minval)
|
119
118
|
|
120
119
|
|
121
|
-
def dir_create_checked(path: tp.Union[pathlib.Path, str],
|
122
|
-
exist_ok: bool) -> None:
|
120
|
+
def dir_create_checked(path: tp.Union[pathlib.Path, str], exist_ok: bool) -> None:
|
123
121
|
"""Create a directory idempotently.
|
124
122
|
|
125
123
|
If the directory exists and it shouldn't, raise an error.
|
@@ -158,51 +156,46 @@ def path_exists(path: tp.Union[pathlib.Path, str]) -> bool:
|
|
158
156
|
return max(set(res), key=res.count)
|
159
157
|
|
160
158
|
|
161
|
-
def get_primary_axis(criteria,
|
162
|
-
primary_axis_bc: tp.List,
|
163
|
-
cmdopts: types.Cmdopts) -> int:
|
159
|
+
def get_primary_axis(criteria, primary_axis_bc: tp.List, cmdopts: types.Cmdopts) -> int:
|
164
160
|
"""
|
165
161
|
Determine axis in a bivariate batch criteria is the primary axis.
|
166
162
|
|
167
163
|
This is obtained on a per-query basis depending on the query context, or can
|
168
164
|
be overriden on the cmdline.
|
169
165
|
"""
|
170
|
-
if cmdopts[
|
166
|
+
if cmdopts["plot_primary_axis"] == 0:
|
171
167
|
return 0
|
172
168
|
|
173
|
-
if cmdopts[
|
169
|
+
if cmdopts["plot_primary_axis"] == 1:
|
174
170
|
return 1
|
175
171
|
|
176
|
-
if any(isinstance(criteria.
|
172
|
+
if any(isinstance(criteria.criterias[1], elt) for elt in primary_axis_bc):
|
177
173
|
return 0
|
178
174
|
|
179
175
|
return 1
|
180
176
|
|
181
177
|
|
182
|
-
def exp_range_calc(
|
183
|
-
|
184
|
-
|
178
|
+
def exp_range_calc(
|
179
|
+
exp_range: str, root_dir: pathlib.Path, dirnames: tp.List[str]
|
180
|
+
) -> types.PathList:
|
185
181
|
"""
|
186
182
|
Get the range of experiments to run/do stuff with. SUPER USEFUL.
|
187
183
|
"""
|
188
|
-
exp_all = [root_dir / d for d in
|
184
|
+
exp_all = [root_dir / d for d in dirnames]
|
189
185
|
|
190
|
-
exp_range
|
186
|
+
if exp_range is not None:
|
187
|
+
min_exp = int(exp_range.split(":")[0])
|
188
|
+
max_exp = int(exp_range.split(":")[1])
|
189
|
+
assert (
|
190
|
+
min_exp <= max_exp
|
191
|
+
), f"Min batch exp >= max batch exp({min_exp} vs. {max_exp})"
|
191
192
|
|
192
|
-
|
193
|
-
min_exp = int(exp_range.split(':')[0])
|
194
|
-
max_exp = int(exp_range.split(':')[1])
|
195
|
-
assert min_exp <= max_exp, \
|
196
|
-
f"Min batch exp >= max batch exp({min_exp} vs. {max_exp})"
|
197
|
-
|
198
|
-
return exp_all[min_exp: max_exp + 1]
|
193
|
+
return exp_all[min_exp : max_exp + 1]
|
199
194
|
|
200
195
|
return exp_all
|
201
196
|
|
202
197
|
|
203
|
-
def exp_include_filter(inc_spec: tp.Optional[str],
|
204
|
-
target: tp.List,
|
205
|
-
n_exps: int):
|
198
|
+
def exp_include_filter(inc_spec: tp.Optional[str], target: tp.List, n_exps: int):
|
206
199
|
"""Calculate which experiments to include in a calculation for something.
|
207
200
|
|
208
201
|
Take a input list of experiment numbers to include, and returns the sublist
|
@@ -216,9 +209,9 @@ def exp_include_filter(inc_spec: tp.Optional[str],
|
|
216
209
|
start = None
|
217
210
|
end = None
|
218
211
|
else:
|
219
|
-
r = inc_spec.split(
|
212
|
+
r = inc_spec.split(":")
|
220
213
|
start = int(r[0])
|
221
|
-
if r[1] ==
|
214
|
+
if r[1] == "":
|
222
215
|
end = len(target)
|
223
216
|
else:
|
224
217
|
end = int(r[1])
|
@@ -229,8 +222,9 @@ def exp_include_filter(inc_spec: tp.Optional[str],
|
|
229
222
|
return target[slice(start, end, None)]
|
230
223
|
|
231
224
|
|
232
|
-
def bivar_exp_labels_calc(
|
233
|
-
|
225
|
+
def bivar_exp_labels_calc(
|
226
|
+
exp_dirs: types.PathList,
|
227
|
+
) -> tp.Tuple[tp.List[str], tp.List[str]]:
|
234
228
|
"""
|
235
229
|
Calculate the labels for bivariant experiment graphs.
|
236
230
|
"""
|
@@ -241,7 +235,7 @@ def bivar_exp_labels_calc(exp_dirs: types.PathList) -> tp.Tuple[tp.List[str],
|
|
241
235
|
xlabels_set = set()
|
242
236
|
ylabels_set = set()
|
243
237
|
for e in exp_dirs:
|
244
|
-
pair = e.name.split(
|
238
|
+
pair = e.name.split("+")
|
245
239
|
xlabels_set.add(pair[0])
|
246
240
|
ylabels_set.add(pair[1])
|
247
241
|
|
@@ -251,27 +245,28 @@ def bivar_exp_labels_calc(exp_dirs: types.PathList) -> tp.Tuple[tp.List[str],
|
|
251
245
|
return (xlabels, ylabels)
|
252
246
|
|
253
247
|
|
254
|
-
def apply_to_expdef(var,
|
255
|
-
|
256
|
-
|
257
|
-
|
248
|
+
def apply_to_expdef(var, exp_def: definition.BaseExpDef) -> tp.Tuple[
|
249
|
+
tp.Optional[definition.ElementRmList],
|
250
|
+
tp.Optional[definition.ElementAddList],
|
251
|
+
tp.Optional[definition.AttrChangeSet],
|
252
|
+
]:
|
258
253
|
"""
|
259
|
-
Apply a generated
|
254
|
+
Apply a generated expdef modifictions to an experiment definition.
|
260
255
|
|
261
256
|
In this order:
|
262
257
|
|
263
|
-
#. Remove existing
|
264
|
-
#. Add new
|
265
|
-
#. Change existing
|
258
|
+
#. Remove existing expdef elements
|
259
|
+
#. Add new expdef elements
|
260
|
+
#. Change existing expdef element attributes
|
266
261
|
"""
|
267
|
-
rmsl = var.gen_tag_rmlist() # type: tp.List[
|
268
|
-
addsl = var.
|
269
|
-
chgsl = var.gen_attr_changelist() # type: tp.List[
|
262
|
+
rmsl = var.gen_tag_rmlist() # type: tp.List[definition.ElementRmList]
|
263
|
+
addsl = var.gen_element_addlist() # type: tp.List[definition.ElementAddList]
|
264
|
+
chgsl = var.gen_attr_changelist() # type: tp.List[definition.AttrChangeSet]
|
270
265
|
|
271
266
|
if rmsl:
|
272
267
|
rms = rmsl[0]
|
273
268
|
for r in rms:
|
274
|
-
exp_def.
|
269
|
+
exp_def.element_remove(r.path, r.tag)
|
275
270
|
else:
|
276
271
|
rms = None
|
277
272
|
|
@@ -279,7 +274,7 @@ def apply_to_expdef(var,
|
|
279
274
|
adds = addsl[0]
|
280
275
|
for a in adds:
|
281
276
|
assert a.path is not None, "Can't add tag {a.tag} with no parent"
|
282
|
-
exp_def.
|
277
|
+
exp_def.element_add(a.path, a.tag, a.attr, a.allow_dup)
|
283
278
|
else:
|
284
279
|
adds = None
|
285
280
|
|
@@ -293,11 +288,13 @@ def apply_to_expdef(var,
|
|
293
288
|
return rms, adds, chgs
|
294
289
|
|
295
290
|
|
296
|
-
def pickle_modifications(
|
297
|
-
|
298
|
-
|
291
|
+
def pickle_modifications(
|
292
|
+
adds: tp.Optional[definition.ElementAddList],
|
293
|
+
chgs: tp.Optional[definition.AttrChangeSet],
|
294
|
+
path: pathlib.Path,
|
295
|
+
) -> None:
|
299
296
|
"""
|
300
|
-
After applying
|
297
|
+
After applying expdef modifications, pickle changes for later retrieval.
|
301
298
|
"""
|
302
299
|
if adds is not None:
|
303
300
|
adds.pickle(path)
|
@@ -306,29 +303,31 @@ def pickle_modifications(adds: tp.Optional[xml.TagAddList],
|
|
306
303
|
chgs.pickle(path)
|
307
304
|
|
308
305
|
|
309
|
-
def exp_template_path(
|
310
|
-
|
311
|
-
|
306
|
+
def exp_template_path(
|
307
|
+
cmdopts: types.Cmdopts, batch_input_root: pathlib.Path, dirname: str
|
308
|
+
) -> pathlib.Path:
|
312
309
|
"""Calculate the path to the template input file in the batch experiment root.
|
313
310
|
|
314
|
-
|
315
|
-
|
311
|
+
The file at this path will be Used as the de-facto template for generating
|
312
|
+
per-run input files.
|
316
313
|
|
317
314
|
"""
|
318
|
-
template = pathlib.Path(cmdopts[
|
315
|
+
template = pathlib.Path(cmdopts["expdef_template"])
|
319
316
|
return batch_input_root / dirname / template.stem
|
320
317
|
|
321
318
|
|
322
|
-
def
|
323
|
-
|
324
|
-
|
325
|
-
|
319
|
+
def get_n_agents(
|
320
|
+
main_config: types.YAMLDict,
|
321
|
+
cmdopts: types.Cmdopts,
|
322
|
+
exp_input_root: pathlib.Path,
|
323
|
+
exp_def: definition.BaseExpDef,
|
324
|
+
) -> int:
|
326
325
|
"""
|
327
|
-
Get the #
|
326
|
+
Get the # agents used for a specific :term:`Experiment`.
|
328
327
|
"""
|
329
|
-
|
328
|
+
module1 = pm.pipeline.get_plugin_module(cmdopts["engine"])
|
330
329
|
|
331
|
-
# Get #
|
330
|
+
# Get # agents to send to shell cmds generator. We try:
|
332
331
|
#
|
333
332
|
# 1. Getting it from the current experiment definition, which contains all
|
334
333
|
# changes to the template input file EXCEPT those from batch criteria,
|
@@ -336,29 +335,28 @@ def get_n_robots(main_config: types.YAMLDict,
|
|
336
335
|
#
|
337
336
|
# 2. Getting it from the pickled experiment definition (i.e., from the
|
338
337
|
# batch criteria which was used for this experiment).
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
if n_robots <= 0:
|
343
|
-
pkl_def = definition.unpickle(exp_input_root / config.kPickleLeaf)
|
344
|
-
n_robots = module.population_size_from_pickle(pkl_def,
|
345
|
-
main_config,
|
346
|
-
cmdopts)
|
338
|
+
n_agents = module1.population_size_from_def(exp_def, main_config, cmdopts)
|
339
|
+
|
340
|
+
module2 = pm.pipeline.get_plugin_module(cmdopts["expdef"])
|
347
341
|
|
348
|
-
|
342
|
+
if n_agents <= 0:
|
343
|
+
pkl_def = module2.unpickle(exp_input_root / config.kPickleLeaf)
|
344
|
+
n_agents = module1.population_size_from_pickle(pkl_def, main_config, cmdopts)
|
349
345
|
|
350
|
-
|
346
|
+
assert n_agents > 0, "n_agents must be > 0"
|
347
|
+
|
348
|
+
return n_agents
|
351
349
|
|
352
350
|
|
353
351
|
def df_fill(df: pd.DataFrame, policy: str) -> pd.DataFrame:
|
354
352
|
"""
|
355
353
|
Fill missing cells in a dataframe according to the specified fill policy.
|
356
354
|
"""
|
357
|
-
if policy ==
|
355
|
+
if policy == "none":
|
358
356
|
return df
|
359
|
-
elif policy ==
|
360
|
-
return df.fillna(method=
|
361
|
-
elif policy ==
|
357
|
+
elif policy == "pad":
|
358
|
+
return df.fillna(method="pad")
|
359
|
+
elif policy == "zero":
|
362
360
|
return df.fillna(value=0)
|
363
361
|
else:
|
364
362
|
raise RuntimeError(f"Bad fill policy {policy}")
|
@@ -372,20 +370,19 @@ def pickle_dump(obj: object, f) -> None:
|
|
372
370
|
def gen_scenario_spec(cmdopts: types.Cmdopts, **kwargs) -> tp.Dict[str, tp.Any]:
|
373
371
|
# scenario is passed in kwargs during stage 5 (can't be passed via
|
374
372
|
# --scenario in general )
|
375
|
-
scenario = kwargs.get(
|
376
|
-
|
377
|
-
sgp = pm.module_load_tiered(project=cmdopts['project'],
|
378
|
-
path='generators.scenario_generator_parser')
|
379
|
-
kw = sgp.ScenarioGeneratorParser().to_dict(scenario)
|
373
|
+
scenario = kwargs.get("scenario", cmdopts["scenario"])
|
380
374
|
|
381
|
-
|
375
|
+
module = pm.module_load_tiered(
|
376
|
+
project=cmdopts["project"], path="generators.scenario"
|
377
|
+
)
|
378
|
+
return module.to_dict(scenario)
|
382
379
|
|
383
380
|
|
384
381
|
def sphinx_ref(ref: str) -> str:
|
385
382
|
try:
|
386
383
|
# This is kind of a hack...
|
387
384
|
if __sphinx_build_man__: # type: ignore
|
388
|
-
parts = ref.split(
|
385
|
+
parts = ref.split(".")
|
389
386
|
stripped = parts[-1]
|
390
387
|
return stripped[:-1]
|
391
388
|
|
@@ -395,25 +392,25 @@ def sphinx_ref(ref: str) -> str:
|
|
395
392
|
return ref
|
396
393
|
|
397
394
|
|
398
|
-
utf8open = functools.partial(open, encoding=
|
395
|
+
utf8open = functools.partial(open, encoding="UTF-8")
|
399
396
|
"""
|
400
397
|
Explictly specify that the type of file being opened is UTF-8, which is should
|
401
398
|
be for almost everything in SIERRA.
|
402
399
|
"""
|
403
400
|
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
|
412
|
-
|
413
|
-
|
414
|
-
|
415
|
-
|
416
|
-
|
417
|
-
|
418
|
-
|
401
|
+
__all__ = [
|
402
|
+
"ArenaExtent",
|
403
|
+
"Sigmoid",
|
404
|
+
"ReLu",
|
405
|
+
"dir_create_checked",
|
406
|
+
"path_exists",
|
407
|
+
"get_primary_axis",
|
408
|
+
"exp_range_calc",
|
409
|
+
"exp_include_filter",
|
410
|
+
"apply_to_expdef",
|
411
|
+
"pickle_modifications",
|
412
|
+
"exp_template_path",
|
413
|
+
"get_n_agents",
|
414
|
+
"df_fill",
|
415
|
+
"utf8open",
|
419
416
|
]
|