Skip to content

Commit cfb5675

Browse files
awoll-bdaiexploy-bot
authored andcommitted
Allow to specify directory where onnx test files are generated (#53)
# Pull Request ### What change is being made Make data directory for ONNX test files configurable. ### Why this change is being made Compatible with bazel gen rule. ### Tested Tested with genrule in core. GitOrigin-RevId: d95d322945e64e3f4cb4055de89045aac6da0f66
1 parent 8190fb6 commit cfb5675

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

control/test/testdata/test_onnx_generator.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import json
33
import logging
44
import os
5+
import sys
56

67
import onnx
78
import torch
@@ -382,7 +383,13 @@ def export_simple_model(data_dir: str):
382383

383384
def main():
384385
"""Main entry point for generating test ONNX model."""
385-
data_dir = os.path.dirname(os.path.abspath(__file__))
386+
if len(sys.argv) > 1:
387+
arg_path = os.path.abspath(sys.argv[1])
388+
data_dir = arg_path if os.path.isdir(arg_path) else os.path.dirname(arg_path)
389+
else:
390+
data_dir = os.path.dirname(os.path.abspath(__file__))
391+
392+
os.makedirs(data_dir, exist_ok=True)
386393

387394
export_simple_model(data_dir)
388395
export_model(data_dir)

0 commit comments

Comments
 (0)