From c652dedca5deb9c495b2f5c6f0e9301b2ea09a99 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 26 Jul 2023 04:06:49 +0000 Subject: [PATCH 1/2] Bump mypy from 1.2.0 to 1.4.1 Bumps [mypy](https://github.com/python/mypy) from 1.2.0 to 1.4.1. - [Commits](https://github.com/python/mypy/compare/v1.2.0...v1.4.1) --- updated-dependencies: - dependency-name: mypy dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- requirements-dev.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements-dev.txt b/requirements-dev.txt index 0e89da9e83..5cd6193c43 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -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 From e50cba93e7e24ee5b63ed1e70ef0bcbb55ef2102 Mon Sep 17 00:00:00 2001 From: "Michael R. Crusoe" Date: Thu, 27 Jul 2023 11:34:35 +0200 Subject: [PATCH 2/2] fix types --- src/toil/lib/accelerators.py | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/src/toil/lib/accelerators.py b/src/toil/lib/accelerators.py index eab1d7f630..2c7f50c9c2 100644 --- a/src/toil/lib/accelerators.py +++ b/src/toil/lib/accelerators.py @@ -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 @@ -92,10 +92,21 @@ def count_nvidia_gpus() -> int: # # Some example output is here: 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