Skip to content

Latest commit

 

History

History
142 lines (91 loc) · 7.6 KB

CONTRIBUTING.md

File metadata and controls

142 lines (91 loc) · 7.6 KB

Contributing Guidelines

Pull requests, bug reports, and all other forms of contribution are welcomed and highly encouraged! :octocat:

Contents

This guide serves to set clear expectations for everyone involved with the project so that we can improve it together while also creating a welcoming space for everyone to participate. Following these guidelines will help ensure a positive experience for contributors and maintainers.

Contributing Code

To contribute to this project, please follow the "fork and pull request" workflow. Please do not try to push directly to this repo unless you are a maintainer.

Please follow the checked-in pull request template when opening pull requests. Note related issues and tag relevant maintainers.

Pull requests cannot land without passing the formatting, linting, and testing checks first. See Testing and Formatting and Linting for how to run these checks locally.

Dependency Management: Poetry and other env/dependency managers

This project utilizes Poetry v1.6.1+ as a dependency manager.

❗Note: Before installing Poetry, if you use Conda, create and activate a new Conda env (e.g. conda create -n together python=3.10)

Install Poetry: documentation on how to install it.

❗Note: If you use Conda or Pyenv as your environment/package manager, after installing Poetry, tell Poetry to use the virtualenv python environment (poetry config virtualenvs.prefer-active-python true)

Local Development Dependencies

Install Together development requirements (for running Together, running examples, linting, formatting, and tests):

poetry install --with quality,tests

And set up pre-commit for auto-formatting and linting

pre-commit install

Formatting and Linting

Run these locally before submitting a PR; the CI system will check also.

$ make format

Running tests

Unit Tests

make tests

Integration Tests

🚧 Warning: Integration Tests requires an API key to be exported and you will be charged for usage. It is recommended to let the CI system handle integration tests.

make integration_tests

Working with Optional Dependencies

If you're adding a new dependency to Together, assume that it will be an optional dependency, and that most users won't have it installed.

Users who do not have the dependency installed should be able to import your code without any side effects (no warnings, no errors, no exceptions).

To introduce the dependency to the pyproject.toml file correctly, please do the following:

  1. Add the dependency to the main group as an optional dependency
poetry add --optional [package_name]
  1. Open pyproject.toml and add the dependency to the extended_testing extra
  2. Relock the poetry file to update the extra.
poetry lock --no-update
  1. Add a unit test that the very least attempts to import the new code. Ideally, the unit test makes use of lightweight fixtures to test the logic of the code.
  2. Please use the @pytest.mark.requires(package_name) decorator for any tests that require the dependency.

🔁 Submitting Pull Requests

We love pull requests! Before forking the repo and creating a pull request for non-trivial changes, it is usually best to first open an issue to discuss the changes, or discuss your intended approach for solving the problem in the comments for an existing issue.

For most contributions, after your first pull request is accepted and merged, you will be invited to the project and given push access. 🎉

Note: All contributions will be licensed under the project's license.

  • Smaller is better. Submit one pull request per bug fix or feature. A pull request should contain isolated changes pertaining to a single bug fix or feature implementation. Do not refactor or reformat code that is unrelated to your change. It is better to submit many small pull requests rather than a single large one. Enormous pull requests will take enormous amounts of time to review, or may be rejected altogether.

  • Coordinate bigger changes. For large and non-trivial changes, open an issue to discuss a strategy with the maintainers. Otherwise, you risk doing a lot of work for nothing!

  • Prioritize understanding over cleverness. Write code clearly and concisely. Remember that source code usually gets written once and read often. Ensure the code is clear to the reader. The purpose and logic should be obvious to a reasonably skilled developer, otherwise you should add a comment that explains it.

  • Follow existing coding style and conventions. Keep your code consistent with the style, formatting, and conventions in the rest of the code base. When possible, these will be enforced with a linter. Consistency makes it easier to review and modify in the future.

  • Include test coverage. Add unit tests or integration tests when possible. Follow existing patterns for implementing tests.

  • Update the examples if one exists to exercise any new functionality you have added.

  • Add documentation. Document your changes with code doc comments or in existing guides.

  • Resolve any merge conflicts that occur.

  • Promptly address any CI failures. If your pull request fails to build or pass tests, please push another commit to fix it.

  • When writing comments, use properly constructed sentences, including punctuation.

  • Use spaces, not tabs.

🏅 Certificate of Origin

Developer's Certificate of Origin 1.1

By making a contribution to this project, I certify that:

  1. The contribution was created in whole or in part by me and I have the right to submit it under the open source license indicated in the file; or
  2. The contribution is based upon previous work that, to the best of my knowledge, is covered under an appropriate open source license and I have the right under that license to submit that work with modifications, whether created in whole or in part by me, under the same open source license (unless I am permitted to submit under a different license), as indicated in the file; or
  3. The contribution was provided directly to me by some other person who certified (1), (2) or (3) and I have not modified it.
  4. I understand and agree that this project and the contribution are public and that a record of the contribution (including all personal information I submit with it, including my sign-off) is maintained indefinitely and may be redistributed consistent with this project or the open source license(s) involved.