Commit ba01769
Move converter implementation files to _internal folder (#2738)
## Plan to Move Implementation Files to _internal
- [x] Analyze current imports and dependencies
- [x] Move implementation files to _internal:
- [x] Move converter.py to _internal/converter.py
- [x] Move evaluator.py to _internal/evaluator.py
- [x] Move irbuilder.py to _internal/irbuilder.py
- [x] Move main.py to _internal/main.py
- [x] Move type_annotation.py to _internal/type_annotation.py
- [x] Move values.py to _internal/values.py
- [x] Move corresponding test files to _internal:
- [x] Move converter_test.py to _internal/converter_test.py
- [x] Move evaluator_test.py to _internal/evaluator_test.py
- [x] Move type_annotation_test.py to _internal/type_annotation_test.py
- [x] Move values_test.py to _internal/values_test.py
- [x] Update __init__.py to import and re-export public API:
- [x] Export script, graph, export_onnx_lib from main.py
- [x] Export OnnxFunction, TracedOnnxFunction from values.py
- [x] Create public API shim files:
- [x] Create values.py shim
- [x] Create evaluator.py shim (removed * import, added explicit
exports)
- [x] Update all internal imports in moved files to use _internal
- [x] Update lintrunner configuration
- [x] Run lintrunner to ensure code style compliance
- [x] Run tests to verify everything works
## Summary
Successfully moved all implementation files (converter.py, evaluator.py,
irbuilder.py, main.py, type_annotation.py, values.py) and their
corresponding test files to the `_internal` folder.
### Key Changes:
1. **Moved files to _internal**: All implementation files now reside in
`onnxscript/_internal/`
2. **Created public API shims where needed**: Only `values.py` and
`evaluator.py` shims remain in the main `onnxscript/` directory to
re-export the public API from `_internal`
3. **Maintained backward compatibility**: All existing import patterns
continue to work
4. **Updated internal cross-references**: All imports within moved files
now reference `_internal` modules
5. **Updated lintrunner config**: Modified `.lintrunner.toml` to point
to new file locations
6. **Removed * imports**: Replaced wildcard import with explicit exports
in evaluator.py
7. **Simplified API surface**: Removed unnecessary `main.py` and
`type_annotation.py` shims
### Public API Exports:
- **onnxscript** (main module): script, graph, export_onnx_lib (imported
directly from `_internal.main` via `__init__.py`)
- **onnxscript.evaluator**: Evaluator, OnnxReferenceRuntimeEvaluator,
ORTEvaluator, ORTMixedEvaluator, default, default_as
- **onnxscript.values**: Opset, Op, OnnxFunction, TracedOnnxFunction,
and other value types
### Import Patterns:
Users should now import as follows:
- `from onnxscript import script, graph, export_onnx_lib` (recommended)
- `from onnxscript.values import Opset, Op` (still supported for
backward compatibility)
- `from onnxscript.evaluator import Evaluator, default_as` (still
supported for backward compatibility)
Internal code can access type_annotation utilities via `from
onnxscript._internal import type_annotation`.
<!-- START COPILOT ORIGINAL PROMPT -->
<details>
<summary>Original prompt</summary>
>
> ----
>
> *This section details on the original issue you should resolve*
>
> <issue_title>Make implementation files internal
(private)</issue_title>
> <issue_description>The implementation files for the onnxscript
converter should be moved into the _internal folder to clarify that
these are not public and that users should not take a dependence on the
implementation details.
>
> This likely includes files such as converter.py, evaluator.py,
irbuilder.py, main.py, type_annotation.py, and values.py, along with
corresponding test files.
>
> The main types intended to be made public should be imported from
these files and made public by the init.py file.</issue_description>
>
> ## Comments on the Issue (you are @copilot in this section)
>
> <comments>
> </comments>
>
</details>
<!-- START COPILOT CODING AGENT SUFFIX -->
- Fixes #2737
<!-- START COPILOT CODING AGENT TIPS -->
---
💡 You can make Copilot smarter by setting up custom instructions,
customizing its development environment and configuring Model Context
Protocol (MCP) servers. Learn more [Copilot coding agent
tips](https://gh.io/copilot-coding-agent-tips) in the docs.
---------
Signed-off-by: Justin Chu <[email protected]>
Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: gramalingam <[email protected]>
Co-authored-by: justinchuby <[email protected]>
Co-authored-by: Justin Chu <[email protected]>1 parent 20a99d1 commit ba01769
File tree
18 files changed
+1613
-1540
lines changed- onnxscript
- _internal
- backend
- tests/models
18 files changed
+1613
-1540
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
43 | | - | |
44 | | - | |
45 | | - | |
46 | | - | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
47 | 47 | | |
48 | 48 | | |
49 | 49 | | |
| |||
114 | 114 | | |
115 | 115 | | |
116 | 116 | | |
117 | | - | |
118 | 117 | | |
119 | | - | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
120 | 122 | | |
121 | 123 | | |
122 | 124 | | |
123 | | - | |
124 | | - | |
125 | 125 | | |
126 | 126 | | |
127 | 127 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
66 | 66 | | |
67 | 67 | | |
68 | 68 | | |
| 69 | + | |
69 | 70 | | |
70 | | - | |
71 | 71 | | |
72 | 72 | | |
73 | 73 | | |
| |||
128 | 128 | | |
129 | 129 | | |
130 | 130 | | |
131 | | - | |
| 131 | + | |
132 | 132 | | |
133 | 133 | | |
134 | 134 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
16 | | - | |
| 16 | + | |
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
| |||
Lines changed: 12 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
23 | | - | |
24 | | - | |
25 | | - | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
26 | 35 | | |
27 | 36 | | |
28 | 37 | | |
| |||
Lines changed: 2 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
26 | | - | |
| 26 | + | |
| 27 | + | |
27 | 28 | | |
28 | 29 | | |
29 | 30 | | |
| |||
0 commit comments