Skip to content

Commit

Permalink
removed singularity related options and added new script location in …
Browse files Browse the repository at this point in the history
…the user's prefix instead of in the container
  • Loading branch information
FrederickDeny committed Dec 29, 2023
1 parent 62336c9 commit 2e66cc4
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
3 changes: 3 additions & 0 deletions e4s_cl/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"""

Expand Down
18 changes: 10 additions & 8 deletions e4s_cl/cf/containers/barebones.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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,
]

Expand All @@ -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)

Expand Down

0 comments on commit 2e66cc4

Please sign in to comment.