First of all, thank you so much for contributing! 🎉 💯
This document contains guidelines on how to most effectively contribute within this repository.
If you are stuck, please feel free to ask any questions or ask for help.
This project is governed by our code of conduct. By participating, you are expected to uphold this code.
This project leverages development environments managed by a Python Poetry pyproject.toml
file.
We use pytest for testing and GitHub Actions for automated tests.
pre-commit
is used to help lint or format code.
A Conda environment is provided (via the file environment.yml
) for convenience but is not required for development purposes.
Perform the following steps to setup a Python development environment.
- Install Python (we recommend using
pyenv
or similar) - Install Poetry.
- Install package, e.g.
poetry install
Work added to this project is automatically checked using pre-commit via GitHub Actions. Pre-commit can work alongside your local git with git-hooks
After installing pre-commit within your development environment, the following command also can perform the same checks within your local development environment:
% pre-commit run --all-files
We use these same checks within our automated tests which are managed by GitHub Actions workflows. These automated tests generally must pass in order to merge work into this repository.
Work added to this project is automatically tested using pytest via GitHub Actions. Pytest is installed through the Poetry environment for this project. We recommend testing your work before opening pull requests with proposed changes.
Some tests require a special environment key to be set: OPENAI_API_KEY
.
This key is an openai.com API key tied to an account.
See here to make an OpenAI account and create an API key.
While the OPENAI_API_KEY
environment variable must be set to a value for the testing suite to complete, any non-whitespace value will do. It doesn't have to be a valid API key, since all tests that actually query the API with the key are skipped by default.
If you want to run tests that query the actual OpenAI API, you must specify a valid API key for OPENAI_API_KEY
. You can then execute pytest with the --runcost
option, e.g. poetry run pytest --runcost
, which will then use the specified key to run tests that query the API. Note that this will cost you money, typically around a cent or two per execution, depending on your choice of model. You can find detailed information about cost for each model per 1M tokens on the OpenAI API Pricing Page -- our test suite uses gpt-3.5-turbo
. The tests also take significantly longer than the non-live test suite to complete, so it's recommended to leave them disabled them unless you know you need to test the live API.
You can set this key as follows:
export OPENAI_API_KEY=ABCD1234
You can run pytest on your work using the following example:
% poetry run pytest
We welcome anyone to use GitHub issues (requires a GitHub login) or create pull requests (to directly make changes within this repository) to modify content found within this repository.
Specifically, there are several ways to suggest or make changes to this repository:
- Open a GitHub issue: https://github.com/manubot/manubot-ai-editor/issues
- Create a pull request from a forked branch of the repository
After you’ve decided to contribute code and have written it up, please file a pull request. We specifically follow a forked pull request model. Please create a fork of this repository, clone the fork, and then create a new, feature-specific branch. Once you make the necessary changes on this branch, you should file a pull request to incorporate your changes into this (fork upstream) repository.
The content and description of your pull request are directly related to the speed at which we are able to review, approve, and merge your contribution. To ensure an efficient review process please perform the following steps:
- Triple check that your pull request is adding one specific feature or additional group of content. Small, bite-sized pull requests move so much faster than large pull requests.
- After submitting your pull request, ensure that your contribution passes all status checks (e.g. passes all tests)
Pull request review and approval is required by at least one project maintainer to merge. We will do our best to review the code addition in a timely fashion. Ensuring that you follow all steps above will increase our speed and ability to review. We will check for accuracy, style, code coverage, and scope.
We use poetry-dynamic-versioning
to help version this software through PEP 440
standards.
Configuration for versioning is found within the pyproject.toml
file.
All builds for packages include dynamic version data to help label distinct versions of the software.
poetry-dynamic-versioning
uses git
tags to help distinguish version data.
We also use the __init__.py
file as a place to persist the version data for occaissions where the git
history is unavailable or unwanted.
The following command is used to add poetry-dynamic-versioning
to Poetry for use with this project: poetry self add "poetry-dynamic-versioning[plugin]"
.
Versioning for the project is intended to align with GitHub Releases which provide git
tag capabilities.
We publish source code by using GitHub Releases available here. We publish a related Python package through the Python Packaging Index (PyPI) available here.
Several manual and automated steps are involved with publishing manubot-ai-editor releases. See below for an overview of how this works.
Notes about semantic version (semver) specifications:
manubot-ai-editor version specifications are controlled through poetry-dynamic-versioning
which leverages dunamai
to create version data based on git tags and commits.
manubot-ai-editor release git tags are automatically applied through GitHub Releases and related inferred changes from release-drafter
.
- Open a pull request and use a repository label for
release-<semver release type>
to label the pull request for visibility withrelease-drafter
. - On merging the pull request for the release, a GitHub Actions workflow defined in
draft-release.yml
leveragingrelease-drafter
will draft a release for maintainers. - The draft GitHub release will include a version tag based on the GitHub PR label applied and
release-drafter
. - Make modifications as necessary to the draft GitHub release, then publish the release (the draft release does not require additional modifications by default).
- On publishing the GitHub release, another GitHub Actions workflow defined in
publish-pypi.yml
will run to build and deploy the Python package to PyPI (utilizing the earlier modifiedpyproject.toml
semantic version reference for labeling the release).