Skip to content

Commit

Permalink
Merge pull request #3318 from ekouts/bugfix/autodetection_job_options
Browse files Browse the repository at this point in the history
[bugfix] Add job options from the command-line to processor auto-detection remote job
  • Loading branch information
vkarak authored Nov 13, 2024
2 parents 29d838d + 78772a2 commit a5acd35
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 19 deletions.
11 changes: 7 additions & 4 deletions reframe/frontend/autodetect.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ def _is_part_local(part):
part.launcher_type.registered_name == 'local')


def _remote_detect(part):
def _remote_detect(part, cli_job_options):
use_login_shell = runtime.runtime().get_option('general/0/use_login_shell')

def _emit_script_for_source(job, env):
Expand Down Expand Up @@ -172,7 +172,7 @@ def _emit_custom_script(job, env, commands):
job = Job.create(part.scheduler,
part.launcher_type(),
name='rfm-detect-job',
sched_access=part.access)
sched_access=part.access + cli_job_options)
custom_command = runtime.runtime().get_option(
'general/0/remote_install'
)
Expand Down Expand Up @@ -201,7 +201,8 @@ def _emit_custom_script(job, env, commands):
return topo_info


def detect_topology():
def detect_topology(cli_job_options=None):
cli_job_options = [] if cli_job_options is None else cli_job_options
rt = runtime.runtime()
detect_remote_systems = rt.get_option('general/0/remote_detect')
topo_prefix = osext.expandvars(rt.get_option('general/0/topology_prefix'))
Expand Down Expand Up @@ -280,7 +281,9 @@ def detect_topology():
_save_info(topo_file, part.processor.info)
elif detect_remote_systems:
with runtime.temp_environment(modules=modules, env_vars=vars):
part._processor = ProcessorInfo(_remote_detect(part))
part._processor = ProcessorInfo(
_remote_detect(part, cli_job_options)
)

if part.processor.info:
_save_info(topo_file, part.processor.info)
Expand Down
28 changes: 14 additions & 14 deletions reframe/frontend/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -1109,7 +1109,20 @@ def restrict_logging():

sys.exit(0)

autodetect.detect_topology()
# Need to parse the cli options before autodetection
parsed_job_options = []
for opt in options.job_options:
opt_split = opt.split('=', maxsplit=1)
optstr = opt_split[0]
valstr = opt_split[1] if len(opt_split) > 1 else ''
if opt.startswith('-') or opt.startswith('#'):
parsed_job_options.append(opt)
elif len(optstr) == 1:
parsed_job_options.append(f'-{optstr} {valstr}')
else:
parsed_job_options.append(f'--{optstr}={valstr}')

autodetect.detect_topology(parsed_job_options)
printer.debug(format_env(options.env_vars))

# Setup the check loader
Expand Down Expand Up @@ -1224,19 +1237,6 @@ def print_infoline(param, value):
try:
logging.getprofiler().enter_region('test processing')

# Need to parse the cli options before loading the tests
parsed_job_options = []
for opt in options.job_options:
opt_split = opt.split('=', maxsplit=1)
optstr = opt_split[0]
valstr = opt_split[1] if len(opt_split) > 1 else ''
if opt.startswith('-') or opt.startswith('#'):
parsed_job_options.append(opt)
elif len(optstr) == 1:
parsed_job_options.append(f'-{optstr} {valstr}')
else:
parsed_job_options.append(f'--{optstr}={valstr}')

# Locate and load checks; `force=True` is not needed for normal
# invocations from the command line and has practically no effect, but
# it is needed to better emulate the behavior of running reframe's CLI
Expand Down
1 change: 0 additions & 1 deletion unittests/test_parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

import reframe as rfm
from reframe.core.exceptions import ReframeSyntaxError
import reframe.core.decorators as decorators


class NoParams(rfm.RunOnlyRegressionTest):
Expand Down

0 comments on commit a5acd35

Please sign in to comment.