Skip to content

Commit

Permalink
check for apptainer runtime
Browse files Browse the repository at this point in the history
  • Loading branch information
espenhgn committed Oct 1, 2024
1 parent a882657 commit 0f71aa7
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions tests/test_mtag_container.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,19 @@
# If neither are found, tests will fall back to plain python.
try:
pth = os.path.join('apptainer', 'mtag.sif')
out = subprocess.run('singularity')
try:
out = subprocess.run('singularity')
runtime = 'singularity'
except FileNotFoundError:
try:
out = subprocess.run('apptainer')
runtime = 'apptainer'
except FileNotFoundError:
raise FileNotFoundError
cwd = os.getcwd()
MTAG = f'singularity run {pth}'
PREFIX = f'singularity exec {pth} python'
PREFIX_MOUNT = f'singularity exec --home={cwd}:/home/ {pth} python'
MTAG = f'{runtime} run {pth}'
PREFIX = f'{runtime} exec {pth} python'
PREFIX_MOUNT = f'{runtime} exec --home={cwd}:/home/ {pth} python'
except FileNotFoundError:
try:
out = subprocess.run('docker')
Expand All @@ -43,7 +51,7 @@
'ghcr.io/comorment/mtag')
except FileNotFoundError as err:
# neither singularity nor docker found, fall back to plain python
mssg = 'Neither singularity nor docker found, tests will fail'
mssg = 'Neither singularity, apptainer nor docker found; tests fail'
raise FileNotFoundError(mssg) from err


Expand Down

0 comments on commit 0f71aa7

Please sign in to comment.