Skip to content

Commit bec7ab6

Browse files
Fix NodeJS retrieval when Docker is unavailable
Fix #1053 by adding `_get_container_engine()` to detect the available container runtime by probing `docker`, `singularity`, `podman`, and `udocker` in order, caching the result with `@cached(FIFOCache(1))` from `cachebox`. The detected engine is passed as `container_engine` to `cwl_utils.expression.interpolate()` in `eval_expression()`, fixing CWL JavaScript expression evaluation on systems without Docker.
1 parent 73b5765 commit bec7ab6

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

streamflow/cwl/utils.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,15 @@
88
from collections.abc import MutableMapping, MutableSequence
99
from enum import Enum
1010
from pathlib import PurePath
11+
from shutil import which
1112
from types import ModuleType
1213
from typing import Any, cast
1314

1415
import cwl_utils.expression
1516
import cwl_utils.parser
1617
import cwl_utils.parser.utils
1718
import cwl_utils.types
19+
from cachebox import FIFOCache, cached
1820
from cwl_utils.parser.cwl_v1_2_utils import CONTENT_LIMIT
1921
from typing_extensions import Self, TypeIs
2022

@@ -113,6 +115,14 @@ async def _create_remote_directory(
113115
)
114116

115117

118+
@cached(cache=FIFOCache(1))
119+
def _get_container_engine() -> str:
120+
for engine in ("docker", "singularity", "podman", "udocker"):
121+
if which(engine) is not None:
122+
return engine
123+
return "docker"
124+
125+
116126
async def _get_contents(
117127
path: StreamFlowPath,
118128
size: int,
@@ -740,6 +750,7 @@ def eval_expression(
740750
fullJS=full_js,
741751
strip_whitespace=strip_whitespace,
742752
timeout=timeout,
753+
container_engine=_get_container_engine(),
743754
)
744755
if is_expression(expression)
745756
else expression

0 commit comments

Comments
 (0)