Skip to content

Commit 2348014

Browse files
authored
Wrap the package version check in a logger so it doesn't push exceptions to the execution console (#134) (#136)
* Wrap the package version check in a logger so it doesn't push exceptions to the execution console * make style
1 parent 286246a commit 2348014

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

src/sparsezoo/package.py

+11-6
Original file line numberDiff line numberDiff line change
@@ -77,18 +77,23 @@ def version_check_execution_condition(
7777
:param package_integration: package integration of the client
7878
"""
7979
if (
80-
os.getenv("NM_VERSION_CHECK") is None
81-
or os.getenv("NM_VERSION_CHECK").lower().strip() != "false"
80+
os.getenv("NM_VERSION_CHECK") is not None
81+
and os.getenv("NM_VERSION_CHECK").lower().strip() == "false"
8282
):
83+
LOGGER.info("Skipping Neural Magic's latest package version check")
84+
return
85+
86+
try:
8387
package_version_check_request(
8488
package_name=package_name,
8589
package_integration=package_integration,
8690
package_version=package_version,
8791
)
88-
else:
89-
LOGGER.info(
90-
"Skipping Neural Magic's internal code exection: "
91-
"latest package version check"
92+
except Exception as err:
93+
LOGGER.warning(
94+
"Neural Magic's latest package version check raised an exception. "
95+
"To turn off set the following in the environment NM_VERSION_CHECK=false "
96+
f"Exception: {err}"
9297
)
9398

9499

0 commit comments

Comments
 (0)