Skip to content

Commit

Permalink
Address PR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Blanca-Fuentes committed Oct 28, 2024
1 parent 9ede1b6 commit 9743d89
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 27 deletions.
14 changes: 9 additions & 5 deletions docs/config_reference.rst
Original file line number Diff line number Diff line change
Expand Up @@ -618,18 +618,22 @@ System Partition Configuration
#. If the corresponding metadata files are not found, the processor information will be auto-detected.
If the system partition is local (i.e., ``local`` scheduler + ``local`` launcher), the processor information is auto-detected unconditionally and stored in the corresponding metadata file for this partition.
If the partition is remote, ReFrame will not try to auto-detect it unless the :envvar:`RFM_REMOTE_DETECT` or the :attr:`general.remote_detect` configuration option is set.
The installation of ReFrame in the remote partition for the auto-detection of processor topology can be configured through the :attr:`general.remote_install` configuration option.
The steps to auto-detect the remote processor information are the following:


a. ReFrame creates a temporary directory created under ``.`` by default.
This temporary directory prefix can be changed by setting the :envvar:`RFM_REMOTE_WORKDIR` environment variable or the :attr:`general.remote_workdir` configuration option.
The directory specified with :envvar:`RFM_REMOTE_WORKDIR` or :attr:`general.remote_workdir` must be a shared directory between the remote node and the one ReFrame is running on.

b. ReFrame changes to that directory and launches a job for the topology auto-detection ``reframe --detect-host-topology=topo.json``.
The :option:`--detect-host-topology` option causes ReFrame to detect the topology of the current host, which in this case would be one of the remote compute nodes.
b. ReFrame changes to that directory and creates a clone of itself there:

- A set of custom commands for the ReFrame installation can be specified through :attr:`general.remote_install` configuration option (as a list). The installation commands must make sure that the fresh ReFrame clone is found in the system path.

- If no custom commands are passed, ReFrame tries to perform the installation first using ``./bootstrap.sh``. If this is not possible, it tries to use ``pip``.

- If a custom set of commands for the remote installation of ReFrame is specified through :attr:`general.remote_install`, ReFrame launches a job with the passed list of commands. The command ``reframe --detect-host-topology=topo.json`` is always added as a last command. Thus, the installation commands must make sure that the reframe installation is found.
- Otherwise, ReFrame creates a fresh clone of itself in the temporary directory and launches a job that will first bootstrap the fresh clone and then run that clone with ``{launcher} ./bin/reframe --detect-host-topology=topo.json``.

c. ReFrame launches a job for the topology auto-detection ``reframe --detect-host-topology=topo.json``.
The :option:`--detect-host-topology` option causes ReFrame to detect the topology of the current host, which in this case would be one of the remote compute nodes.

In case of errors during auto-detection, ReFrame will simply issue a warning and continue.

Expand Down
10 changes: 5 additions & 5 deletions reframe/frontend/autodetect.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def _log_contents(filename):
f'--- {filename} ---')


class _copy_reframe:
class _prepare_reframe:
def __init__(self, prefix):
self._prefix = prefix
self._workdir = None
Expand Down Expand Up @@ -162,15 +162,15 @@ def _emit_custom_script(job, env, commands):
topo_info = {}
try:
prefix = runtime.runtime().get_option('general/0/remote_workdir')
custom_command = runtime.runtime().get_option(
'general/0/remote_install'
)
with _copy_reframe(prefix) as (dirname, use_pip):
with _prepare_reframe(prefix) as (dirname, use_pip):
with osext.change_dir(dirname):
job = Job.create(part.scheduler,
part.launcher_type(),
name='rfm-detect-job',
sched_access=part.access)
custom_command = runtime.runtime().get_option(
'general/0/remote_install'
)
if custom_command:
_emit_custom_script(job, [part.local_env], custom_command)
elif use_pip:
Expand Down
31 changes: 14 additions & 17 deletions unittests/test_autodetect.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,25 +54,23 @@ def default_exec_ctx(make_exec_ctx_g, temp_topo):
yield from make_exec_ctx_g()


@pytest.fixture(params=['default', 'custom_install'])
def custom_install(request):
return request.param == 'custom_install'


@pytest.fixture
def remote_exec_ctx(request, make_exec_ctx, temp_topo):
def remote_exec_ctx(make_exec_ctx, temp_topo, custom_install, monkeypatch):
if test_util.USER_CONFIG_FILE is None:
pytest.skip('no user configuration file supplied')

custom_install = getattr(request, 'param', False)
options = {'general/remote_detect': True}
if custom_install:
options.update({'general/remote_install': ['echo \'{"dummy": "value"}\' > topo.json']})

if not custom_install:
ctx = make_exec_ctx(test_util.USER_CONFIG_FILE,
test_util.USER_SYSTEM,
{'general/remote_detect': True})
else:
ctx = make_exec_ctx(test_util.USER_CONFIG_FILE,
test_util.USER_SYSTEM,
{'general/remote_detect': True,
'general/remote_install': [
'echo \'{"dummy": "value"}\' > topo.json',
]})
yield ctx
yield make_exec_ctx(test_util.USER_CONFIG_FILE,
test_util.USER_SYSTEM,
options)


@pytest.fixture
Expand Down Expand Up @@ -120,13 +118,12 @@ def test_autotect_with_invalid_files(invalid_topo_exec_ctx):
assert part.devices == []


@pytest.mark.parametrize('remote_exec_ctx', [False, True], indirect=True)
def test_remote_autodetect(remote_exec_ctx):
# All we can do with this test is to trigger the remote auto-detection
# path; since we don't know what the remote user system is, we cannot test
# if the topology is right.
# When the parameter in remote_exec_ctx is set to True, custom remote
# installation commands are tested creating a dummy json like topo.json.
# In the custom_remote test installation commands are tested creating
# a dummy json like topo.json.
# This is done to avoid a warning (which would be raised as an error)
# when ReFrame tries to search for the topo.json after
# reframe --detect-host-topology=topo.json, thus checking that the custom
Expand Down

0 comments on commit 9743d89

Please sign in to comment.