Skip to content

Commit f33c8e5

Browse files
author
Vasileios Karakasis
authored
Merge pull request #2074 from vkarak/bugfix/use-home-autodetect
[bugfix] Always use `$HOME` for storing processor auto-detection results
2 parents bb91223 + 9620dd1 commit f33c8e5

File tree

3 files changed

+10
-25
lines changed

3 files changed

+10
-25
lines changed

reframe/frontend/autodetect.py

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -154,14 +154,7 @@ def _emit_script(job):
154154
def detect_topology():
155155
rt = runtime()
156156
detect_remote_systems = rt.get_option('general/0/remote_detect')
157-
config_file = rt.site_config.filename
158-
if config_file == '<builtin>':
159-
config_prefix = os.path.join(
160-
os.getenv('HOME'), '.reframe/topology'
161-
)
162-
else:
163-
config_prefix = os.path.join(os.path.dirname(config_file), '_meta')
164-
157+
topo_prefix = os.path.join(os.getenv('HOME'), '.reframe/topology')
165158
for part in rt.system.partitions:
166159
getlogger().debug(f'detecting topology info for {part.fullname}')
167160
found_procinfo = False
@@ -184,10 +177,10 @@ def detect_topology():
184177
continue
185178

186179
topo_file = os.path.join(
187-
config_prefix, f'{rt.system.name}-{part.name}', 'processor.json'
180+
topo_prefix, f'{rt.system.name}-{part.name}', 'processor.json'
188181
)
189182
dev_file = os.path.join(
190-
config_prefix, f'{rt.system.name}-{part.name}', 'devices.json'
183+
topo_prefix, f'{rt.system.name}-{part.name}', 'devices.json'
191184
)
192185
if not found_procinfo and os.path.exists(topo_file):
193186
getlogger().debug(

unittests/test_autodetect.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
import json
77
import os
88
import pytest
9-
import shutil
109

1110

1211
from reframe.core.runtime import runtime
@@ -15,13 +14,12 @@
1514

1615

1716
@pytest.fixture
18-
def exec_ctx(make_exec_ctx_g, tmp_path):
19-
# Copy the default settings to the temp dir
20-
config_file = tmp_path / 'conf.py'
21-
shutil.copy('reframe/core/settings.py', config_file)
17+
def exec_ctx(make_exec_ctx_g, tmp_path, monkeypatch):
18+
# Monkey-patch HOME, since topology is always written there
19+
monkeypatch.setenv('HOME', str(tmp_path))
2220

2321
# Create a devices file manually, since it is not auto-generated
24-
meta_prefix = tmp_path / '_meta' / 'generic-default'
22+
meta_prefix = tmp_path / '.reframe' / 'topology' / 'generic-default'
2523
os.makedirs(meta_prefix)
2624
with open(meta_prefix / 'devices.json', 'w') as fp:
2725
json.dump([
@@ -32,7 +30,7 @@ def exec_ctx(make_exec_ctx_g, tmp_path):
3230
}
3331
], fp)
3432

35-
yield from make_exec_ctx_g(config_file)
33+
yield from make_exec_ctx_g()
3634

3735

3836
def test_autotect(exec_ctx):

unittests/test_cli.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
import os
1111
import pytest
1212
import re
13-
import shutil
1413
import sys
1514

1615
import reframe.core.environments as env
@@ -54,13 +53,7 @@ def perflogdir(tmp_path):
5453

5554

5655
@pytest.fixture
57-
def rm_config_meta():
58-
yield
59-
shutil.rmtree('unittests/resources/_meta', ignore_errors=True)
60-
61-
62-
@pytest.fixture
63-
def run_reframe(tmp_path, perflogdir, rm_config_meta):
56+
def run_reframe(tmp_path, perflogdir, monkeypatch):
6457
def _run_reframe(system='generic:default',
6558
checkpath=['unittests/resources/checks/hellocheck.py'],
6659
environs=['builtin'],
@@ -113,6 +106,7 @@ def _run_reframe(system='generic:default',
113106

114107
return run_command_inline(argv, cli.main)
115108

109+
monkeypatch.setenv('HOME', str(tmp_path))
116110
return _run_reframe
117111

118112

0 commit comments

Comments
 (0)