|
1 | | -# How to Contribute |
| 1 | +# Contribute to Model Card Toolkit |
2 | 2 |
|
3 | | -We'd love to accept your patches and contributions to this project. There are |
4 | | -just a few small guidelines you need to follow. |
| 3 | +Model Card Toolkit can only grow through the contributions of this community. |
| 4 | +Thanks so much for your enthusiasm and your work—we appreciate everything you do! |
5 | 5 |
|
6 | | -## Contributor License Agreement |
| 6 | +There are many ways to contribute to Model Card Toolkit! You can contribute code, |
| 7 | +improve tests and API documentation, or create new end-to-end examples. Code |
| 8 | +contributions are not the only way to help the community. Proposing usability |
| 9 | +and design improvements, answering questions, and helping others are also |
| 10 | +immensely valuable. |
7 | 11 |
|
8 | | -Contributions to this project must be accompanied by a Contributor License |
9 | | -Agreement. You (or your employer) retain the copyright to your contribution; |
10 | | -this simply gives us permission to use and redistribute your contributions as |
11 | | -part of the project. Head over to <https://cla.developers.google.com/> to see |
12 | | -your current agreements on file or to sign a new one. |
| 12 | +It also helps us if you spread the word! Reference the library in blog posts |
| 13 | +about the awesome projects it made possible, shout out on social media every |
| 14 | +time it has helped you, or simply star the repository to say thank you. |
13 | 15 |
|
14 | | -You generally only need to submit a CLA once, so if you've already submitted one |
15 | | -(even if it was for a different project), you probably don't need to do it |
16 | | -again. |
| 16 | +For more ways to contribute, refer to GitHub's |
| 17 | +[guide to making open source contributions](https://opensource.guide/how-to-contribute/) |
17 | 18 |
|
18 | | -## Code reviews |
| 19 | +**However you choose to contribute, please follow |
| 20 | +[Google's Open Source Community Guidelines](https://opensource.google/conduct/).** |
| 21 | + |
| 22 | +*This guide was heavily inspired by other guides in the |
| 23 | +[Tensorflow GitHub organization](https://github.com/tensorflow) and the |
| 24 | +[🤗 Transformers guide to contributing](https://github.com/huggingface/transformers/blob/main/CONTRIBUTING.md).* |
| 25 | + |
| 26 | +## Contributing Code |
| 27 | + |
| 28 | +If you have improvements to Model Card Toolkit, send us your pull requests! |
| 29 | +Before writing any code, we strongly advise you to search through the existing |
| 30 | +[pull requests](https://github.com/tensorflow/model-card-toolkit/pulls) |
| 31 | +or [issues](https://github.com/tensorflow/model-card-toolkit/issues) to make sure |
| 32 | +nobody is already working on the same thing. |
| 33 | + |
| 34 | +If you would like to contribute code and are not sure where to start, take look |
| 35 | +at issues with the labels |
| 36 | +["good first issue"](https://github.com/tensorflow/model-card-toolkit/labels/good%20first%20issue) |
| 37 | +or ["contributions welcome"](https://github.com/tensorflow/model-card-toolkit/labels/stat%3Acontributions%20welcome). |
| 38 | + |
| 39 | +When you find an issue that you want to work on, please leave a comment so other |
| 40 | +people know you're working on it. If you need help or would prefer to work on the |
| 41 | +issue with others, you may use the issue comment thread ask questions or coordinate. |
| 42 | + |
| 43 | +### Code reviews |
19 | 44 |
|
20 | 45 | All submissions, including submissions by project members, require review. We |
21 | | -use GitHub pull requests for this purpose. Consult |
22 | | -[GitHub Help](https://help.github.com/articles/about-pull-requests/) for more |
23 | | -information on using pull requests. |
| 46 | +use GitHub pull requests for this purpose. For those just getting started, GitHub |
| 47 | +has a [pull requests guide](https://help.github.com/articles/using-pull-requests/). |
| 48 | + |
| 49 | +Before submitting your pull request for review, make sure your changes follow the |
| 50 | +Model Card Toolkit guidelines and coding style. Maintainers and other contributors |
| 51 | +will review your pull request. Please participate in the discussion and make the |
| 52 | +requested changes. |
| 53 | + |
| 54 | +### Contributor License Agreements |
| 55 | + |
| 56 | +We'd love to accept your patches! Before we can take them, we have to jump |
| 57 | +a couple of legal hurdles. |
| 58 | + |
| 59 | +Please fill out either the individual or corporate Contributor License Agreement (CLA). |
| 60 | + |
| 61 | +- If you are an individual writing original source code and you're sure you own the |
| 62 | + intellectual property, then you'll need to sign an |
| 63 | + [individual CLA](https://code.google.com/legal/individual-cla-v1.0.html). |
| 64 | +- If you work for a company that wants to allow you to contribute your work, then you'll |
| 65 | + need to sign a [corporate CLA](https://code.google.com/legal/corporate-cla-v1.0.html). |
| 66 | + |
| 67 | +Follow either of the two links above to access the appropriate CLA and instructions |
| 68 | +for how to sign and return it. Once we receive it, we'll be able to accept your pull |
| 69 | +requests. |
| 70 | + |
| 71 | +***NOTE***: Only original source code from you and other people that have signed the |
| 72 | +CLA can be accepted into the main repository. |
| 73 | + |
| 74 | +### Setting up a local development environment |
| 75 | + |
| 76 | +Follow these steps to install `model-card-toolkit`: |
| 77 | + |
| 78 | +1. Install [Bazel](https://bazel.build/install), which powers the protobuf stub |
| 79 | + code generation. Confirm that Bazel is installed and executable: |
| 80 | + |
| 81 | + ```sh |
| 82 | + bazel --version |
| 83 | + ``` |
| 84 | + |
| 85 | +2. Fork the [repository](https://github.com/tensorflow/model-card-toolkit) by |
| 86 | + clicking on the **[Fork](https://github.com/tensorflow/model-card-toolkit/fork)** |
| 87 | + button on the repository's page. This creates a copy of the code under your |
| 88 | + GitHub user account. |
| 89 | + |
| 90 | +3. Clone your fork to your local machine: |
| 91 | + |
| 92 | + ```sh |
| 93 | + git clone git@github.com:<your GitHub username>/model-card-toolkit.git |
| 94 | + cd model-card-toolkit |
| 95 | + ``` |
| 96 | + |
| 97 | +4. Create and activate a virtual environment: |
| 98 | + |
| 99 | + ```sh |
| 100 | + python3 -m venv env |
| 101 | + source env/bin/activate |
| 102 | + pip install --upgrade pip |
| 103 | + ``` |
| 104 | + |
| 105 | +5. Install the `model-card-toolkit` development package in editable mode: |
| 106 | + |
| 107 | + ```sh |
| 108 | + pip install -e ".[test]" |
| 109 | + ``` |
| 110 | + |
| 111 | + When you install the library in editable mode (with the `-e` flag), your local |
| 112 | + changes will be picked up without needing to re-install the library. |
| 113 | + |
| 114 | +### Re-generating protobuf stub code |
| 115 | + |
| 116 | +If you make changes to a `.proto` file, you should re-generate the |
| 117 | +protobuf stub code before using it. The command used to do this is |
| 118 | +automatically invoked once when you first install `model-card-toolkit` in |
| 119 | +editable mode, but further stub generation requires manual invocation. |
| 120 | + |
| 121 | +```sh |
| 122 | +bazel run //model_card_toolkit:move_generated_files |
| 123 | +``` |
| 124 | + |
| 125 | +### Licenses |
| 126 | + |
| 127 | +Include a license at the top of new files. |
| 128 | + |
| 129 | +- [Python license example](https://github.com/tensorflow/model-card-toolkit/blob/master/setup.py#L1) |
| 130 | +- [Bash license example](https://github.com/tensorflow/model-card-toolkit/blob/master/model_card_toolkit/move_generated_files.sh#L2) |
| 131 | + |
| 132 | +Bazel BUILD files also need to include a license section. See |
| 133 | +[BUILD example](https://github.com/tensorflow/model-card-toolkit/blob/master/model_card_toolkit/BUILD#L15). |
| 134 | + |
| 135 | +**Do not** include a license at the top of Jinja template files. |
| 136 | + |
| 137 | +### Python coding style |
| 138 | + |
| 139 | +Changes to Model Card Toolkit Python code should conform to the |
| 140 | +[Google Python Style Guide](https://github.com/google/styleguide/blob/gh-pages/pyguide.md) |
| 141 | +with indentation width of 2 spaces. |
| 142 | + |
| 143 | +### Testing your changes |
| 144 | + |
| 145 | +#### Writing and updating unit tests |
| 146 | + |
| 147 | +Include unit tests when you contribute new features, as they help to a) prove |
| 148 | +that your code works correctly, and b) guard against future breaking |
| 149 | +changes to lower maintenance costs. Bug fixes also generally require creating |
| 150 | +or updating unit tests, because the presence of bugs usually indicates insufficient |
| 151 | +test coverage. |
| 152 | + |
| 153 | +In general, all Python files have at least one corresponding test file. For example, |
| 154 | +`awesome.py` should have a corresponding `awesome_test.py`. |
| 155 | + |
| 156 | +#### Running unit tests |
| 157 | + |
| 158 | +To run a specific test suite, e.g. `ModelCardTest`, run its test file: |
| 159 | + |
| 160 | +```sh |
| 161 | +pytest model_card_toolkit/model_card_test.py |
| 162 | +``` |
24 | 163 |
|
25 | | -## Community Guidelines |
| 164 | +Use the following command to run all unit tests: |
26 | 165 |
|
27 | | -This project follows [Google's Open Source Community |
28 | | -Guidelines](https://opensource.google/conduct/). |
| 166 | +```sh |
| 167 | +pytest model_card_toolkit |
| 168 | +``` |
0 commit comments