MATE-runtime 1.0.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.
- MATE/__init__.py +22 -0
- MATE/__main__.py +7 -0
- MATE/cli/__init__.py +181 -0
- MATE/cli/commands.py +573 -0
- MATE/cli/workdir.py +571 -0
- MATE/compat/__init__.py +1 -0
- MATE/compat/interface.py +248 -0
- MATE/compat/sizes.py +144 -0
- MATE/config/__init__.py +1 -0
- MATE/config/axes.py +310 -0
- MATE/config/builders.py +498 -0
- MATE/config/calendar.py +371 -0
- MATE/config/canonical.py +543 -0
- MATE/config/criteria.py +396 -0
- MATE/config/events.py +183 -0
- MATE/config/invariance.py +227 -0
- MATE/config/loader.py +498 -0
- MATE/config/model.py +883 -0
- MATE/config/resolve.py +943 -0
- MATE/config/runtable.py +342 -0
- MATE/config/seeds.py +344 -0
- MATE/config/stages.py +632 -0
- MATE/config/structure.py +635 -0
- MATE/config/toml.py +237 -0
- MATE/conformance/__init__.py +14 -0
- MATE/conformance/baseline.py +250 -0
- MATE/conformance/checks.py +1604 -0
- MATE/conformance/sampler.py +179 -0
- MATE/errors.py +236 -0
- MATE/evaluation/__init__.py +1 -0
- MATE/evaluation/budget.py +160 -0
- MATE/evaluation/invalids.py +181 -0
- MATE/evaluation/requests.py +148 -0
- MATE/execution/__init__.py +1 -0
- MATE/execution/accelerator.py +60 -0
- MATE/execution/base.py +643 -0
- MATE/execution/choose.py +152 -0
- MATE/execution/devices.py +108 -0
- MATE/execution/process.py +377 -0
- MATE/execution/serial.py +37 -0
- MATE/execution/thread.py +106 -0
- MATE/execution/vectorised.py +32 -0
- MATE/launch.py +267 -0
- MATE/loop/__init__.py +6 -0
- MATE/loop/continuous.py +172 -0
- MATE/loop/driver.py +783 -0
- MATE/loop/events.py +266 -0
- MATE/loop/generational.py +140 -0
- MATE/loop/owns_loop.py +333 -0
- MATE/loop/subpops.py +508 -0
- MATE/modules/__init__.py +1 -0
- MATE/modules/construct.py +198 -0
- MATE/modules/discovery.py +238 -0
- MATE/modules/registry.py +970 -0
- MATE/modules/software.py +593 -0
- MATE/modules/versions.py +72 -0
- MATE/numerics.py +159 -0
- MATE/observation/__init__.py +10 -0
- MATE/observation/control.py +199 -0
- MATE/observation/hub.py +451 -0
- MATE/observation/records.py +125 -0
- MATE/observation/sinks.py +313 -0
- MATE/provenance.py +396 -0
- MATE/readout/__init__.py +10 -0
- MATE/readout/catalogue.py +282 -0
- MATE/readout/front.py +151 -0
- MATE/readout/readout.py +927 -0
- MATE/readout/series.py +155 -0
- MATE/readout/statistics.py +202 -0
- MATE/run/__init__.py +1 -0
- MATE/run/checkpointing.py +266 -0
- MATE/run/contexts.py +553 -0
- MATE/run/declarations.py +240 -0
- MATE/run/plan.py +464 -0
- MATE/run/preconditions.py +165 -0
- MATE/run/run.py +991 -0
- MATE/run/specs.py +319 -0
- MATE/run/times.py +103 -0
- MATE/scheduling/__init__.py +214 -0
- MATE/scheduling/local.py +119 -0
- MATE/scheduling/slurm.py +380 -0
- MATE/storage/__init__.py +1 -0
- MATE/storage/checkpoint.py +414 -0
- MATE/storage/codec.py +315 -0
- MATE/storage/database.py +359 -0
- MATE/storage/lease.py +397 -0
- MATE/storage/rundir.py +248 -0
- mate_runtime-1.0.0.dist-info/METADATA +58 -0
- mate_runtime-1.0.0.dist-info/RECORD +93 -0
- mate_runtime-1.0.0.dist-info/WHEEL +4 -0
- mate_runtime-1.0.0.dist-info/entry_points.txt +2 -0
- mate_runtime-1.0.0.dist-info/licenses/COPYING +674 -0
- mate_runtime-1.0.0.dist-info/licenses/COPYING.LESSER +165 -0
MATE/__init__.py
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"""MATE runtime: runs, records and replays artificial evolution experiments.
|
|
2
|
+
|
|
3
|
+
``import MATE`` re-exports the contract types, so that users need not tell ``MATE`` and
|
|
4
|
+
``MATE_contract`` apart, and adds the Python form of a protocol (design §2.4). Every other
|
|
5
|
+
runtime name is imported from its module (``MATE.conformance``, ``MATE.observation.records``,
|
|
6
|
+
...).
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
import importlib.metadata
|
|
10
|
+
|
|
11
|
+
from MATE_contract import * # noqa: F403
|
|
12
|
+
from MATE_contract import __all__ as _contract_names
|
|
13
|
+
|
|
14
|
+
from MATE.config.builders import Protocol, loops, method, protocol, replicates, sample, stop, system
|
|
15
|
+
from MATE.errors import ProtocolRefused
|
|
16
|
+
from MATE.run.plan import LaunchResult
|
|
17
|
+
from MATE.run.run import Run
|
|
18
|
+
|
|
19
|
+
__version__ = importlib.metadata.version("MATE-runtime")
|
|
20
|
+
|
|
21
|
+
__all__ = [*_contract_names, "protocol", "method", "system", "loops", "stop", "replicates",
|
|
22
|
+
"sample", "Protocol", "ProtocolRefused", "Run", "LaunchResult"]
|
MATE/__main__.py
ADDED
MATE/cli/__init__.py
ADDED
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
"""The ``MATE`` command line ([X] §24, [C] §21, design §3.14).
|
|
2
|
+
|
|
3
|
+
:func:`main` parses the arguments and dispatches to :mod:`MATE.cli.commands`. Exit status:
|
|
4
|
+
0 success, 1 refusal (software, interface, preconditions, deferred feature), 2 run
|
|
5
|
+
failures, 3 usage error.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
import argparse
|
|
9
|
+
import sys
|
|
10
|
+
from importlib.metadata import version
|
|
11
|
+
from typing import NoReturn
|
|
12
|
+
|
|
13
|
+
from MATE.cli import commands
|
|
14
|
+
|
|
15
|
+
__all__ = ["main", "build_parser"]
|
|
16
|
+
|
|
17
|
+
_USAGE = 3
|
|
18
|
+
_EXECUTORS = ("serial", "thread", "process", "vectorised", "accelerator")
|
|
19
|
+
_VERBOSITIES = ("quiet", "normal", "verbose", "debug")
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
class _Usage(Exception):
|
|
23
|
+
"""An argument error, reported with exit status 3."""
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
class _Parser(argparse.ArgumentParser):
|
|
27
|
+
"""An argument parser whose errors give exit status 3 instead of exiting with 2."""
|
|
28
|
+
|
|
29
|
+
def error(self, message: str) -> NoReturn:
|
|
30
|
+
self.print_usage(sys.stderr)
|
|
31
|
+
raise _Usage(f"{self.prog}: error: {message}")
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
def _execution(p: argparse.ArgumentParser, *, retention: bool = False) -> None:
|
|
35
|
+
"""The ``[execution]`` overrides ([C] R21.1)."""
|
|
36
|
+
p.add_argument("--workers", type=int, help="number of workers")
|
|
37
|
+
p.add_argument("--executor", choices=_EXECUTORS, help="executor")
|
|
38
|
+
p.add_argument("--scheduler", choices=("slurm",), help="submit to a Slurm cluster")
|
|
39
|
+
p.add_argument("--verbosity", choices=_VERBOSITIES, help="terminal verbosity")
|
|
40
|
+
p.add_argument("--workdir", help="working directory of the runs")
|
|
41
|
+
p.add_argument("--sinks", help="comma-separated sink names, replacing [execution] sinks")
|
|
42
|
+
p.add_argument("--debug", action="store_true", help="debug mode: fail at the first error")
|
|
43
|
+
p.add_argument("--dry-run", action="store_true",
|
|
44
|
+
help="prepare the workdir (and Slurm scripts) and run nothing")
|
|
45
|
+
if retention:
|
|
46
|
+
p.add_argument("--retention", choices=("minimal", "lineage", "full"))
|
|
47
|
+
p.add_argument("--checkpoint-every", type=int, dest="checkpoint_every")
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
def build_parser() -> argparse.ArgumentParser:
|
|
51
|
+
"""Build the argument parser of the ``MATE`` command.
|
|
52
|
+
|
|
53
|
+
Returns
|
|
54
|
+
-------
|
|
55
|
+
argparse.ArgumentParser
|
|
56
|
+
One sub-command per command of [X] §24 and design §3.14; ``exec-run`` is hidden.
|
|
57
|
+
"""
|
|
58
|
+
parser = _Parser(
|
|
59
|
+
prog="MATE",
|
|
60
|
+
description="MATE, the Modular Algorithmic Toolkit for Evolution.",
|
|
61
|
+
)
|
|
62
|
+
parser.add_argument(
|
|
63
|
+
"--version",
|
|
64
|
+
action="version",
|
|
65
|
+
version=f"MATE-runtime {version('MATE-runtime')} (MATE-contract {version('MATE-contract')})",
|
|
66
|
+
)
|
|
67
|
+
sub = parser.add_subparsers(dest="command", metavar="<command>", parser_class=_Parser)
|
|
68
|
+
|
|
69
|
+
p = sub.add_parser("launch", help="launch a protocol")
|
|
70
|
+
p.add_argument("protocol", help="the protocol file")
|
|
71
|
+
_execution(p)
|
|
72
|
+
p.add_argument("--sweep", action="append", metavar="PATH=V1,V2",
|
|
73
|
+
help="add an axis (repeatable)")
|
|
74
|
+
p.add_argument("--dashboard", action="store_true", help=argparse.SUPPRESS)
|
|
75
|
+
p.set_defaults(func=commands.cmd_launch)
|
|
76
|
+
|
|
77
|
+
for name, text, func in (("status", "progress and missing runs", commands.cmd_status),
|
|
78
|
+
("verify", "check the held invariants", commands.cmd_verify),
|
|
79
|
+
("runs", "blueprints -> runs, for analysis", commands.cmd_runs)):
|
|
80
|
+
p = sub.add_parser(name, help=text)
|
|
81
|
+
p.add_argument("workdir")
|
|
82
|
+
p.add_argument("--protocol", help="the protocol aggregated (several in the workdir)")
|
|
83
|
+
p.set_defaults(func=func)
|
|
84
|
+
|
|
85
|
+
p = sub.add_parser("diff", help="what differs between two blueprints")
|
|
86
|
+
p.add_argument("a", help="a run directory or a workdir")
|
|
87
|
+
p.add_argument("b", help="a run directory or a workdir")
|
|
88
|
+
p.set_defaults(func=commands.cmd_diff)
|
|
89
|
+
|
|
90
|
+
p = sub.add_parser("show", help="summary, series, best individual")
|
|
91
|
+
p.add_argument("path", help="a run directory or a workdir")
|
|
92
|
+
p.add_argument("--objective", help="objective of the best individual (K >= 2)")
|
|
93
|
+
p.add_argument("--subpop", help="subpopulation shown (several subpopulations)")
|
|
94
|
+
p.set_defaults(func=commands.cmd_show)
|
|
95
|
+
|
|
96
|
+
p = sub.add_parser("branch", help="branch from a recorded run")
|
|
97
|
+
p.add_argument("target", metavar="RUN@GENERATION")
|
|
98
|
+
p.add_argument("--count", type=int, required=True, help="number of replicates")
|
|
99
|
+
p.add_argument("--root-seed", required=True, dest="root_seed",
|
|
100
|
+
help="root seed (an integer or 'fresh')")
|
|
101
|
+
_execution(p, retention=True)
|
|
102
|
+
p.set_defaults(func=commands.cmd_branch)
|
|
103
|
+
|
|
104
|
+
p = sub.add_parser("control", help="control a running run")
|
|
105
|
+
p.add_argument("run", help="the run directory")
|
|
106
|
+
p.add_argument("command_name", metavar="command",
|
|
107
|
+
choices=("stop", "suspend", "resume", "checkpoint", "verbosity"))
|
|
108
|
+
p.add_argument("value", nargs="?", help="the verbosity, for 'verbosity'")
|
|
109
|
+
p.set_defaults(func=commands.cmd_control)
|
|
110
|
+
|
|
111
|
+
p = sub.add_parser("list", help="installed modules and their status")
|
|
112
|
+
p.set_defaults(func=commands.cmd_list)
|
|
113
|
+
|
|
114
|
+
p = sub.add_parser("matrix", help="compatibility table of methods x systems")
|
|
115
|
+
p.add_argument("--smoke", action="store_true", help="two real generations per pair")
|
|
116
|
+
p.set_defaults(func=commands.cmd_matrix)
|
|
117
|
+
|
|
118
|
+
p = sub.add_parser("check", help="conformance suite of a module")
|
|
119
|
+
p.add_argument("module")
|
|
120
|
+
p.add_argument("--kind", choices=("method", "system"),
|
|
121
|
+
help="the module's kind, when a method and a system share its name")
|
|
122
|
+
p.add_argument("--system", help="system a method is checked against")
|
|
123
|
+
p.add_argument("--method", help="method a system's resume test runs with")
|
|
124
|
+
p.add_argument("--set", action="append", metavar="KEY=VALUE",
|
|
125
|
+
help="a setting of the module (repeatable)")
|
|
126
|
+
p.add_argument("--tolerance", type=float, default=0.0)
|
|
127
|
+
p.set_defaults(func=commands.cmd_check)
|
|
128
|
+
|
|
129
|
+
p = sub.add_parser("search", help="search the module registry")
|
|
130
|
+
p.add_argument("text")
|
|
131
|
+
p.set_defaults(func=commands.cmd_search)
|
|
132
|
+
|
|
133
|
+
p = sub.add_parser("install", help="install modules from the registry")
|
|
134
|
+
p.add_argument("names", nargs="+", metavar="name",
|
|
135
|
+
help="a registered name, optionally name==version, or a git+ URL")
|
|
136
|
+
p.set_defaults(func=commands.cmd_install)
|
|
137
|
+
|
|
138
|
+
p = sub.add_parser("replay", help="visual replay (not available in MATE 1.0.0)")
|
|
139
|
+
p.add_argument("args", nargs=argparse.REMAINDER)
|
|
140
|
+
p.set_defaults(func=commands.cmd_replay)
|
|
141
|
+
|
|
142
|
+
p = sub.add_parser("dashboard", help="terminal dashboard (not available in MATE 1.0.0)")
|
|
143
|
+
p.add_argument("args", nargs=argparse.REMAINDER)
|
|
144
|
+
p.set_defaults(func=commands.cmd_dashboard)
|
|
145
|
+
|
|
146
|
+
p = sub.add_parser("exec-run") # hidden: no help, not listed ([X] SC4)
|
|
147
|
+
p.add_argument("directory")
|
|
148
|
+
p.add_argument("--debug", action="store_true")
|
|
149
|
+
p.set_defaults(func=commands.cmd_exec_run)
|
|
150
|
+
return parser
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+
def main(argv: list[str] | None = None) -> int:
|
|
154
|
+
"""Run the ``MATE`` command line.
|
|
155
|
+
|
|
156
|
+
Parameters
|
|
157
|
+
----------
|
|
158
|
+
argv : list of str, optional
|
|
159
|
+
The arguments; default ``sys.argv[1:]``.
|
|
160
|
+
|
|
161
|
+
Returns
|
|
162
|
+
-------
|
|
163
|
+
int
|
|
164
|
+
The exit status: 0 success, 1 refusal, 2 run failures, 3 usage error.
|
|
165
|
+
"""
|
|
166
|
+
parser = build_parser()
|
|
167
|
+
try:
|
|
168
|
+
args = parser.parse_args(argv)
|
|
169
|
+
except _Usage as exc:
|
|
170
|
+
print(exc, file=sys.stderr)
|
|
171
|
+
return _USAGE
|
|
172
|
+
except SystemExit as exc: # --version, --help
|
|
173
|
+
return exc.code if isinstance(exc.code, int) else 0
|
|
174
|
+
if args.command is None:
|
|
175
|
+
parser.print_help()
|
|
176
|
+
return 0
|
|
177
|
+
try:
|
|
178
|
+
return args.func(args)
|
|
179
|
+
except commands.UsageError as exc:
|
|
180
|
+
print(f"MATE {args.command}: error: {exc}", file=sys.stderr)
|
|
181
|
+
return _USAGE
|