restage 0.8.0__py3-none-any.whl → 0.8.2__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.
- restage/splitrun.py +51 -13
- {restage-0.8.0.dist-info → restage-0.8.2.dist-info}/METADATA +2 -2
- {restage-0.8.0.dist-info → restage-0.8.2.dist-info}/RECORD +6 -6
- {restage-0.8.0.dist-info → restage-0.8.2.dist-info}/WHEEL +0 -0
- {restage-0.8.0.dist-info → restage-0.8.2.dist-info}/entry_points.txt +0 -0
- {restage-0.8.0.dist-info → restage-0.8.2.dist-info}/top_level.txt +0 -0
restage/splitrun.py
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
|
|
3
3
|
from pathlib import Path
|
|
4
|
+
from typing import Optional
|
|
5
|
+
|
|
4
6
|
from .tables import SimulationEntry, InstrEntry
|
|
5
7
|
|
|
6
8
|
def mcpl_parameters_split(s: str) -> list[tuple[str, str]]:
|
|
@@ -13,6 +15,8 @@ def si_int(s: str) -> int:
|
|
|
13
15
|
'Ki': 2 ** 10, 'Mi': 2 ** 20, 'Gi': 2 ** 30, 'Ti': 2 ** 40, 'Pi': 2 ** 50
|
|
14
16
|
}
|
|
15
17
|
def int_mult(x: str, mult: int = 1):
|
|
18
|
+
if len(x) == 0 and mult > 1:
|
|
19
|
+
return mult
|
|
16
20
|
return int(x) * mult if x.isnumeric() else int(float(x) * mult)
|
|
17
21
|
|
|
18
22
|
def do_parse():
|
|
@@ -24,7 +28,7 @@ def si_int(s: str) -> int:
|
|
|
24
28
|
return int_mult(s)
|
|
25
29
|
value = do_parse()
|
|
26
30
|
if value < 0:
|
|
27
|
-
|
|
31
|
+
raise ValueError(f'Negative {value=} encountered')
|
|
28
32
|
elif value > 2**53:
|
|
29
33
|
logger.info(
|
|
30
34
|
'McStas/McXtrace parse integer inputs as doubles,'
|
|
@@ -33,6 +37,17 @@ def si_int(s: str) -> int:
|
|
|
33
37
|
)
|
|
34
38
|
return value
|
|
35
39
|
|
|
40
|
+
def si_int_limits(s: str) -> tuple[Optional[int], int, Optional[int]]:
|
|
41
|
+
low, high = None, None
|
|
42
|
+
min_seps, max_seps = (']', '-', '}'), ('[', '+', '{')
|
|
43
|
+
if any(x in s for x in min_seps):
|
|
44
|
+
low, s = s.split(next(x for x in min_seps if x in s), maxsplit=1)
|
|
45
|
+
low = si_int(low)
|
|
46
|
+
if any(x in s for x in max_seps):
|
|
47
|
+
s, high = s.split(next(x for x in max_seps if x in s), maxsplit=1)
|
|
48
|
+
high = si_int(high)
|
|
49
|
+
return low, si_int(s), high
|
|
50
|
+
|
|
36
51
|
def make_splitrun_parser():
|
|
37
52
|
from argparse import ArgumentParser
|
|
38
53
|
parser = ArgumentParser('splitrun')
|
|
@@ -40,7 +55,8 @@ def make_splitrun_parser():
|
|
|
40
55
|
aa('instrument', type=str, default=None,
|
|
41
56
|
help='Instrument `.instr` file name or serialised HDF5 or JSON Instr object')
|
|
42
57
|
aa('parameters', nargs='*', type=str, default=None)
|
|
43
|
-
aa('-n', '--ncount', type=
|
|
58
|
+
aa('-n', '--ncount', type=si_int_limits, default=None, metavar='[MIN-]COUNT[+MAX]',
|
|
59
|
+
help='COUNT {number}[kMGTP] target, MIN MAX replace missing --nmin --nmax')
|
|
44
60
|
aa('-m', '--mesh', action='store_true', default=False, help='N-dimensional mesh scan')
|
|
45
61
|
aa('-d', '--dir', type=str, default=None, help='Output directory')
|
|
46
62
|
aa('-s', '--seed', type=int, default=None, help='Random number generator seed')
|
|
@@ -49,16 +65,16 @@ def make_splitrun_parser():
|
|
|
49
65
|
help='Enable gravitation for all trajectories')
|
|
50
66
|
aa('--bufsiz', type=si_int, default=None, help='Monitor_nD list/buffer-size')
|
|
51
67
|
aa('--format', type=str, default=None, help='Output data files using FORMAT')
|
|
52
|
-
aa('--nmin', type=
|
|
53
|
-
help='
|
|
54
|
-
aa('--nmax', type=
|
|
55
|
-
help='
|
|
68
|
+
aa('--nmin', type=si_int, default=None, metavar='MIN',
|
|
69
|
+
help='MIN {number}[kMGTP] rays per first-instrument simulation')
|
|
70
|
+
aa('--nmax', type=si_int, default=None, metavar='MAX',
|
|
71
|
+
help='MAX {number}[kMGTP] rays per first-instrument simulation')
|
|
56
72
|
aa('--dryrun', action='store_true', default=False,
|
|
57
73
|
help='Do not run any simulations, just print the commands')
|
|
58
74
|
aa('--parallel', action='store_true', default=False,
|
|
59
|
-
help='Use MPI multi-process parallelism
|
|
75
|
+
help='Use MPI multi-process parallelism')
|
|
60
76
|
aa('--gpu', action='store_true', default=False,
|
|
61
|
-
help='Use GPU OpenACC parallelism
|
|
77
|
+
help='Use GPU OpenACC parallelism')
|
|
62
78
|
aa('--process-count', type=int, default=0,
|
|
63
79
|
help='MPI process count, 0 == System Default')
|
|
64
80
|
# splitrun controlling parameters
|
|
@@ -119,6 +135,31 @@ def parse_splitrun_precision(unparsed: list[str]) -> dict[str, float]:
|
|
|
119
135
|
precision[k] = float(v)
|
|
120
136
|
return precision
|
|
121
137
|
|
|
138
|
+
def args_fixup(args):
|
|
139
|
+
"""Ensure that arguments match expectations
|
|
140
|
+
|
|
141
|
+
- MCPL input and output instance parameters should be dictionaries if present.
|
|
142
|
+
- NCOUNT needs to be separated into (MIN, COUNT, MAX) values, with multiple
|
|
143
|
+
specifications of either MIN or MAX checked for consistency
|
|
144
|
+
"""
|
|
145
|
+
if args.mcpl_input_parameters is not None:
|
|
146
|
+
args.mcpl_input_parameters = dict(args.mcpl_input_parameters)
|
|
147
|
+
if args.mcpl_output_parameters is not None:
|
|
148
|
+
args.mcpl_output_parameters = dict(args.mcpl_output_parameters)
|
|
149
|
+
|
|
150
|
+
if args.ncount is not None:
|
|
151
|
+
nmin, ncount, nmax = args.ncount
|
|
152
|
+
if args.nmin and nmin and args.nmin != nmin:
|
|
153
|
+
raise ValueError(f'Invalid repeated nmin specification: {nmin} != {args.nmin}')
|
|
154
|
+
if args.nmax and nmax and args.nmax != nmax:
|
|
155
|
+
raise ValueError(f'Invalid repeated nmax specification: {nmax} != {args.nmax}')
|
|
156
|
+
if nmin and not args.nmin:
|
|
157
|
+
args.nmin = nmin
|
|
158
|
+
if nmax and not args.nmax:
|
|
159
|
+
args.nmax = nmax
|
|
160
|
+
args.ncount = ncount
|
|
161
|
+
|
|
162
|
+
return args
|
|
122
163
|
|
|
123
164
|
def parse_splitrun(parser):
|
|
124
165
|
from .range import parse_scan_parameters
|
|
@@ -126,11 +167,8 @@ def parse_splitrun(parser):
|
|
|
126
167
|
import sys
|
|
127
168
|
sys.argv[1:] = sort_args(sys.argv[1:])
|
|
128
169
|
|
|
129
|
-
args = parser.parse_args()
|
|
130
|
-
|
|
131
|
-
args.mcpl_input_parameters = dict(args.mcpl_input_parameters)
|
|
132
|
-
if args.mcpl_output_parameters is not None:
|
|
133
|
-
args.mcpl_output_parameters = dict(args.mcpl_output_parameters)
|
|
170
|
+
args = args_fixup(parser.parse_args())
|
|
171
|
+
|
|
134
172
|
parameters = parse_scan_parameters(args.parameters)
|
|
135
173
|
precision = parse_splitrun_precision(args.P)
|
|
136
174
|
return args, parameters, precision
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: restage
|
|
3
|
-
Version: 0.8.
|
|
3
|
+
Version: 0.8.2
|
|
4
4
|
Author-email: Gregory Tucker <gregory.tucker@ess.eu>
|
|
5
5
|
License: BSD-3-Clause
|
|
6
6
|
Classifier: License :: OSI Approved :: BSD License
|
|
@@ -17,7 +17,7 @@ Requires-Dist: zenlog>=1.1
|
|
|
17
17
|
Requires-Dist: platformdirs>=3.11
|
|
18
18
|
Requires-Dist: confuse
|
|
19
19
|
Requires-Dist: psutil>=5.9.6
|
|
20
|
-
Requires-Dist: mccode-antlr[hdf5]>=0.15.
|
|
20
|
+
Requires-Dist: mccode-antlr[hdf5]>=0.15.1
|
|
21
21
|
Provides-Extra: test
|
|
22
22
|
Requires-Dist: pytest; extra == "test"
|
|
23
23
|
Requires-Dist: chopcal; extra == "test"
|
|
@@ -10,12 +10,12 @@ restage/mcpl.py,sha256=u7ixerJs4lqKSW2MYndZ2Xpsk8O0S-ZVo735YIy86gc,3223
|
|
|
10
10
|
restage/range.py,sha256=TjOf4DSKfgoAIcrWQvv6MrtksQpnGJHdsEjVI5K-UfI,8116
|
|
11
11
|
restage/run.py,sha256=bTcQIN9edKMXU_eFdX3E_mtJjwemoARrIUmZqzEGf0E,1475
|
|
12
12
|
restage/scan.py,sha256=Yx8OQSBG6I2_64sW0LIDb0glVKwWoxUQQznASXgDZFQ,1432
|
|
13
|
-
restage/splitrun.py,sha256=
|
|
13
|
+
restage/splitrun.py,sha256=5mTSkw-Mm0yq6GAq6oG0NNU7ajVkp_hvLvdcx_HlCj0,27793
|
|
14
14
|
restage/tables.py,sha256=vQf0GkM7ojQbWee_P_Xqfx0-lXLym7x6kyam8CWpB5s,16373
|
|
15
15
|
restage/config/__init__.py,sha256=zFRT9QXgpUJpBncELCQ6by1-kjYp8Li1yJDfqxkHxAA,965
|
|
16
16
|
restage/config/default.yaml,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
17
|
-
restage-0.8.
|
|
18
|
-
restage-0.8.
|
|
19
|
-
restage-0.8.
|
|
20
|
-
restage-0.8.
|
|
21
|
-
restage-0.8.
|
|
17
|
+
restage-0.8.2.dist-info/METADATA,sha256=nCWaQAwVks6yvGipmOu5L8eNSq9jGnP07G9G74oCSf4,7434
|
|
18
|
+
restage-0.8.2.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
19
|
+
restage-0.8.2.dist-info/entry_points.txt,sha256=vYNOPxJ4PzG-1GGFSd08jFxhrtKUWAdWzjJQeFBzFJE,116
|
|
20
|
+
restage-0.8.2.dist-info/top_level.txt,sha256=iM_pb-taTZ0S2WMoDnt_qDMZoNMjmM19z3tTCuVm1IE,8
|
|
21
|
+
restage-0.8.2.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|