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

fix: move onnxruntime import to function scope #204

Merged
merged 3 commits into from
Dec 1, 2022

Conversation

justinchuby
Copy link
Collaborator

@justinchuby justinchuby commented Nov 23, 2022

Move ort import into functions so onnx script still works without ort. This is also more friendly for new potential evaluators that do not require ORT.

fixes: #81

onnxscript/values.py Fixed Show resolved Hide resolved
@@ -7,19 +7,17 @@
import abc
import contextlib
import pprint
import typing

Check notice

Code scanning / CodeQL

Module is imported with 'import' and 'import from'

Module 'typing' is imported with both 'import' and 'import from'.

from onnxscript import autocast, irbuilder, onnx_opset, tensor, utils, values

if typing.TYPE_CHECKING:
import onnxruntime as ort
Copy link
Collaborator

Choose a reason for hiding this comment

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

Just wondering: why is this necessary?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is for type annotation (for _cache_models). ort will be imported by type checkers but not in run time, so we don't fail if the environment doesn't have ort.

@codecov
Copy link

codecov bot commented Dec 1, 2022

Codecov Report

Merging #204 (2ca3457) into main (769d3cb) will decrease coverage by 0.00%.
The diff coverage is 80.00%.

@@            Coverage Diff             @@
##             main     #204      +/-   ##
==========================================
- Coverage   75.50%   75.50%   -0.01%     
==========================================
  Files          89       89              
  Lines        7198     7201       +3     
==========================================
+ Hits         5435     5437       +2     
- Misses       1763     1764       +1     
Impacted Files Coverage Δ
onnxscript/values.py 87.42% <ø> (ø)
onnxscript/evaluator.py 91.61% <80.00%> (-0.46%) ⬇️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@justinchuby justinchuby merged commit b5389e2 into main Dec 1, 2022
@justinchuby justinchuby deleted the justinchu/evaluator branch December 1, 2022 00:50
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.

Avoid dependence on ort by default
2 participants