1# Development
2
3You will need to install protobuf and numpy to build ONNX. An easy
4way to get these dependencies is via [Anaconda](https://www.anaconda.com/download/):
5
6```
7# Use conda-forge protobuf, as defaults doesn't come with protoc
8conda install -c conda-forge protobuf numpy
9```
10
11During development, it's convenient to install ONNX in development mode (to disable ONNX-ML, set environment variable `ONNX_ML=0`):
12
13```
14git clone --recursive https://github.com/onnx/onnx.git
15pip install -e onnx/
16```
17Then, after you have made changes to Python and C++ files:
18
19- `Python files`: the changes are effective immediately in your installation. You don't need to install these again.
20- `C++ files`: you need to install these again to trigger the native extension build.
21
22## Folder structure
23
24- `onnx/`: the main folder that all code lies under
25  - `onnx.proto`: the protobuf (v2.6.1) that contains all the structures
26  - `checker.py`: a utility to check whether a serialized ONNX proto is legal
27  - `helper.py`: tools for graph operation
28  - `defs/`: a subfolder that defines the ONNX operators
29  - `test/`: test files
30
31## Generated operator documentation
32
33[Operator docs in Operators.md](Operators.md) are automatically generated based on C++ operator definitions. To refresh these docs, remember to re-install (see above) and then run the following command from the repo root and commit the results:
34
35```
36python onnx/defs/gen_doc.py
37```
38
39## Adding a new operator
40
41ONNX is an open standard, and we encourage developers to contribute high
42quality operators to ONNX specification.
43Before proposing a new operator, please read [the tutorial](AddNewOp.md).
44
45# Testing
46
47ONNX uses [pytest](https://docs.pytest.org) as a test driver. To run tests, you'll first need to install pytest:
48
49```
50pip install pytest nbval
51```
52
53After installing pytest, run
54
55```
56pytest
57```
58
59to begin the tests.
60
61# Static typing (mypy)
62
63We use [mypy](http://mypy-lang.org/) to run static type checks on the onnx code base. To check that your code passes, you'll first need to install the mypy type checker. If you're using python 3, call from your onnx source folder:
64
65```
66pip install -e .[mypy]
67```
68
69The type checker cannot run in a python 2 environment (but it will check python 2 code).
70If you're using python 2, you need to install mypy into your system packages instead:
71
72```
73pip3 install mypy==[version]
74```
75*Note: You'll find the version we're currently using in `setup.py`.*
76
77After having installed mypy, you can run the type checks:
78
79```
80python setup.py typecheck
81```
82
83
84# Other developer documentation
85
86* [How to implement ONNX backend (ONNX to something converter)](ImplementingAnOnnxBackend.md)
87* [Backend test infrastructure and how to add tests](OnnxBackendTest.md)
88
89# License
90
91[MIT License](LICENSE)
92
93# Code of Conduct
94
95[ONNX Open Source Code of Conduct](http://onnx.ai/codeofconduct.html)
96