Commit ed4ae5fe authored by Alejandro Homs Puron's avatar Alejandro Homs Puron
Browse files

[SCRIPTS] Improve lima_launcher setup_script and conda:

* Support multi-line scripts
* Add default conda environment base (/users/blissadm/conda/miniconda)
parent 33d4a81a
......@@ -10,7 +10,7 @@
},
"environment": {
"*": {
"setup_script": "/users/blissadm/local/sls_detectors/eiger/scripts/det_env_setup.sh",
"setup_script": [". /users/blissadm/local/sls_detectors/common/scripts/det_env_setup.sh"],
"ssh_agent": true,
"cpu_affinity": {
"cpufreq_governor": "performance",
......
......@@ -97,13 +97,15 @@ class Environment:
else:
print(f'Warning: error in EXEC access to {ld_preload}')
script = self.config.get('setup_script', {})
if script:
cmd = f'. {script} && {cmd}'
script = self.config.get('setup_script', [])
if len(script) == 1:
cmd = f'{script[0]} && {cmd}'
elif script:
cmd = '\n'.join(script + [cmd])
conda = self.config.get('conda', {})
if conda:
conda_base = conda.get('base', '')
conda_base = conda.get('base', '/users/blissadm/conda/miniconda')
env = conda.get('environment', '')
if conda_base and env:
activate = os.path.join(conda_base, 'bin/activate')
......@@ -111,13 +113,14 @@ class Environment:
else:
print(f'Warning: missing conda base/environment')
cmd = ['bash', '-c', cmd]
cmd = ['bash', '-ec', cmd]
ssh_agent = self.config.get('ssh_agent', False)
if ssh_agent:
cmd.insert(0, 'ssh-agent')
print('Executing:', ' '.join(cmd), '...')
print_cmd = ' '.join(cmd[:-1] + [f"'{cmd[-1]}'"])
print(f'Executing: {print_cmd} ...')
sys.stdout.flush()
global running_proc
running_proc = subprocess.Popen(cmd)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment