Skip to content

Commit

Permalink
Bump mypy from 1.2.0 to 1.4.1 (#4548)
Browse files Browse the repository at this point in the history
* 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](python/mypy@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] <support@github.com>

* fix types

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Michael R. Crusoe <michael.crusoe@gmail.com>
  • Loading branch information
dependabot[bot] and mr-c authored Jul 27, 2023
1 parent a4f56b4 commit 1d09b45
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
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

0 comments on commit 1d09b45

Please sign in to comment.