You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CONTRIBUTING.md
+32-41Lines changed: 32 additions & 41 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -77,77 +77,68 @@ Improvements to existing functionality are tracked as [GitHub issues using the U
77
77
The following tools are required:
78
78
79
79
-[git](https://git-scm.com)
80
-
-[python](https://www.python.org) (v3.8+)
80
+
-[python](https://www.python.org) (v3.11)
81
81
-[pip](https://pypi.org/project/pip/) (v23.0+)
82
82
83
+
You can setup your dev environment using `tox`, an environment orchestrator which allows for setting up environments for and invoking builds, unit tests, formatting, linting, etc. Install `tox` with:
84
+
85
+
```shell
86
+
pip install tox
87
+
```
88
+
89
+
If you want to manage your own virtual environment () instead of using `tox`, you can install model optimizer and all dependencies. Check out [installation](./README.md#installation) foir more details.
90
+
91
+
Before pushing changes to GitHub, you need to run the tests and coding style as shown below. They can be run individually as shown in each sub-section or can be run with the one command:
92
+
93
+
```shell
94
+
tox
95
+
```
96
+
83
97
### Unit tests
84
98
85
99
Unit tests are enforced by the CI system. When making changes, run the tests before pushing the changes to avoid CI issues. Running unit tests ensures your contributions do not break exiting code. We use [pytest](https://docs.pytest.org/) framework to run unit tests. The framework is setup to run all run all test_*.py or *_test.py in the [tests](./tests) directory.
86
100
87
101
Running unit tests is as simple as:
88
102
89
103
```sh
90
-
make test
104
+
tox -e unit
91
105
```
92
106
93
-
### Coding style
107
+
By default, all tests found within the tests directory are run. However, specific unit tests can run by passing filenames, classes and/or methods to `pytest` using `tox` positional arguments. The following example invokes a single test method `test_double_qmodel_prep_assert` that is declared in the `tests/models/test_qmodelprep.py` file:
94
108
95
-
#### Formatting
109
+
```shell
110
+
tox -e unit -- tests/models/test_qmodelprep.py::test_double_qmodel_prep_assert
111
+
```
112
+
113
+
### Coding style
96
114
97
-
FMS Model Optimizer follows the python[pep8](https://peps.python.org/pep-0008/) coding style. The coding style is enforced by the CI system, and your PR will fail until the style has been applied correctly.
115
+
FMS Model Optimizer follows the Python[pep8](https://peps.python.org/pep-0008/) coding style. The coding style is enforced by the CI system, and your PR will fail until the style has been applied correctly.
98
116
99
-
We use [pre-commit](https://pre-commit.com/) to enforce coding style using [black](https://github.com/psf/black), [prettier](https://github.com/prettier/prettier)and [isort](https://pycqa.github.io/isort/).
117
+
We use [pre-commit](https://pre-commit.com/) to enforce coding style using [black](https://github.com/psf/black), and [isort](https://pycqa.github.io/isort/).
100
118
101
119
You can invoke formatting with:
102
120
103
121
```sh
104
-
make fmt
122
+
tox -e fmt
105
123
```
106
124
107
-
You could optionally install the git pre-commit hooks if you would like to format the code automatically for each commit:
108
-
```
109
-
brew install pre-commit
125
+
You could optionally install the git [pre-commit hooks](https://pre-commit.com/) if you would like to format the code automatically for each commit:
126
+
127
+
```shell
128
+
pip install pre-commit
110
129
pre-commit install
111
130
```
112
131
113
-
#### Lint
114
-
115
-
In addition, we use [pylint](https://www.pylint.org) to perform static code analysis of the code for errors, coding standards, code convention and refactoring suggestions.
116
-
117
-
Pylint emits [messages](https://pylint.pycqa.org/en/latest/user_guide/messages/index.html) that provides explanations of the failed checks.
118
-
119
-
You should fix all message in the following order:
120
-
1. Fix each message provided. Select a message [description](https://pylint.pycqa.org/en/latest/user_guide/messages/messages_overview.html#messages-overview) to fix a message.
121
-
2. Disable a message (i.e: unbalanced-tuple-unpacking) caused by a particular line of code:
122
-
```python
123
-
a, b =...# pylint: disable=unbalanced-tuple-unpacking
124
-
```
125
-
Please see [here](https://pylint.pycqa.org/en/latest/user_guide/messages/message_control.html#block-disables) for the progma syntax.
126
-
127
-
3. Disable a checker globally. Please extend the `disable=`listin the [pylintrc](.pylintrc) file.
128
-
> Note: Disable checkers only if there is good reason.
132
+
In addition, we use [pylint](https://www.pylint.org/) to perform static code analysis of the code.
129
133
130
-
You can invoke the linting with the following command:
134
+
You can invoke the linting with the following command
131
135
132
-
```sh
133
-
make lint
134
-
```
135
-
136
-
### Build Wheel
137
-
138
-
To build a wheel file:
139
136
```shell
140
-
tox -e build
137
+
tox -e lint
141
138
```
142
-
Running the command will create a single ZIP-format archive containing the library source code with the .whl extension in the `dist/` directory.
143
-
144
139
## Your First Code Contribution
145
140
146
141
Unsure where to begin contributing? You can start by looking through these issues:
147
142
148
143
- Issues with the [`good first issue` label](https://github.com/foundation-model-stack/fms-model-optimizer/issues?q=is%3Aissue+is%3Aopen+label%3A%22good+first+issue%22) - these should only require a few lines of code and are good targets if you're just starting contributing.
149
144
- Issues with the [`help wanted` label](https://github.com/foundation-model-stack/fms-model-optimizer/issues?q=is%3Aissue+is%3Aopen+label%3A%22help+wanted%22) - these range from simple to more complex, but are generally things we want but can't get to in a short time frame.
150
-
151
-
<!--## Releasing (Maintainers only)
152
-
153
-
The responsibility for releasing new versions of the libraries falls to the maintainers. Releases will follow standard [semantic versioning](https://semver.org/) and be hosted on [pypi](https://pypi.org/project/jtd-to-proto/). -->
0 commit comments