Skip to content

Commit

Permalink
Merge pull request #2978 from vkarak/bugfix/remote-autodetect-pip
Browse files Browse the repository at this point in the history
[bugfix] Fix remote topology detection for pip installations
  • Loading branch information
vkarak committed Sep 11, 2023
2 parents dfa93c3 + c8983c5 commit fd77789
Showing 1 changed file with 32 additions and 15 deletions.
47 changes: 32 additions & 15 deletions reframe/frontend/autodetect.py
Expand Up @@ -48,15 +48,19 @@ def __enter__(self):
tempfile.mkdtemp(prefix='rfm.', dir=self._prefix)
)
paths = ['bin/', 'reframe/', 'bootstrap.sh', 'requirements.txt']
for p in paths:
src = os.path.join(rfm.INSTALL_PREFIX, p)
if os.path.isdir(src):
dst = os.path.join(self._workdir, p)
osext.copytree(src, dst, dirs_exist_ok=True)
else:
shutil.copy2(src, self._workdir)

return self._workdir
use_pip = False
try:
for p in paths:
src = os.path.join(rfm.INSTALL_PREFIX, p)
if os.path.isdir(src):
dst = os.path.join(self._workdir, p)
osext.copytree(src, dst, dirs_exist_ok=True)
else:
shutil.copy2(src, self._workdir)
except FileNotFoundError:
use_pip = True

return self._workdir, use_pip

def __exit__(self, exc_type, exc_val, exc_tb):
osext.rmtree(self._workdir)
Expand Down Expand Up @@ -124,11 +128,20 @@ def _is_part_local(part):


def _remote_detect(part):
def _emit_script(job, env):
launcher_cmd = job.launcher.run_command(job)
def _emit_script_for_source(job, env):
commands = [
'./bootstrap.sh',
'./bin/reframe --detect-host-topology=topo.json'
]
job.prepare(commands, env, trap_errors=True)

def _emit_script_for_pip(job, env):
commands = [
f'./bootstrap.sh',
f'{launcher_cmd} ./bin/reframe --detect-host-topology=topo.json'
'python3 -m venv venv.reframe',
'source venv.reframe/bin/activate',
f'pip install reframe-hpc=={rfm.VERSION}',
'reframe --detect-host-topology=topo.json',
'deactivate'
]
job.prepare(commands, env, trap_errors=True)

Expand All @@ -139,13 +152,17 @@ def _emit_script(job, env):
topo_info = {}
try:
prefix = runtime.runtime().get_option('general/0/remote_workdir')
with _copy_reframe(prefix) as dirname:
with _copy_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)
_emit_script(job, [part.local_env])
if use_pip:
_emit_script_for_pip(job, [part.local_env])
else:
_emit_script_for_source(job, [part.local_env])

getlogger().debug('submitting detection script')
_log_contents(job.script_filename)
job.submit()
Expand Down

0 comments on commit fd77789

Please sign in to comment.