Skip to content

Commit

Permalink
fix issue
Browse files Browse the repository at this point in the history
Signed-off-by: Xavier Dupre <[email protected]>
  • Loading branch information
xadupre committed Jun 26, 2024
1 parent d04099f commit ac25ae7
Showing 1 changed file with 8 additions and 14 deletions.
22 changes: 8 additions & 14 deletions onnxscript/backend/onnx_export_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,20 +173,14 @@ def extract_functions(name: str, content: str, test_folder: pathlib.Path):
stdout, stderr = subprocess.Popen( # pylint: disable=consider-using-with
[sys.executable, filename], stdout=subprocess.PIPE, stderr=subprocess.PIPE
).communicate()
if not stderr:
# The execution ran fine. So the error is somewhere else.
sys.path.insert(0, os.path.abspath(str(test_folder)))
mod = importlib.__import__(name)
del sys.path[0]
else:
raise AssertionError(
f"Unable to import {import_name!r} (e={e}) (file: {filename!r}, "
f"absolute path: {os.path.abspath(filename)!r}, "
f"current folder: {os.getcwd()}"
f")\n---- STDERR --\n{stderr.decode('utf-8', errors='ignore')}"
f"\n---- STDOUT --\n{stdout.decode('utf-8', errors='ignore')}"
f"\n---- CONTENT --\n{content}"
) from e
raise AssertionError(
f"Unable to import {import_name!r} (e={e}) (file: {filename!r}, "
f"absolute path: {os.path.abspath(filename)!r}, "
f"current folder: {os.getcwd()}"
f")\n---- STDERR --\n{stderr.decode('utf-8', errors='ignore')}"
f"\n---- STDOUT --\n{stdout.decode('utf-8', errors='ignore')}"
f"\n---- CONTENT --\n{content}"
) from e
functions = {
k: v for k, v in mod.__dict__.items() if isinstance(v, onnxscript.OnnxFunction)
}
Expand Down

0 comments on commit ac25ae7

Please sign in to comment.