Skip to content

Commit 592590c

Browse files
committed
Update dev env section of the contributing guide
The `tox` environment has changed and the guide needed to be updated to be relevant. Signed-off-by: Martin Hickey <[email protected]>
1 parent e104c43 commit 592590c

File tree

1 file changed

+32
-41
lines changed

1 file changed

+32
-41
lines changed

CONTRIBUTING.md

Lines changed: 32 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -77,77 +77,68 @@ Improvements to existing functionality are tracked as [GitHub issues using the U
7777
The following tools are required:
7878

7979
- [git](https://git-scm.com)
80-
- [python](https://www.python.org) (v3.8+)
80+
- [python](https://www.python.org) (v3.11)
8181
- [pip](https://pypi.org/project/pip/) (v23.0+)
8282

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+
8397
### Unit tests
8498

8599
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.
86100

87101
Running unit tests is as simple as:
88102

89103
```sh
90-
make test
104+
tox -e unit
91105
```
92106

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:
94108

95-
#### Formatting
109+
```shell
110+
tox -e unit -- tests/models/test_qmodelprep.py::test_double_qmodel_prep_assert
111+
```
112+
113+
### Coding style
96114

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.
98116

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/).
100118

101119
You can invoke formatting with:
102120

103121
```sh
104-
make fmt
122+
tox -e fmt
105123
```
106124

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
110129
pre-commit install
111130
```
112131

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=` list in 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.
129133

130-
You can invoke the linting with the following command:
134+
You can invoke the linting with the following command
131135

132-
```sh
133-
make lint
134-
```
135-
136-
### Build Wheel
137-
138-
To build a wheel file:
139136
```shell
140-
tox -e build
137+
tox -e lint
141138
```
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-
144139
## Your First Code Contribution
145140

146141
Unsure where to begin contributing? You can start by looking through these issues:
147142

148143
- 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.
149144
- 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

Comments
 (0)