Skip to content

Commit e8bc88e

Browse files
Merge pull request #29 from hickeyma/doc/update-contrib-guide
doc: Update dev env section of the contributing guide
2 parents dce294e + 56a9e6b commit e8bc88e

File tree

1 file changed

+33
-41
lines changed

1 file changed

+33
-41
lines changed

CONTRIBUTING.md

Lines changed: 33 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -77,77 +77,69 @@ 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-
### 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:
8684

87-
Running unit tests is as simple as:
88-
89-
```sh
90-
make test
85+
```shell
86+
pip install tox
9187
```
9288

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

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

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+
```
9896

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
10098

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

103103
```sh
104-
make fmt
104+
tox -e unit
105105
```
106106

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
111111
```
112112

113-
#### Lint
113+
### Coding style
114114

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

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).
118118

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

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.
121+
```sh
122+
tox -e ruff
123+
```
129124

130-
You can invoke the linting with the 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:
131126

132-
```sh
133-
make lint
127+
```shell
128+
pip install pre-commit
129+
pre-commit install
134130
```
135131

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
137135

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

144140
## Your First Code Contribution
145141

146142
Unsure where to begin contributing? You can start by looking through these issues:
147143

148144
- 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.
149145
- 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)