Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix tests for when Apptainer/Singularity is available #8

Merged
merged 2 commits into from
Oct 1, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 14 additions & 6 deletions tests/test_mtag_container.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,20 @@
# Check that (1) singularity exist, and (2) if not, check for docker.
# If neither are found, tests will fall back to plain python.
try:
pth = os.path.join('containers', 'mtag.sif')
out = subprocess.run('singularity')
pth = os.path.join('apptainer', 'mtag.sif')
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 run {pth} python'
PREFIX_MOUNT = f'singularity run --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
Loading