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

[Tests] Ensure MyPy type checks pass #9284

Merged
merged 2 commits into from
Oct 14, 2021
Merged

Conversation

Mousius
Copy link
Member

@Mousius Mousius commented Oct 14, 2021

There's a few errors that come up when type checking that aren't triggering any failures:

Checking MyPy Type defs in the meta schedule package.
python/tvm/meta_schedule/utils.py:23:1: error: Cannot find implementation or library stub for module named "psutil"
python/tvm/meta_schedule/utils.py:23:1: note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports
python/tvm/meta_schedule/search_strategy/search_strategy.py: note: In member "__init__" of class "MeasureCandidate":
python/tvm/meta_schedule/search_strategy/search_strategy.py:59:13: error: Module has no attribute "MeasureCandidate"
python/tvm/meta_schedule/search_strategy/search_strategy.py: note: In member "initialize_with_tune_context" of class "SearchStrategy":
python/tvm/meta_schedule/search_strategy/search_strategy.py:83:9: error: Module has no attribute "SearchStrategyInitializeWithTuneContext"

To rectify this the types-psutil package adds type hints for mypy (will update later to remove the ignore on this once the docker image is rebuilt) and # type: ignore stops mypy from trying to figure out types of _ffi_api resources.

There's also a few places where variable type definitions are repeated even though they're only required once.

Finally, I've ensured task_mypy.sh fails the build since it's stable right now, using set -e.

There's a few errors that come up when type checking that aren't triggering any failures:
```
Checking MyPy Type defs in the meta schedule package.
python/tvm/meta_schedule/utils.py:23:1: error: Cannot find implementation or library stub for module named "psutil"
python/tvm/meta_schedule/utils.py:23:1: note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports
python/tvm/meta_schedule/search_strategy/search_strategy.py: note: In member "__init__" of class "MeasureCandidate":
python/tvm/meta_schedule/search_strategy/search_strategy.py:59:13: error: Module has no attribute "MeasureCandidate"
python/tvm/meta_schedule/search_strategy/search_strategy.py: note: In member "initialize_with_tune_context" of class "SearchStrategy":
python/tvm/meta_schedule/search_strategy/search_strategy.py:83:9: error: Module has no attribute "SearchStrategyInitializeWithTuneContext"
```

To rectify this the `types-psutil` package adds type hints for `mypy` and `# type: ignore` stops `mypy` from trying to figure out types of `_ffi_api` resources.

There's also a few places where variable type definitions are repeated even though they're only required once.

Finally, I've ensured `task_mypy.sh` fails the build since it's stable right now, using `set -e`.
Mousius added a commit to Mousius/tvm that referenced this pull request Oct 14, 2021
Spun out from apache#9284 as I think we need
to update the image to get this in?
@Mousius
Copy link
Member Author

Mousius commented Oct 14, 2021

cc @mikepapadim

@mikepapadim
Copy link
Contributor

LGMT, thanks @Mousius

@mikepapadim
Copy link
Contributor

cc @areusch

Copy link
Contributor

@areusch areusch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks @Mousius !

@jroesch jroesch merged commit 95a2031 into apache:main Oct 14, 2021
ylc pushed a commit to ylc/tvm that referenced this pull request Jan 7, 2022
* [Tests] Ensure MyPy type checks pass

There's a few errors that come up when type checking that aren't triggering any failures:
```
Checking MyPy Type defs in the meta schedule package.
python/tvm/meta_schedule/utils.py:23:1: error: Cannot find implementation or library stub for module named "psutil"
python/tvm/meta_schedule/utils.py:23:1: note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports
python/tvm/meta_schedule/search_strategy/search_strategy.py: note: In member "__init__" of class "MeasureCandidate":
python/tvm/meta_schedule/search_strategy/search_strategy.py:59:13: error: Module has no attribute "MeasureCandidate"
python/tvm/meta_schedule/search_strategy/search_strategy.py: note: In member "initialize_with_tune_context" of class "SearchStrategy":
python/tvm/meta_schedule/search_strategy/search_strategy.py:83:9: error: Module has no attribute "SearchStrategyInitializeWithTuneContext"
```

To rectify this the `types-psutil` package adds type hints for `mypy` and `# type: ignore` stops `mypy` from trying to figure out types of `_ffi_api` resources.

There's also a few places where variable type definitions are repeated even though they're only required once.

Finally, I've ensured `task_mypy.sh` fails the build since it's stable right now, using `set -e`.

* Add temporary # type : ignore for psutil
ylc pushed a commit to ylc/tvm that referenced this pull request Jan 13, 2022
* [Tests] Ensure MyPy type checks pass

There's a few errors that come up when type checking that aren't triggering any failures:
```
Checking MyPy Type defs in the meta schedule package.
python/tvm/meta_schedule/utils.py:23:1: error: Cannot find implementation or library stub for module named "psutil"
python/tvm/meta_schedule/utils.py:23:1: note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports
python/tvm/meta_schedule/search_strategy/search_strategy.py: note: In member "__init__" of class "MeasureCandidate":
python/tvm/meta_schedule/search_strategy/search_strategy.py:59:13: error: Module has no attribute "MeasureCandidate"
python/tvm/meta_schedule/search_strategy/search_strategy.py: note: In member "initialize_with_tune_context" of class "SearchStrategy":
python/tvm/meta_schedule/search_strategy/search_strategy.py:83:9: error: Module has no attribute "SearchStrategyInitializeWithTuneContext"
```

To rectify this the `types-psutil` package adds type hints for `mypy` and `# type: ignore` stops `mypy` from trying to figure out types of `_ffi_api` resources.

There's also a few places where variable type definitions are repeated even though they're only required once.

Finally, I've ensured `task_mypy.sh` fails the build since it's stable right now, using `set -e`.

* Add temporary # type : ignore for psutil
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants