Skip to content

Commit 744fb65

Browse files
committed
Fix apptainer workdir metadata
1 parent 4ab1331 commit 744fb65

File tree

4 files changed

+14
-26
lines changed

4 files changed

+14
-26
lines changed

setup.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,9 @@ def prerelease_local_scheme(version):
2424
# perform the install
2525
setup(
2626
name='girder-slicer-cli-web',
27-
# use_scm_version={
28-
# 'local_scheme': prerelease_local_scheme,
29-
# 'fallback_version': '0.0.0'},
30-
version='1.5.5',
27+
use_scm_version={
28+
'local_scheme': prerelease_local_scheme,
29+
'fallback_version': '0.0.0'},
3130
setup_requires=[
3231
'setuptools-scm',
3332
],

slicer_cli_web/singularity/slicer_cli_web_singularity/commands.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,13 @@ def singularity_pull(name: str, uri: str = 'docker'):
3030
return ['apptainer', 'pull', '--force', sif_name, f'{uri}://{name}']
3131

3232
@staticmethod
33-
def get_entry_path(imageName: str):
33+
def get_work_dir(imageName: str):
3434
switch_to_sif_image_folder()
3535
sif_name = generate_image_name_for_singularity(imageName)
36-
cmd = ['apptainer', 'exec', '--cleanenv', sif_name, 'cat', '/.singularity.d/labels.json']
36+
cmd = ['apptainer', 'sif', 'dump', '3', sif_name]
3737
label_json = run_command(cmd)
3838
labels = json.loads(label_json)
39-
return labels.get('entry_path')
39+
return labels.get('WorkingDir')
4040

4141
@staticmethod
4242
def singualrity_run(imageName: str, run_parameters=None, container_args=None):

slicer_cli_web/singularity/slicer_cli_web_singularity/girder_worker_plugin/direct_singularity_run.py

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -27,39 +27,28 @@ def __call__(self, *args, **kwargs):
2727
super().__call__(*args, **kwargs)
2828

2929

30-
def check_local_sif_image(image):
31-
"""
32-
Pulls the specified Plugin image (Ususally a docker image) onto the singularity container
33-
if the image is not present
34-
"""
35-
# Image path - Image path has to be present in tmp/images folder
36-
if not image:
37-
logger.write('Image name cannot be empty')
38-
return False
39-
# Just for testing. Change it later...
40-
return False
41-
42-
4330
@app.task(base=DirectSingularityTask, bind=True)
4431
def run(task, **kwargs):
4532
"""Wraps singularity_run to support running singularity containers"""
4633
image = kwargs['image']
4734
kwargs['image'] = generate_image_name_for_singularity(image)
48-
try:
49-
pwd = SingularityCommands.get_entry_path(image)
50-
kwargs['pwd'] = pwd
51-
except Exception as e:
52-
raise e
35+
36+
pwd = SingularityCommands.get_work_dir(image)
37+
kwargs['pwd'] = pwd
38+
5339
logs_dir = os.getenv('LOGS')
5440
kwargs['nvidia'] = _is_nvidia_img(image)
41+
5542
# Cahnge to reflect JOBID for logs later
5643
random_file_name = str(uuid4()) + 'logs.log'
5744
log_file_name = os.path.join(logs_dir, random_file_name)
5845
kwargs['log_file'] = log_file_name
46+
5947
# Create file since it doesn't exist
6048
if not os.path.exists(log_file_name):
6149
with open(log_file_name, 'x'):
6250
pass
51+
6352
file_obj = open(log_file_name, 'rb')
6453
if hasattr(task, 'job_manager'):
6554
stream_connectors = kwargs.setdefault('stream_connectors', [])

slicer_cli_web/singularity/slicer_cli_web_singularity/job.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ def get_local_singularity_output(imgName, cmdArg: str):
204204
function
205205
"""
206206
try:
207-
cwd = SingularityCommands.get_entry_path(imgName)
207+
cwd = SingularityCommands.get_work_dir(imgName)
208208
if not cwd:
209209
logger.exception('Please set the entry_path env variable on the Docker Image')
210210
raise Exception('Please set the entry_path env variable on the Docker Image')

0 commit comments

Comments
 (0)