restage 0.8.0__tar.gz → 0.8.1__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.
- {restage-0.8.0/src/restage.egg-info → restage-0.8.1}/PKG-INFO +1 -1
- {restage-0.8.0 → restage-0.8.1}/src/restage/splitrun.py +37 -8
- {restage-0.8.0 → restage-0.8.1/src/restage.egg-info}/PKG-INFO +1 -1
- {restage-0.8.0 → restage-0.8.1}/test/test_single.py +33 -5
- {restage-0.8.0 → restage-0.8.1}/.github/workflows/pip.yml +0 -0
- {restage-0.8.0 → restage-0.8.1}/.github/workflows/wheels.yml +0 -0
- {restage-0.8.0 → restage-0.8.1}/.gitignore +0 -0
- {restage-0.8.0 → restage-0.8.1}/README.md +0 -0
- {restage-0.8.0 → restage-0.8.1}/pyproject.toml +0 -0
- {restage-0.8.0 → restage-0.8.1}/setup.cfg +0 -0
- {restage-0.8.0 → restage-0.8.1}/src/restage/__init__.py +0 -0
- {restage-0.8.0 → restage-0.8.1}/src/restage/bifrost_choppers.py +0 -0
- {restage-0.8.0 → restage-0.8.1}/src/restage/cache.py +0 -0
- {restage-0.8.0 → restage-0.8.1}/src/restage/config/__init__.py +0 -0
- {restage-0.8.0 → restage-0.8.1}/src/restage/config/default.yaml +0 -0
- {restage-0.8.0 → restage-0.8.1}/src/restage/cspec_choppers.py +0 -0
- {restage-0.8.0 → restage-0.8.1}/src/restage/database.py +0 -0
- {restage-0.8.0 → restage-0.8.1}/src/restage/emulate.py +0 -0
- {restage-0.8.0 → restage-0.8.1}/src/restage/energy.py +0 -0
- {restage-0.8.0 → restage-0.8.1}/src/restage/instr.py +0 -0
- {restage-0.8.0 → restage-0.8.1}/src/restage/mcpl.py +0 -0
- {restage-0.8.0 → restage-0.8.1}/src/restage/range.py +0 -0
- {restage-0.8.0 → restage-0.8.1}/src/restage/run.py +0 -0
- {restage-0.8.0 → restage-0.8.1}/src/restage/scan.py +0 -0
- {restage-0.8.0 → restage-0.8.1}/src/restage/tables.py +0 -0
- {restage-0.8.0 → restage-0.8.1}/src/restage.egg-info/SOURCES.txt +0 -0
- {restage-0.8.0 → restage-0.8.1}/src/restage.egg-info/dependency_links.txt +0 -0
- {restage-0.8.0 → restage-0.8.1}/src/restage.egg-info/entry_points.txt +0 -0
- {restage-0.8.0 → restage-0.8.1}/src/restage.egg-info/requires.txt +0 -0
- {restage-0.8.0 → restage-0.8.1}/src/restage.egg-info/top_level.txt +0 -0
- {restage-0.8.0 → restage-0.8.1}/test/test_cache.py +0 -0
- {restage-0.8.0 → restage-0.8.1}/test/test_cache_ro.py +0 -0
- {restage-0.8.0 → restage-0.8.1}/test/test_database.py +0 -0
- {restage-0.8.0 → restage-0.8.1}/test/test_energy.py +0 -0
- {restage-0.8.0 → restage-0.8.1}/test/test_env_vars.py +0 -0
- {restage-0.8.0 → restage-0.8.1}/test/test_range.py +0 -0
- {restage-0.8.0 → restage-0.8.1}/test/test_scan.py +0 -0
|
@@ -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
|
|
@@ -131,6 +147,19 @@ def parse_splitrun(parser):
|
|
|
131
147
|
args.mcpl_input_parameters = dict(args.mcpl_input_parameters)
|
|
132
148
|
if args.mcpl_output_parameters is not None:
|
|
133
149
|
args.mcpl_output_parameters = dict(args.mcpl_output_parameters)
|
|
150
|
+
|
|
151
|
+
if args.ncount is not None:
|
|
152
|
+
nmin, ncount, nmax = args.ncount
|
|
153
|
+
if args.nmin and nmin and args.nmin != nmin:
|
|
154
|
+
raise ValueError(f'Invalid repeated nmin specification: {nmin} != {args.nmin}')
|
|
155
|
+
if args.nmax and nmax and args.nmax != nmax:
|
|
156
|
+
raise ValueError(f'Invalid repeated nmax specification: {nmax} != {args.nmax}')
|
|
157
|
+
if nmin and not args.nmin:
|
|
158
|
+
args.nmin = nmin
|
|
159
|
+
if nmax and not args.nmax:
|
|
160
|
+
args.nmax = nmax
|
|
161
|
+
args.ncount = ncount
|
|
162
|
+
|
|
134
163
|
parameters = parse_scan_parameters(args.parameters)
|
|
135
164
|
precision = parse_splitrun_precision(args.P)
|
|
136
165
|
return args, parameters, precision
|
|
@@ -45,17 +45,28 @@ class SingleTestCase(unittest.TestCase):
|
|
|
45
45
|
self.assertEqual(args.split_at, 'here')
|
|
46
46
|
self.assertTrue(args.mesh)
|
|
47
47
|
|
|
48
|
+
def test_negative_count_throws(self):
|
|
49
|
+
from restage.splitrun import si_int, si_int_limits
|
|
50
|
+
with self.assertRaises(ValueError):
|
|
51
|
+
si_int('-10')
|
|
52
|
+
with self.assertRaises(ValueError):
|
|
53
|
+
si_int_limits('10--4+10') # '10--4+10' -> ('10', '-4+10') -> (10, '-4', '10')
|
|
54
|
+
with self.assertRaises(ValueError):
|
|
55
|
+
# This is probably a parsing error, but would raise a negative error
|
|
56
|
+
# in si_int, so is fine. '-10]-2[-1' -> ('','10]-2[-1') -> Error on int('')
|
|
57
|
+
si_int_limits('-10]-2[-1')
|
|
58
|
+
|
|
48
59
|
def test_mccode_flags(self):
|
|
49
|
-
args = self.parser.parse_args(['test.instr', '-s', '123456', '-n', '
|
|
60
|
+
args = self.parser.parse_args(['test.instr', '-s', '123456', '-n', '1', '-d', '/a/dir', '-t', '-g'])
|
|
50
61
|
self.assertEqual(args.seed, 123456)
|
|
51
|
-
self.assertEqual(args.ncount,
|
|
62
|
+
self.assertEqual(args.ncount, (None, 1, None))
|
|
52
63
|
self.assertEqual(args.dir, '/a/dir')
|
|
53
64
|
self.assertEqual(args.trace, True)
|
|
54
65
|
self.assertEqual(args.gravitation, True)
|
|
55
66
|
|
|
56
67
|
args = self.parser.parse_args(['test.instr', '-s=99999', '-n=10000', '-d=/b/dir'])
|
|
57
68
|
self.assertEqual(args.seed, 99999)
|
|
58
|
-
self.assertEqual(args.ncount, 10000)
|
|
69
|
+
self.assertEqual(args.ncount, (None, 10000, None))
|
|
59
70
|
self.assertEqual(args.dir, '/b/dir')
|
|
60
71
|
self.assertEqual(args.trace, False)
|
|
61
72
|
self.assertEqual(args.gravitation, False)
|
|
@@ -63,7 +74,7 @@ class SingleTestCase(unittest.TestCase):
|
|
|
63
74
|
args = self.parser.parse_args(['test.instr', '--seed', '888', '--ncount', '4', '--dir', '/c/dir', '--trace',
|
|
64
75
|
'--gravitation', '--bufsiz', '1000', '--format', 'NEXUS'])
|
|
65
76
|
self.assertEqual(args.seed, 888)
|
|
66
|
-
self.assertEqual(args.ncount, 4)
|
|
77
|
+
self.assertEqual(args.ncount, (None, 4, None))
|
|
67
78
|
self.assertEqual(args.dir, '/c/dir')
|
|
68
79
|
self.assertEqual(args.trace, True)
|
|
69
80
|
self.assertEqual(args.gravitation, True)
|
|
@@ -73,13 +84,30 @@ class SingleTestCase(unittest.TestCase):
|
|
|
73
84
|
args = self.parser.parse_args(['test.instr', '--seed=777', '--ncount=5', '--dir=/d/dir', '--bufsiz=2000',
|
|
74
85
|
'--format=RAW'])
|
|
75
86
|
self.assertEqual(args.seed, 777)
|
|
76
|
-
self.assertEqual(args.ncount, 5)
|
|
87
|
+
self.assertEqual(args.ncount, (None, 5, None))
|
|
77
88
|
self.assertEqual(args.dir, '/d/dir')
|
|
78
89
|
self.assertEqual(args.trace, False)
|
|
79
90
|
self.assertEqual(args.gravitation, False)
|
|
80
91
|
self.assertEqual(args.bufsiz, 2000)
|
|
81
92
|
self.assertEqual(args.format, 'RAW')
|
|
82
93
|
|
|
94
|
+
def test_ncount_varieties(self):
|
|
95
|
+
args = self.parser.parse_args(['test.instr', '--ncount=5'])
|
|
96
|
+
self.assertEqual(args.ncount, (None, 5, None))
|
|
97
|
+
args = self.parser.parse_args(['test.instr', '-n' ,'4k'])
|
|
98
|
+
self.assertEqual(args.ncount, (None, 4000, None))
|
|
99
|
+
args = self.parser.parse_args(['test.instr', '-n', '3-2+1'])
|
|
100
|
+
self.assertEqual(args.ncount, (3, 2, 1))
|
|
101
|
+
args = self.parser.parse_args(['test.instr', '-n', '1M]1G[1T'])
|
|
102
|
+
self.assertEqual(args.ncount, (10**6, 10**9, 10**12))
|
|
103
|
+
args = self.parser.parse_args(['test.instr', '-n', '1Ki}Mi{2Gi'])
|
|
104
|
+
self.assertEqual(args.ncount, (2**10, 2**20, 2**31))
|
|
105
|
+
args = self.parser.parse_args(['t.instr', '-n', '1.1M', '--nmin', 'M', '--nmax', '2M'])
|
|
106
|
+
self.assertEqual(args.ncount, (None, 1100000, None))
|
|
107
|
+
self.assertEqual(args.nmin, 1000000)
|
|
108
|
+
self.assertEqual(args.nmax, 2000000)
|
|
109
|
+
|
|
110
|
+
|
|
83
111
|
def test_parameters(self):
|
|
84
112
|
from restage.range import MRange, Singular, parameters_to_scan, parse_scan_parameters
|
|
85
113
|
args = self.parser.parse_args(['test.instr', 'a=1.0', 'b=2', 'c=3:5', 'd=blah', 'e=/data', '-m'])
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|