diff --git a/e4s_cl/cf/containers/barebones.py b/e4s_cl/cf/containers/barebones.py index e0e21c73..d5ba0c14 100644 --- a/e4s_cl/cf/containers/barebones.py +++ b/e4s_cl/cf/containers/barebones.py @@ -106,8 +106,9 @@ def _prepare(self, command: List[str], overload: bool = True) -> List[str]: nvidia_flag = ['--nv'] if self._has_nvidia() else [] return [ - *self._additional_options('exec'), + *self._additional_options(), *command, + *self._additional_options('exec'), ] def bind_file(self, diff --git a/e4s_cl/config.py b/e4s_cl/config.py index 9be704db..2dfd94f4 100644 --- a/e4s_cl/config.py +++ b/e4s_cl/config.py @@ -327,6 +327,24 @@ def __str__(self): "Options to pass to the shifter executable", ), }), + ConfigurationGroup( + "barebones", + { + ConfigurationField( + "options", + list, + lambda: [], + "Options to pass before the execution script", + ), + ConfigurationField( + "exec_options", + list, + lambda: [], + "Options to pass after the execution script", + ), + }, + "Barebones backend configuration", + ), }), }) diff --git a/tests/test_containers_barebones.py b/tests/test_containers_barebones.py index e0510917..1ea0b392 100644 --- a/tests/test_containers_barebones.py +++ b/tests/test_containers_barebones.py @@ -16,6 +16,7 @@ TEST_CONFIGURATION = config.Configuration.create_from_string(f""" backends: barebones: + options: ['--nocolor', '-s'] exec_options: ['--hostname', 'XxmycoolcontainerxX'] """) @@ -27,19 +28,6 @@ def test_create(self): self.assertFalse(type(container) == Container) self.assertTrue(isinstance(container, Container)) - def test_run_image(self): - container = Container(name='barebones', image='imagenametest') - command = [''] - container_cmd = container._prepare(command) - self.assertIn('imagenametest', ' '.join(map(str, container_cmd))) - - def test_run_pwd(self): - container = Container(name='barebones') - command = [''] - container_cmd = container._prepare(command) - pwd = getcwd() - self.assertIn(pwd, ' '.join(map(str, container_cmd))) - def test_run_mpirun(self): container = Container(name='barebones', image='dummyimagename') command = ['mpirun -n 2 ls'] @@ -64,22 +52,6 @@ def test_bind_file(self): self.assertIn('tmp2', [Path(path).name for path in list_directory_files(Path(BAREBONES_LIBRARY_DIR))]) - def test_bind_relative(self): - container = Container(name='barebones') - - target = Path('/tmp/../proc/meminfo') - - ref = Path('/tmp') - file_ex = Path('/proc/meminfo') - home = Path.home() - paths = {ref, file_ex, home} - - container.bind_file(target) - files = set(map(lambda x: x.origin, container.bound)) - - for item in paths: - self.assertIn(item, files) - def test_additional_options_config(self): container = Container(name='barebones') command = [''] @@ -93,7 +65,6 @@ def test_additional_options_config(self): self.assertContainsInOrder([ '--nocolor', '-s', - 'exec', '--hostname', 'XxmycoolcontainerxX', ], barebones_command) @@ -111,20 +82,19 @@ def test_additional_options_environment(self): for option in {'--nocolor', '-s', '--hostname', 'XxmycoolcontainerxX'}: self.assertNotIn(option, barebones_command) - environ['E4S_CL_barebones_OPTIONS'] = "--nocolor -s" + environ['E4S_CL_BAREBONES_OPTIONS'] = "--nocolor -s" environ[ - 'E4S_CL_barebones_EXEC_OPTIONS'] = "--hostname XxmycoolcontainerxX" + 'E4S_CL_BAREBONES_EXEC_OPTIONS'] = "--hostname XxmycoolcontainerxX" barebones_command = container._prepare(command) self.assertContainsInOrder([ '--nocolor', '-s', - 'exec', '--hostname', 'XxmycoolcontainerxX', ], barebones_command) - del environ['E4S_CL_barebones_OPTIONS'] - del environ['E4S_CL_barebones_EXEC_OPTIONS'] + del environ['E4S_CL_BAREBONES_OPTIONS'] + del environ['E4S_CL_BAREBONES_EXEC_OPTIONS'] barebones_command = container._prepare(command) for option in {'--nocolor', '-s', '--hostname', 'XxmycoolcontainerxX'}: self.assertNotIn(option, barebones_command)