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
+33-41Lines changed: 33 additions & 41 deletions
Original file line number
Diff line number
Diff line change
@@ -77,77 +77,69 @@ 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
-
### Unit tests
84
-
85
-
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.
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:
86
84
87
-
Running unit tests is as simple as:
88
-
89
-
```sh
90
-
make test
85
+
```shell
86
+
pip install tox
91
87
```
92
88
93
-
### Coding style
89
+
If you want to manage your own virtual environment instead of using `tox`, you can install the model optimizer and all dependencies. Check out [installation](./README.md#installation) for more details.
94
90
95
-
#### Formatting
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:
96
92
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.
93
+
```shell
94
+
tox
95
+
```
98
96
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/).
97
+
### Unit tests
100
98
101
-
You can invoke formatting with:
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.
100
+
101
+
Running unit tests is as simple as:
102
102
103
103
```sh
104
-
make fmt
104
+
tox -e unit
105
105
```
106
106
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
110
-
pre-commit install
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:
108
+
109
+
```shell
110
+
tox -e unit -- tests/models/test_qmodelprep.py::test_double_qmodel_prep_assert
111
111
```
112
112
113
-
#### Lint
113
+
###Coding style
114
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.
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.
116
116
117
-
Pylint emits [messages](https://pylint.pycqa.org/en/latest/user_guide/messages/index.html) that provides explanations of the failed checks.
117
+
We use [Ruff](https://docs.astral.sh/ruff/) to enforce coding style using [Black](https://github.com/psf/black), [isort](https://pycqa.github.io/isort/), and [Flake8](https://docs.astral.sh/ruff/faq/#how-does-ruffs-linter-compare-to-flake8).
118
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.
119
+
You can invoke Ruff with:
126
120
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.
121
+
```sh
122
+
tox -e ruff
123
+
```
129
124
130
-
You can invoke the linting withthe following command:
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:
131
126
132
-
```sh
133
-
make lint
127
+
```shell
128
+
pip install pre-commit
129
+
pre-commit install
134
130
```
135
131
136
-
### Build Wheel
132
+
In addition, we use [pylint](https://www.pylint.org/) to perform static code analysis of the code.
133
+
134
+
You can invoke the linting with the following command
137
135
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
139
144
140
## Your First Code Contribution
145
141
146
142
Unsure where to begin contributing? You can start by looking through these issues:
147
143
148
144
- 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
145
- 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