Skip to content

Commit dc7fd2e

Browse files
committed
fix type errors discovered by mypyc
1 parent 393b698 commit dc7fd2e

File tree

3 files changed

+12
-11
lines changed

3 files changed

+12
-11
lines changed

cwltool/cuda.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import subprocess # nosec
44
import xml.dom.minidom # nosec
5+
from typing import Union
56

67
from .loghandler import _logger
78
from .utils import CWLObjectType
@@ -10,9 +11,9 @@
1011
def cuda_version_and_device_count() -> tuple[str, int]:
1112
"""Determine the CUDA version and number of attached CUDA GPUs."""
1213
try:
13-
out = subprocess.check_output(["nvidia-smi", "-q", "-x"]) # nosec
14+
out: Union[str, bytes] = subprocess.check_output(["nvidia-smi", "-q", "-x"]) # nosec
1415
except Exception as e:
15-
_logger.warning("Error checking CUDA version with nvidia-smi: %s", e)
16+
_logger.warning("Error checking CUDA version with nvidia-smi: %s", e, exc_info=e)
1617
return ("", 0)
1718
dm = xml.dom.minidom.parseString(out) # nosec
1819

@@ -62,5 +63,5 @@ def cuda_check(cuda_req: CWLObjectType, requestCount: int) -> int:
6263
return 0
6364
return requestCount
6465
except Exception as e:
65-
_logger.warning("Error checking CUDA requirements: %s", e)
66+
_logger.warning("Error checking CUDA requirements: %s", e, exc_info=e)
6667
return 0

cwltool/singularity_utils.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import os
44
import os.path
5-
from subprocess import DEVNULL, PIPE, Popen, TimeoutExpired # nosec
5+
import subprocess # nosec
66
from typing import Optional
77

88
_USERNS: Optional[bool] = None
@@ -14,17 +14,17 @@ def singularity_supports_userns() -> bool:
1414
if _USERNS is None:
1515
try:
1616
hello_image = os.path.join(os.path.dirname(__file__), "hello.simg")
17-
result = Popen( # nosec
17+
result = subprocess.run( # nosec
1818
["singularity", "exec", "--userns", hello_image, "true"],
19-
stderr=PIPE,
20-
stdout=DEVNULL,
21-
universal_newlines=True,
22-
).communicate(timeout=60)[1]
19+
capture_output=True,
20+
timeout=60,
21+
text=True,
22+
).stderr
2323
_USERNS = (
2424
"No valid /bin/sh" in result
2525
or "/bin/sh doesn't exist in container" in result
2626
or "executable file not found in" in result
2727
)
28-
except TimeoutExpired:
28+
except subprocess.TimeoutExpired:
2929
_USERNS = False
3030
return _USERNS

cwltool/workflow_job.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,7 @@ def object_from_state(
406406
("merge_nested" if len(connections) > 1 else None),
407407
),
408408
),
409-
valueFrom=cast(str, inp.get("valueFrom")),
409+
valueFrom=cast(Optional[str], inp.get("valueFrom")),
410410
):
411411
raise WorkflowException(
412412
"Type mismatch between source '%s' (%s) and "

0 commit comments

Comments
 (0)