MATE-runtime 1.0.0.dev0__tar.gz → 1.0.0rc1__tar.gz
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.
Potentially problematic release.
This version of MATE-runtime might be problematic. Click here for more details.
- {mate_runtime-1.0.0.dev0 → mate_runtime-1.0.0rc1}/.gitignore +2 -0
- {mate_runtime-1.0.0.dev0 → mate_runtime-1.0.0rc1}/PKG-INFO +14 -4
- {mate_runtime-1.0.0.dev0 → mate_runtime-1.0.0rc1}/README.md +11 -2
- {mate_runtime-1.0.0.dev0 → mate_runtime-1.0.0rc1}/pyproject.toml +2 -2
- mate_runtime-1.0.0rc1/src/MATE/__init__.py +22 -0
- {mate_runtime-1.0.0.dev0 → mate_runtime-1.0.0rc1}/src/MATE/__main__.py +2 -0
- mate_runtime-1.0.0rc1/src/MATE/cli/__init__.py +181 -0
- mate_runtime-1.0.0rc1/src/MATE/cli/commands.py +561 -0
- mate_runtime-1.0.0rc1/src/MATE/cli/workdir.py +571 -0
- mate_runtime-1.0.0rc1/src/MATE/compat/__init__.py +1 -0
- mate_runtime-1.0.0rc1/src/MATE/compat/interface.py +248 -0
- mate_runtime-1.0.0rc1/src/MATE/compat/sizes.py +144 -0
- mate_runtime-1.0.0rc1/src/MATE/config/__init__.py +1 -0
- mate_runtime-1.0.0rc1/src/MATE/config/axes.py +310 -0
- mate_runtime-1.0.0rc1/src/MATE/config/builders.py +498 -0
- mate_runtime-1.0.0rc1/src/MATE/config/calendar.py +371 -0
- mate_runtime-1.0.0rc1/src/MATE/config/canonical.py +543 -0
- mate_runtime-1.0.0rc1/src/MATE/config/criteria.py +396 -0
- mate_runtime-1.0.0rc1/src/MATE/config/events.py +183 -0
- mate_runtime-1.0.0rc1/src/MATE/config/invariance.py +227 -0
- mate_runtime-1.0.0rc1/src/MATE/config/loader.py +498 -0
- mate_runtime-1.0.0rc1/src/MATE/config/model.py +883 -0
- mate_runtime-1.0.0rc1/src/MATE/config/resolve.py +943 -0
- mate_runtime-1.0.0rc1/src/MATE/config/runtable.py +342 -0
- mate_runtime-1.0.0rc1/src/MATE/config/seeds.py +344 -0
- mate_runtime-1.0.0rc1/src/MATE/config/stages.py +632 -0
- mate_runtime-1.0.0rc1/src/MATE/config/structure.py +635 -0
- mate_runtime-1.0.0rc1/src/MATE/config/toml.py +237 -0
- mate_runtime-1.0.0rc1/src/MATE/conformance/__init__.py +14 -0
- mate_runtime-1.0.0rc1/src/MATE/conformance/baseline.py +250 -0
- mate_runtime-1.0.0rc1/src/MATE/conformance/checks.py +1578 -0
- mate_runtime-1.0.0rc1/src/MATE/conformance/sampler.py +179 -0
- mate_runtime-1.0.0rc1/src/MATE/errors.py +236 -0
- mate_runtime-1.0.0rc1/src/MATE/evaluation/__init__.py +1 -0
- mate_runtime-1.0.0rc1/src/MATE/evaluation/budget.py +160 -0
- mate_runtime-1.0.0rc1/src/MATE/evaluation/invalids.py +181 -0
- mate_runtime-1.0.0rc1/src/MATE/evaluation/requests.py +148 -0
- mate_runtime-1.0.0rc1/src/MATE/execution/__init__.py +1 -0
- mate_runtime-1.0.0rc1/src/MATE/execution/base.py +641 -0
- mate_runtime-1.0.0rc1/src/MATE/execution/choose.py +146 -0
- mate_runtime-1.0.0rc1/src/MATE/execution/process.py +377 -0
- mate_runtime-1.0.0rc1/src/MATE/execution/serial.py +37 -0
- mate_runtime-1.0.0rc1/src/MATE/execution/thread.py +106 -0
- mate_runtime-1.0.0rc1/src/MATE/execution/vectorised.py +32 -0
- mate_runtime-1.0.0rc1/src/MATE/launch.py +267 -0
- mate_runtime-1.0.0rc1/src/MATE/loop/__init__.py +6 -0
- mate_runtime-1.0.0rc1/src/MATE/loop/continuous.py +172 -0
- mate_runtime-1.0.0rc1/src/MATE/loop/driver.py +783 -0
- mate_runtime-1.0.0rc1/src/MATE/loop/events.py +266 -0
- mate_runtime-1.0.0rc1/src/MATE/loop/generational.py +140 -0
- mate_runtime-1.0.0rc1/src/MATE/loop/owns_loop.py +333 -0
- mate_runtime-1.0.0rc1/src/MATE/loop/subpops.py +508 -0
- mate_runtime-1.0.0rc1/src/MATE/modules/__init__.py +1 -0
- mate_runtime-1.0.0rc1/src/MATE/modules/construct.py +198 -0
- mate_runtime-1.0.0rc1/src/MATE/modules/discovery.py +204 -0
- mate_runtime-1.0.0rc1/src/MATE/modules/registry.py +334 -0
- mate_runtime-1.0.0rc1/src/MATE/modules/software.py +578 -0
- mate_runtime-1.0.0rc1/src/MATE/modules/versions.py +72 -0
- mate_runtime-1.0.0rc1/src/MATE/numerics.py +159 -0
- mate_runtime-1.0.0rc1/src/MATE/observation/__init__.py +10 -0
- mate_runtime-1.0.0rc1/src/MATE/observation/control.py +199 -0
- mate_runtime-1.0.0rc1/src/MATE/observation/hub.py +451 -0
- mate_runtime-1.0.0rc1/src/MATE/observation/records.py +125 -0
- mate_runtime-1.0.0rc1/src/MATE/observation/sinks.py +313 -0
- mate_runtime-1.0.0rc1/src/MATE/provenance.py +378 -0
- mate_runtime-1.0.0rc1/src/MATE/readout/__init__.py +10 -0
- mate_runtime-1.0.0rc1/src/MATE/readout/catalogue.py +282 -0
- mate_runtime-1.0.0rc1/src/MATE/readout/front.py +151 -0
- mate_runtime-1.0.0rc1/src/MATE/readout/readout.py +927 -0
- mate_runtime-1.0.0rc1/src/MATE/readout/series.py +155 -0
- mate_runtime-1.0.0rc1/src/MATE/readout/statistics.py +202 -0
- mate_runtime-1.0.0rc1/src/MATE/run/__init__.py +1 -0
- mate_runtime-1.0.0rc1/src/MATE/run/checkpointing.py +266 -0
- mate_runtime-1.0.0rc1/src/MATE/run/contexts.py +553 -0
- mate_runtime-1.0.0rc1/src/MATE/run/declarations.py +240 -0
- mate_runtime-1.0.0rc1/src/MATE/run/plan.py +464 -0
- mate_runtime-1.0.0rc1/src/MATE/run/preconditions.py +165 -0
- mate_runtime-1.0.0rc1/src/MATE/run/run.py +980 -0
- mate_runtime-1.0.0rc1/src/MATE/run/specs.py +319 -0
- mate_runtime-1.0.0rc1/src/MATE/run/times.py +103 -0
- mate_runtime-1.0.0rc1/src/MATE/scheduling/__init__.py +214 -0
- mate_runtime-1.0.0rc1/src/MATE/scheduling/local.py +119 -0
- mate_runtime-1.0.0rc1/src/MATE/scheduling/slurm.py +380 -0
- mate_runtime-1.0.0rc1/src/MATE/storage/__init__.py +1 -0
- mate_runtime-1.0.0rc1/src/MATE/storage/checkpoint.py +414 -0
- mate_runtime-1.0.0rc1/src/MATE/storage/codec.py +315 -0
- mate_runtime-1.0.0rc1/src/MATE/storage/database.py +359 -0
- mate_runtime-1.0.0rc1/src/MATE/storage/lease.py +397 -0
- mate_runtime-1.0.0rc1/src/MATE/storage/rundir.py +248 -0
- mate_runtime-1.0.0.dev0/src/MATE/__init__.py +0 -14
- mate_runtime-1.0.0.dev0/src/MATE/cli.py +0 -19
- {mate_runtime-1.0.0.dev0 → mate_runtime-1.0.0rc1}/COPYING +0 -0
- {mate_runtime-1.0.0.dev0 → mate_runtime-1.0.0rc1}/COPYING.LESSER +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: MATE-runtime
|
|
3
|
-
Version: 1.0.
|
|
3
|
+
Version: 1.0.0rc1
|
|
4
4
|
Summary: Runtime of MATE, the Modular Algorithmic Toolkit for Evolution: runs, records and replays artificial evolution experiments
|
|
5
5
|
Project-URL: Homepage, https://gitlab.com/artificial_evolution/mate/mate
|
|
6
6
|
Project-URL: Issues, https://gitlab.com/artificial_evolution/mate/mate/-/issues
|
|
@@ -15,7 +15,8 @@ Classifier: Intended Audience :: Science/Research
|
|
|
15
15
|
Classifier: Programming Language :: Python :: 3
|
|
16
16
|
Classifier: Topic :: Scientific/Engineering
|
|
17
17
|
Requires-Python: >=3.14
|
|
18
|
-
Requires-Dist: mate-contract<2,>=1.0.
|
|
18
|
+
Requires-Dist: mate-contract<2,>=1.0.0rc1
|
|
19
|
+
Requires-Dist: packaging>=24
|
|
19
20
|
Description-Content-Type: text/markdown
|
|
20
21
|
|
|
21
22
|
# MATE-runtime
|
|
@@ -25,8 +26,17 @@ Modular Algorithmic Toolkit for Evolution: the run loop, scheduling, storage
|
|
|
25
26
|
and the command line `MATE`. Its import name is `MATE`, which also re-exports
|
|
26
27
|
the contract types.
|
|
27
28
|
|
|
28
|
-
|
|
29
|
-
|
|
29
|
+
It loads protocols (TOML files or their Python form), runs them with the
|
|
30
|
+
`serial`, `thread`, `process` or `vectorised` executor, locally or on Slurm,
|
|
31
|
+
records every run in a SQLite database with its provenance, and resumes and
|
|
32
|
+
branches runs from their checkpoints. `MATE check` runs the conformance suite
|
|
33
|
+
on a module.
|
|
34
|
+
|
|
35
|
+
```
|
|
36
|
+
MATE launch protocol.toml
|
|
37
|
+
MATE status Files/protocol
|
|
38
|
+
MATE show Files/protocol/run_000
|
|
39
|
+
```
|
|
30
40
|
|
|
31
41
|
## Installation
|
|
32
42
|
|
|
@@ -5,8 +5,17 @@ Modular Algorithmic Toolkit for Evolution: the run loop, scheduling, storage
|
|
|
5
5
|
and the command line `MATE`. Its import name is `MATE`, which also re-exports
|
|
6
6
|
the contract types.
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
It loads protocols (TOML files or their Python form), runs them with the
|
|
9
|
+
`serial`, `thread`, `process` or `vectorised` executor, locally or on Slurm,
|
|
10
|
+
records every run in a SQLite database with its provenance, and resumes and
|
|
11
|
+
branches runs from their checkpoints. `MATE check` runs the conformance suite
|
|
12
|
+
on a module.
|
|
13
|
+
|
|
14
|
+
```
|
|
15
|
+
MATE launch protocol.toml
|
|
16
|
+
MATE status Files/protocol
|
|
17
|
+
MATE show Files/protocol/run_000
|
|
18
|
+
```
|
|
10
19
|
|
|
11
20
|
## Installation
|
|
12
21
|
|
|
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "MATE-runtime"
|
|
7
|
-
version = "1.0.
|
|
7
|
+
version = "1.0.0rc1"
|
|
8
8
|
description = "Runtime of MATE, the Modular Algorithmic Toolkit for Evolution: runs, records and replays artificial evolution experiments"
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
requires-python = ">=3.14"
|
|
@@ -21,7 +21,7 @@ classifiers = [
|
|
|
21
21
|
"Programming Language :: Python :: 3",
|
|
22
22
|
"Topic :: Scientific/Engineering",
|
|
23
23
|
]
|
|
24
|
-
dependencies = ["MATE-contract>=1.0.
|
|
24
|
+
dependencies = ["MATE-contract>=1.0.0rc1,<2", "packaging>=24"]
|
|
25
25
|
|
|
26
26
|
[project.scripts]
|
|
27
27
|
MATE = "MATE.cli:main"
|
|
@@ -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"]
|
|
@@ -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 a module")
|
|
134
|
+
p.add_argument("name")
|
|
135
|
+
p.add_argument("--index", help="a private package index")
|
|
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
|