From 2e66cc4a2bc4101e2daab91b13cfc1ac1be20930 Mon Sep 17 00:00:00 2001 From: Frederick Deny Date: Fri, 29 Dec 2023 15:35:45 -0800 Subject: [PATCH] removed singularity related options and added new script location in the user's prefix instead of in the container --- e4s_cl/__init__.py | 3 +++ e4s_cl/cf/containers/barebones.py | 18 ++++++++++-------- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/e4s_cl/__init__.py b/e4s_cl/__init__.py index 5616aeee..6683ac6c 100644 --- a/e4s_cl/__init__.py +++ b/e4s_cl/__init__.py @@ -93,6 +93,9 @@ CONTAINER_SCRIPT = Path(CONTAINER_DIR, "script").as_posix() """str: Path of the script to execute in the container""" +BAREBONES_SCRIPT = Path(USER_PREFIX, "barebones_script").as_posix() +"""str: Path of the script to execute in the use of the barebones backend""" + CONTAINER_LIBRARY_DIR = Path(CONTAINER_DIR, "hostlibs").as_posix() """str: Path of the libraries bound in the container""" diff --git a/e4s_cl/cf/containers/barebones.py b/e4s_cl/cf/containers/barebones.py index 23c21fa4..417fa5f7 100644 --- a/e4s_cl/cf/containers/barebones.py +++ b/e4s_cl/cf/containers/barebones.py @@ -5,7 +5,7 @@ import os from pathlib import Path from typing import List -from e4s_cl import logger +from e4s_cl import logger, BAREBONES_SCRIPT from e4s_cl.util import run_subprocess from e4s_cl.cf.libraries import cache_libraries from e4s_cl.cf.containers import Container, FileOptions, BackendNotAvailableError @@ -42,6 +42,10 @@ def __setup__(self): #self.bind_file('/dev', option=FileOptions.READ_WRITE) #self.bind_file('/tmp', option=FileOptions.READ_WRITE) + @property + def script(self): + return Path(BAREBONES_SCRIPT) + def _format_bound(self): """ Format a list of files to a compatible bind option of singularity @@ -69,12 +73,7 @@ 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._working_dir(), - *nvidia_flag, *self._additional_options('exec'), - self.image, *command, ] @@ -90,9 +89,12 @@ def _has_nvidia(self): return True def run(self, command: List[str], overload: bool = True) -> int: - executable = self._executable() - container_cmd = [executable, *self._prepare(command, overload)] + container_cmd = [*self._prepare(command, overload)] + LOGGER.debug("***************************************888") + LOGGER.debug(container_cmd) + LOGGER.debug(command) + LOGGER.debug("***************************************888") return run_subprocess(container_cmd, env=self.env)