Skip to content
This repository was archived by the owner on Apr 14, 2026. It is now read-only.

Commit 95bacbd

Browse files
committed
2 parents be796bd + 23458c1 commit 95bacbd

1 file changed

Lines changed: 11 additions & 13 deletions

File tree

src/styxsingularity/__init__.py

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ def __init__(
5757
logger: logging.Logger,
5858
output_dir: pl.Path,
5959
metadata: Metadata,
60-
container_image: pl.Path,
60+
container_tag: str,
6161
singularity_executable: str,
6262
singularity_extra_args: list[str],
6363
environ: dict[str, str],
@@ -68,7 +68,7 @@ def __init__(
6868
self.input_file_next_id = 0
6969
self.output_dir = output_dir
7070
self.metadata = metadata
71-
self.container_image = container_image
71+
self.container_tag = container_tag
7272
self.singularity_executable = singularity_executable
7373
self.singularity_extra_args = singularity_extra_args
7474
self.environ = environ
@@ -151,7 +151,7 @@ def run(
151151
*self.singularity_extra_args,
152152
*mounts,
153153
*(["--env", environ_args_arg] if environ_args_arg else []),
154-
self.container_image.as_posix(),
154+
self.container_tag,
155155
"/bin/bash",
156156
"/styx_output/run.sh",
157157
]
@@ -189,7 +189,7 @@ class SingularityRunner(Runner):
189189

190190
def __init__(
191191
self,
192-
images: dict[str, str | pl.Path] | None = None,
192+
image_overrides: dict[str, str] | None = None,
193193
singularity_executable: str = "singularity",
194194
singularity_extra_args: list[str] | None = None,
195195
data_dir: InputPathType | None = None,
@@ -205,7 +205,7 @@ def __init__(
205205
self.data_dir = pl.Path(data_dir or "styx_tmp")
206206
self.uid = os.urandom(8).hex()
207207
self.execution_counter = 0
208-
self.images = images or {}
208+
self.image_overrides = image_overrides or {}
209209
self.singularity_executable = singularity_executable
210210
self.singularity_extra_args = singularity_extra_args or []
211211
self.environ = environ or {}
@@ -224,21 +224,19 @@ def start_execution(self, metadata: Metadata) -> Execution:
224224
"""Start execution."""
225225
if metadata.container_image_tag is None:
226226
raise ValueError("No container image tag specified in metadata")
227-
if (container_path := self.images.get(metadata.container_image_tag)) is None:
228-
raise ValueError(
229-
f"Container image path not found: {metadata.container_image_tag}. "
230-
f"Use `singularity pull docker://{metadata.container_image_tag} "
231-
f"[output file]` to download it and specify it in the `images` "
232-
f"argument of the runner."
233-
)
227+
container_tag = self.image_overrides.get(
228+
metadata.container_image_tag, metadata.container_image_tag
229+
)
230+
if not container_tag.startswith("docker://"):
231+
container_tag = f"docker://{container_tag}"
234232

235233
self.execution_counter += 1
236234
return _SingularityExecution(
237235
logger=self.logger,
238236
output_dir=self.data_dir
239237
/ f"{self.uid}_{self.execution_counter - 1}_{metadata.name}",
240238
metadata=metadata,
241-
container_image=pl.Path(container_path),
239+
container_tag=container_tag,
242240
singularity_executable=self.singularity_executable,
243241
singularity_extra_args=self.singularity_extra_args,
244242
environ=self.environ,

0 commit comments

Comments
 (0)