diff --git a/hbp_nrp_music_interface/hbp_nrp_music_interface/launch/host/LuganoLauncher.py b/hbp_nrp_music_interface/hbp_nrp_music_interface/launch/host/LuganoLauncher.py index 3153bc144d1170c709e7c9a1f5a4658c2d367879..39d17a40a49093aa72b5fbef3f3d32d388e4f4a1 100644 --- a/hbp_nrp_music_interface/hbp_nrp_music_interface/launch/host/LuganoLauncher.py +++ b/hbp_nrp_music_interface/hbp_nrp_music_interface/launch/host/LuganoLauncher.py @@ -68,19 +68,16 @@ class LuganoLauncher(LuganoVizCluster, LocalLauncher): # create a launch script that configures the vizcluster environment properly with open(path, 'w') as f: f.write('#!/bin/bash\n') + f.write('source /opt/rh/python27/enable\n') # set the terminal type to ensure we get the same behavior as from a backend VM # this is also required in the Docker images f.write('export TERM=linux\n') - # environment variable configuration - f.write('source /opt/rh/python27/enable\n') - f.write('export ENVIRONMENT=%s\n' % environment) - if environment == 'staging': - with open(os.environ.get('NRP_VARIABLES_PATH')) as f: - content = f.readlines() - for version in [x.strip() for x in content if '_VERSION=' in x]: - f.write('%s\n' % version) + # set the environment version and any specific module versions to be used, then + # override the environment variable to the deployed location on the remote host + f.write('source $NRP_MUSIC_DIRECTORY/nrp-variables\n') + f.write('export NRP_VARIABLES_PATH=$NRP_MUSIC_DIRECTORY/nrp-variables\n') # load the environment modules based on the above configuration proj_path = '/gpfs/bbp.cscs.ch/project/proj30/neurorobotics/%s/' % environment @@ -101,6 +98,7 @@ class LuganoLauncher(LuganoVizCluster, LocalLauncher): # actually launch the module f.write('python -m {module}\n'.format(module=module)) + # ensure the script is executable os.chmod(path, stat.S_IRWXU) # return a relative path to the script, it's guaranteed to be run in the tmpdir @@ -111,8 +109,15 @@ class LuganoLauncher(LuganoVizCluster, LocalLauncher): Copy all configuration files to a temp directory on the remote host. The remote directory is created here, so use it to set the launcher interface host tmpdir value. """ + + # generated configuration files for f in os.listdir(self._local_tmpdir): self._copy_to_remote(os.path.join(self._local_tmpdir, f)) + + # deploy any NRP specific variable/module version configuration + self._copy_to_remote(os.environ.get('NRP_VARIABLES_PATH')) + + # set the host tmpdir, slightly different naming convention between interfaces self._host_tmpdir = self._tmp_dir def shutdown(self): diff --git a/hbp_nrp_music_interface/hbp_nrp_music_interface/tests/launch/host/test_lugano.py b/hbp_nrp_music_interface/hbp_nrp_music_interface/tests/launch/host/test_lugano.py index c0edb464a60c110515afa3c30f2675541167ca57..f610f9a3fb71234185e74f626f9919f466a05a8d 100644 --- a/hbp_nrp_music_interface/hbp_nrp_music_interface/tests/launch/host/test_lugano.py +++ b/hbp_nrp_music_interface/hbp_nrp_music_interface/tests/launch/host/test_lugano.py @@ -54,9 +54,10 @@ class TestLuganoLauncherInterface(unittest.TestCase): handle = m() self.assertEqual(handle.write.call_args_list, [call('#!/bin/bash\n'), - call('export TERM=linux\n'), call('source /opt/rh/python27/enable\n'), - call('export ENVIRONMENT=dev\n'), + call('export TERM=linux\n'), + call('source $NRP_MUSIC_DIRECTORY/nrp-variables\n'), + call('export NRP_VARIABLES_PATH=$NRP_MUSIC_DIRECTORY/nrp-variables\n'), call('source /gpfs/bbp.cscs.ch/project/proj30/neurorobotics/dev//server-scripts/nrp-services-modules.sh\n'), call('export NRP_MODELS_DIRECTORY=/gpfs/bbp.cscs.ch/project/proj30/neurorobotics/dev//models\n'), call('export NRP_EXPERIMENTS_DIRECTORY=/gpfs/bbp.cscs.ch/project/proj30/neurorobotics/dev//experiments\n'),