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

Bump mypy from 1.2.0 to 1.4.1 #4548

Merged
merged 2 commits into from
Jul 27, 2023
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ sphinx-autoapi
sphinx-autodoc-typehints
sphinxcontrib-autoprogram
cwltest>=2.2.20211116163652
mypy==1.2.0
mypy==1.4.1
types-requests
types-setuptools
types-boto
Expand Down
21 changes: 16 additions & 5 deletions src/toil/lib/accelerators.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

import os
import subprocess
from typing import Dict, List, Optional, Set, Union
from typing import Dict, List, Optional, Set, Union, cast
from xml.dom import minidom

from toil.job import AcceleratorRequirement
Expand Down Expand Up @@ -92,10 +92,21 @@ def count_nvidia_gpus() -> int:
# <https://github.com/common-workflow-language/cwltool/blob/6f29c59fb1b5426ef6f2891605e8fa2d08f1a8da/cwltool/cuda.py>
# Some example output is here: <https://gist.github.com/loretoparisi/2620b777562c2dfd50d6b618b5f20867>
try:
return int(minidom.parseString(
subprocess.check_output(["nvidia-smi", "-q", "-x"])
).getElementsByTagName("attached_gpus")[0].firstChild.data)
except (FileNotFoundError, subprocess.CalledProcessError, IndexError, ValueError, PermissionError):
return int(
cast(
minidom.Text,
minidom.parseString(subprocess.check_output(["nvidia-smi", "-q", "-x"]))
.getElementsByTagName("attached_gpus")[0]
.firstChild,
).data
)
except (
FileNotFoundError,
subprocess.CalledProcessError,
IndexError,
ValueError,
PermissionError,
):
return 0

# TODO: Parse each gpu > product_name > text content and convert to some
Expand Down