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

[PYTHON] Enable proper error message in python package #7521

Merged
merged 1 commit into from
Feb 25, 2021
Merged
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
7 changes: 6 additions & 1 deletion python/tvm/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,11 @@
from .contrib import rocm as _rocm, nvcc as _nvcc, sdaccel as _sdaccel


# NOTE: This file should be python2 compatible so we can
# raise proper error message when user run the package using
# an older version of the python


def _should_print_backtrace():
in_pytest = "PYTEST_CURRENT_TEST" in os.environ
tvm_backtrace = os.environ.get("TVM_BACKTRACE", "0")
Expand All @@ -76,7 +81,7 @@ def _should_print_backtrace():
tvm_backtrace = bool(int(tvm_backtrace))
except ValueError:
raise ValueError(
f"invalid value for TVM_BACKTRACE `{tvm_backtrace}`, please set to 0 or 1."
"invalid value for TVM_BACKTRACE {}, please set to 0 or 1.".format(tvm_backtrace)
)

return in_pytest or tvm_backtrace
Expand Down