restage 0.5.0__tar.gz → 0.6.0__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.5.0 → restage-0.6.0}/.gitignore +1 -0
- {restage-0.5.0/src/restage.egg-info → restage-0.6.0}/PKG-INFO +2 -2
- {restage-0.5.0 → restage-0.6.0}/pyproject.toml +1 -1
- {restage-0.5.0 → restage-0.6.0}/src/restage/cache.py +6 -10
- {restage-0.5.0 → restage-0.6.0}/src/restage/mcpl.py +20 -23
- {restage-0.5.0 → restage-0.6.0/src/restage.egg-info}/PKG-INFO +2 -2
- {restage-0.5.0 → restage-0.6.0}/src/restage.egg-info/requires.txt +1 -1
- restage-0.6.0/test/test_env_vars.py +42 -0
- {restage-0.5.0 → restage-0.6.0}/test/test_single.py +19 -12
- restage-0.5.0/test/test_env_vars.py +0 -43
- {restage-0.5.0 → restage-0.6.0}/.github/workflows/pip.yml +0 -0
- {restage-0.5.0 → restage-0.6.0}/.github/workflows/wheels.yml +0 -0
- {restage-0.5.0 → restage-0.6.0}/README.md +0 -0
- {restage-0.5.0 → restage-0.6.0}/setup.cfg +0 -0
- {restage-0.5.0 → restage-0.6.0}/src/restage/__init__.py +0 -0
- {restage-0.5.0 → restage-0.6.0}/src/restage/bifrost_choppers.py +0 -0
- {restage-0.5.0 → restage-0.6.0}/src/restage/config/__init__.py +0 -0
- {restage-0.5.0 → restage-0.6.0}/src/restage/config/default.yaml +0 -0
- {restage-0.5.0 → restage-0.6.0}/src/restage/cspec_choppers.py +0 -0
- {restage-0.5.0 → restage-0.6.0}/src/restage/database.py +0 -0
- {restage-0.5.0 → restage-0.6.0}/src/restage/emulate.py +0 -0
- {restage-0.5.0 → restage-0.6.0}/src/restage/energy.py +0 -0
- {restage-0.5.0 → restage-0.6.0}/src/restage/instr.py +0 -0
- {restage-0.5.0 → restage-0.6.0}/src/restage/range.py +0 -0
- {restage-0.5.0 → restage-0.6.0}/src/restage/run.py +0 -0
- {restage-0.5.0 → restage-0.6.0}/src/restage/scan.py +0 -0
- {restage-0.5.0 → restage-0.6.0}/src/restage/splitrun.py +0 -0
- {restage-0.5.0 → restage-0.6.0}/src/restage/tables.py +0 -0
- {restage-0.5.0 → restage-0.6.0}/src/restage.egg-info/SOURCES.txt +0 -0
- {restage-0.5.0 → restage-0.6.0}/src/restage.egg-info/dependency_links.txt +0 -0
- {restage-0.5.0 → restage-0.6.0}/src/restage.egg-info/entry_points.txt +0 -0
- {restage-0.5.0 → restage-0.6.0}/src/restage.egg-info/top_level.txt +0 -0
- {restage-0.5.0 → restage-0.6.0}/test/test_cache.py +0 -0
- {restage-0.5.0 → restage-0.6.0}/test/test_cache_ro.py +0 -0
- {restage-0.5.0 → restage-0.6.0}/test/test_database.py +0 -0
- {restage-0.5.0 → restage-0.6.0}/test/test_energy.py +0 -0
- {restage-0.5.0 → restage-0.6.0}/test/test_range.py +0 -0
- {restage-0.5.0 → restage-0.6.0}/test/test_scan.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: restage
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.6.0
|
|
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.
|
|
20
|
+
Requires-Dist: mccode-antlr[hdf5]>=0.13.0
|
|
21
21
|
Provides-Extra: test
|
|
22
22
|
Requires-Dist: pytest; extra == "test"
|
|
23
23
|
Requires-Dist: chopcal; extra == "test"
|
|
@@ -107,24 +107,20 @@ def directory_under_module_data_path(sub: str, prefix=None, suffix=None, name=No
|
|
|
107
107
|
|
|
108
108
|
def _compile_instr(entry: InstrEntry, instr: Instr, config: dict | None = None,
|
|
109
109
|
mpi: bool = False, acc: bool = False,
|
|
110
|
-
target=None,
|
|
111
|
-
from mccode_antlr import __version__
|
|
110
|
+
target=None, flavor=None):
|
|
111
|
+
from mccode_antlr import __version__, Flavor
|
|
112
112
|
from mccode_antlr.compiler.c import compile_instrument, CBinaryTarget
|
|
113
113
|
if config is None:
|
|
114
114
|
config = dict(default_main=True, enable_trace=False, portable=False, include_runtime=True,
|
|
115
115
|
embed_instrument_file=False, verbose=False)
|
|
116
116
|
if target is None:
|
|
117
117
|
target = CBinaryTarget(mpi=mpi or False, acc=acc or False, count=1, nexus=False)
|
|
118
|
-
if
|
|
119
|
-
|
|
120
|
-
generator = MCSTAS_GENERATOR
|
|
118
|
+
if flavor is None:
|
|
119
|
+
flavor = Flavor.MCSTAS
|
|
121
120
|
|
|
122
121
|
output = directory_under_module_data_path('bin')
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
# FIXME a future mccode-antlr will support setting 'source_file={file_path}'
|
|
126
|
-
# to allow exactly this.
|
|
127
|
-
binary_path = compile_instrument(instr, target, output, generator=generator, config=config, dump_source=True)
|
|
122
|
+
source_file = output.joinpath(instr.name).with_suffix('.c')
|
|
123
|
+
binary_path = compile_instrument(instr, target, output, flavor=flavor, config=config, source_file=source_file)
|
|
128
124
|
entry.mccode_version = __version__
|
|
129
125
|
entry.binary_path = str(binary_path)
|
|
130
126
|
return entry
|
|
@@ -4,20 +4,26 @@ from pathlib import Path
|
|
|
4
4
|
def mcpl_real_filename(filename: Path) -> Path:
|
|
5
5
|
"""MCPL_output from McCode instruments has the bad habit of changing the output file name silently.
|
|
6
6
|
Find the _real_ output file name by looking for the expected variants"""
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
7
|
+
base, ext = filename.parent / filename.stem, filename.suffix
|
|
8
|
+
if ext in ('.gz',):
|
|
9
|
+
ext = base.suffix + ext
|
|
10
|
+
base = base.parent / base.stem
|
|
11
|
+
extensions = {'.mcpl.gz', '.mcpl', ''}
|
|
12
|
+
if ext not in extensions:
|
|
13
|
+
ValueError(f'Unsupported file extension: {ext}')
|
|
14
|
+
for ext in extensions:
|
|
15
|
+
check = base.with_suffix(ext)
|
|
16
|
+
if check.exists() and check.is_file():
|
|
17
|
+
return check
|
|
18
|
+
print(f'{base} -> {check} not found')
|
|
13
19
|
raise FileNotFoundError(f'Could not find MCPL file {filename}')
|
|
14
20
|
|
|
15
21
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
22
|
+
def mcpl_real_extension(filename: Path) -> str:
|
|
23
|
+
for ext in ('.mcpl.gz', '.mcpl'):
|
|
24
|
+
if str(filename).endswith(ext):
|
|
25
|
+
return ext
|
|
26
|
+
return ''
|
|
21
27
|
|
|
22
28
|
|
|
23
29
|
def mcpl_particle_count(filename):
|
|
@@ -52,11 +58,7 @@ def mcpl_merge_files(files: list[Path], filepath: Path, keep_originals: bool = F
|
|
|
52
58
|
from subprocess import run
|
|
53
59
|
real_filenames = [mcpl_real_filename(f) for f in files]
|
|
54
60
|
# if the real filenames have .mcpl or .mcpl.gz, the merged filename should too
|
|
55
|
-
ext =
|
|
56
|
-
if real_filenames[0].name.endswith('.mcpl.gz'):
|
|
57
|
-
ext = '.mcpl.gz'
|
|
58
|
-
elif real_filenames[0].name.endswith('.mcpl'):
|
|
59
|
-
ext = '.mcpl'
|
|
61
|
+
ext = mcpl_real_extension(real_filenames[0])
|
|
60
62
|
filename = filepath.with_suffix(ext).as_posix()
|
|
61
63
|
|
|
62
64
|
command = ['mcpltool', '--merge', filename] + [str(f) for f in real_filenames]
|
|
@@ -69,13 +71,8 @@ def mcpl_merge_files(files: list[Path], filepath: Path, keep_originals: bool = F
|
|
|
69
71
|
|
|
70
72
|
|
|
71
73
|
def mcpl_rename_file(source: Path, dest: Path, strict: bool = False):
|
|
72
|
-
filepath = mcpl_real_filename(source)
|
|
73
|
-
|
|
74
|
-
ext = ''
|
|
75
|
-
if filepath.name.endswith('.mcpl.gz'):
|
|
76
|
-
ext = '.mcpl.gz'
|
|
77
|
-
elif filepath.name.endswith('.mcpl'):
|
|
78
|
-
ext = '.mcpl'
|
|
74
|
+
filepath = mcpl_real_filename(source) # this could be '{name}', '{name}.mcpl', or '{name}.mcpl.gz'
|
|
75
|
+
ext = mcpl_real_extension(filepath)
|
|
79
76
|
|
|
80
77
|
if not dest.name.endswith(ext):
|
|
81
78
|
if strict:
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: restage
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.6.0
|
|
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.
|
|
20
|
+
Requires-Dist: mccode-antlr[hdf5]>=0.13.0
|
|
21
21
|
Provides-Extra: test
|
|
22
22
|
Requires-Dist: pytest; extra == "test"
|
|
23
23
|
Requires-Dist: chopcal; extra == "test"
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
from unittest import TestCase
|
|
2
|
+
from unittest.mock import patch
|
|
3
|
+
from importlib import reload
|
|
4
|
+
import restage.config
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class SettingsTests(TestCase):
|
|
8
|
+
import os
|
|
9
|
+
@patch.dict(os.environ, {"RESTAGE_CACHE": "/tmp/some/location"})
|
|
10
|
+
def test_restage_cache_config(self):
|
|
11
|
+
reload(restage.config)
|
|
12
|
+
from restage.config import config
|
|
13
|
+
self.assertTrue(config['cache'].exists())
|
|
14
|
+
self.assertEqual(config['cache'].as_str(), '/tmp/some/location')
|
|
15
|
+
|
|
16
|
+
@patch.dict(os.environ, {"RESTAGE_FIXED": "/tmp/some/location"})
|
|
17
|
+
def test_restage_single_fixed_config(self):
|
|
18
|
+
reload(restage.config)
|
|
19
|
+
from restage.config import config
|
|
20
|
+
self.assertTrue(config['fixed'].exists())
|
|
21
|
+
self.assertEqual(config['fixed'].as_str(), '/tmp/some/location')
|
|
22
|
+
|
|
23
|
+
@patch.dict(os.environ, {'RESTAGE_FIXED': '/tmp/a /tmp/b /tmp/c'})
|
|
24
|
+
def test_restage_multi_fixed_config(self):
|
|
25
|
+
reload(restage.config)
|
|
26
|
+
from restage.config import config
|
|
27
|
+
self.assertTrue(config['fixed'].exists())
|
|
28
|
+
more = config['fixed'].as_str_seq()
|
|
29
|
+
self.assertEqual(len(more), 3)
|
|
30
|
+
self.assertEqual(more[0],'/tmp/a')
|
|
31
|
+
self.assertEqual(more[1],'/tmp/b')
|
|
32
|
+
self.assertEqual(more[2],'/tmp/c')
|
|
33
|
+
|
|
34
|
+
def test_restage_standard_config(self):
|
|
35
|
+
from os import environ
|
|
36
|
+
reload(restage.config)
|
|
37
|
+
from restage.config import config
|
|
38
|
+
if 'cache' in config:
|
|
39
|
+
self.assertEqual(config['cache'].as_str(), environ['RESTAGE_CACHE'])
|
|
40
|
+
if 'fixed' in config:
|
|
41
|
+
self.assertEqual(config['fixed'].as_str(), environ['RESTAGE_FIXED'])
|
|
42
|
+
|
|
@@ -149,18 +149,10 @@ class SplitRunTestCase(unittest.TestCase):
|
|
|
149
149
|
def _define_instr(self):
|
|
150
150
|
from math import pi, asin, sqrt
|
|
151
151
|
from mccode_antlr.reader import MCSTAS_REGISTRY
|
|
152
|
-
from mccode_antlr.reader import GitHubRegistry
|
|
153
152
|
from mccode_antlr.loader.loader import parse_mccode_instr
|
|
154
153
|
|
|
155
154
|
def parse(contents):
|
|
156
|
-
|
|
157
|
-
mcpl_input_once_registry = GitHubRegistry(
|
|
158
|
-
name='mcpl_input_once',
|
|
159
|
-
url='https://github.com/g5t/mccode-mcpl-input-once',
|
|
160
|
-
version='main',
|
|
161
|
-
filename='pooch-registry.txt'
|
|
162
|
-
)
|
|
163
|
-
registries = [MCSTAS_REGISTRY, mcpl_input_once_registry]
|
|
155
|
+
registries = [MCSTAS_REGISTRY]
|
|
164
156
|
return parse_mccode_instr(contents, registries, '<test string>')
|
|
165
157
|
|
|
166
158
|
d_spacing = 3.355 # (002) for Highly-ordered Pyrolytic Graphite
|
|
@@ -241,8 +233,13 @@ class SplitRunTestCase(unittest.TestCase):
|
|
|
241
233
|
output.mkdir(parents=True)
|
|
242
234
|
|
|
243
235
|
# run the scan
|
|
244
|
-
splitrun(self.instr, scan, precision={}, split_at='split_at', grid=False,
|
|
245
|
-
|
|
236
|
+
splitrun(self.instr, scan, precision={}, split_at='split_at', grid=False,
|
|
237
|
+
ncount=10_000,
|
|
238
|
+
dir=output,
|
|
239
|
+
mcpl_output_parameters={'weight_mode': '1'},
|
|
240
|
+
mcpl_input_component='MCPL_input_once',
|
|
241
|
+
mcpl_input_parameters={'preload': '1'}
|
|
242
|
+
)
|
|
246
243
|
|
|
247
244
|
# check the scan directory for output
|
|
248
245
|
for x in self.dir.glob('**/*.dat'):
|
|
@@ -261,6 +258,13 @@ class SplitRunTestCase(unittest.TestCase):
|
|
|
261
258
|
default installed location, /usr/local/lib64/libmcpl.so; so this test must
|
|
262
259
|
be invoked with that location specified, e.g.,
|
|
263
260
|
$ LD_LIBRARY_PATH=/usr/local/lib64 pytest test/test_single.py -k test_parallel_scan
|
|
261
|
+
|
|
262
|
+
Another potential issue to address, the `MCPL_*.comp` components may use a
|
|
263
|
+
special `@MCPLFLAGS@` directive to read flags from a configuration file instead
|
|
264
|
+
of using the provided `mcpl-config --show buildflags` command.
|
|
265
|
+
You might need to use `mccode-antlr config save -v` to create/locate the
|
|
266
|
+
mccode-antlr `config.yml` file then edit/add the entry for `flags.mcpl` with
|
|
267
|
+
the output of the tool above.
|
|
264
268
|
"""
|
|
265
269
|
from restage.splitrun import splitrun
|
|
266
270
|
from restage.range import parse_scan_parameters
|
|
@@ -270,7 +274,10 @@ class SplitRunTestCase(unittest.TestCase):
|
|
|
270
274
|
output.mkdir(parents=True)
|
|
271
275
|
splitrun(self.instr, scan, precision={}, split_at='split_at', grid=False, ncount=100_000, dir=output,
|
|
272
276
|
parallel=True, process_count=4,
|
|
273
|
-
|
|
277
|
+
mcpl_output_parameters={'weight_mode': '1'},
|
|
278
|
+
mcpl_input_component='MCPL_input_once',
|
|
279
|
+
mcpl_input_parameters={'preload': '1'}
|
|
280
|
+
)
|
|
274
281
|
|
|
275
282
|
# check the scan directory for output
|
|
276
283
|
for x in self.dir.glob('**/*.dat'):
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import os
|
|
2
|
-
from unittest import TestCase, mock
|
|
3
|
-
from pathlib import Path
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
def restage_loaded():
|
|
7
|
-
import sys
|
|
8
|
-
return 'restage' in sys.modules or 'restage.config' in sys.modules
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
def first(test):
|
|
12
|
-
import unittest
|
|
13
|
-
@unittest.skipIf(restage_loaded(), reason="Environment variable patching must be done before restage is loaded")
|
|
14
|
-
def first_test(*args, **kwargs):
|
|
15
|
-
return test(*args, **kwargs)
|
|
16
|
-
return first_test
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
class SettingsTests(TestCase):
|
|
20
|
-
@first
|
|
21
|
-
@mock.patch.dict(os.environ, {"RESTAGE_CACHE": "/tmp/some/location"})
|
|
22
|
-
def test_restage_cache_config(self):
|
|
23
|
-
from restage.config import config
|
|
24
|
-
self.assertTrue(config['cache'].exists())
|
|
25
|
-
self.assertEqual(config['cache'].as_path(), Path('/tmp/some/location'))
|
|
26
|
-
|
|
27
|
-
@first
|
|
28
|
-
@mock.patch.dict(os.environ, {"RESTAGE_FIXED": "/tmp/some/location"})
|
|
29
|
-
def test_restage_single_fixed_config(self):
|
|
30
|
-
from restage.config import config
|
|
31
|
-
self.assertTrue(config['fixed'].exists())
|
|
32
|
-
self.assertEqual(config['fixed'].as_path(), Path('/tmp/some/location'))
|
|
33
|
-
|
|
34
|
-
@first
|
|
35
|
-
@mock.patch.dict(os.environ, {'RESTAGE_FIXED': '/tmp/a /tmp/b /tmp/c'})
|
|
36
|
-
def test_restage_multi_fixed_config(self):
|
|
37
|
-
from restage.config import config
|
|
38
|
-
self.assertTrue(config['fixed'].exists())
|
|
39
|
-
more = config['fixed'].as_str_seq()
|
|
40
|
-
self.assertEqual(len(more), 3)
|
|
41
|
-
self.assertEqual(Path(more[0]), Path('/tmp/a'))
|
|
42
|
-
self.assertEqual(Path(more[1]), Path('/tmp/b'))
|
|
43
|
-
self.assertEqual(Path(more[2]), Path('/tmp/c'))
|
|
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
|