generated from dtunai/Python-Template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 69171a0
Showing
45 changed files
with
1,867 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
.git | ||
.github | ||
.mypy_cache | ||
.pytest_cache | ||
.venv | ||
__pycache__ | ||
*.egg-info |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,168 @@ | ||
# Contributing | ||
|
||
Thanks for considering contributing! Please read this document to learn the various ways you can contribute to this project and how to go about doing it. | ||
|
||
## Bug reports and feature requests | ||
|
||
### Did you find a bug? | ||
|
||
First, do [a quick search](https://github.com/allenai/python-package-template/issues) to see whether your issue has already been reported. | ||
If your issue has already been reported, please comment on the existing issue. | ||
|
||
Otherwise, open [a new GitHub issue](https://github.com/allenai/python-package-template/issues). Be sure to include a clear title | ||
and description. The description should include as much relevant information as possible. The description should | ||
explain how to reproduce the erroneous behavior as well as the behavior you expect to see. Ideally you would include a | ||
code sample or an executable test case demonstrating the expected behavior. | ||
|
||
### Do you have a suggestion for an enhancement or new feature? | ||
|
||
We use GitHub issues to track feature requests. Before you create a feature request: | ||
|
||
* Make sure you have a clear idea of the enhancement you would like. If you have a vague idea, consider discussing | ||
it first on a GitHub issue. | ||
* Check the documentation to make sure your feature does not already exist. | ||
* Do [a quick search](https://github.com/allenai/python-package-template/issues) to see whether your feature has already been suggested. | ||
|
||
When creating your request, please: | ||
|
||
* Provide a clear title and description. | ||
* Explain why the enhancement would be useful. It may be helpful to highlight the feature in other libraries. | ||
* Include code examples to demonstrate how the enhancement would be used. | ||
|
||
## Making a pull request | ||
|
||
When you're ready to contribute code to address an open issue, please follow these guidelines to help us be able to review your pull request (PR) quickly. | ||
|
||
1. **Initial setup** (only do this once) | ||
|
||
<details><summary>Expand details 👇</summary><br/> | ||
|
||
If you haven't already done so, please [fork](https://help.github.com/en/enterprise/2.13/user/articles/fork-a-repo) this repository on GitHub. | ||
|
||
Then clone your fork locally with | ||
|
||
git clone https://github.com/USERNAME/python-package-template.git | ||
|
||
or | ||
|
||
git clone [email protected]:USERNAME/python-package-template.git | ||
|
||
At this point the local clone of your fork only knows that it came from *your* repo, github.com/USERNAME/python-package-template.git, but doesn't know anything the *main* repo, [https://github.com/allenai/python-package-template.git](https://github.com/allenai/python-package-template). You can see this by running | ||
|
||
git remote -v | ||
|
||
which will output something like this: | ||
|
||
origin https://github.com/USERNAME/python-package-template.git (fetch) | ||
origin https://github.com/USERNAME/python-package-template.git (push) | ||
|
||
This means that your local clone can only track changes from your fork, but not from the main repo, and so you won't be able to keep your fork up-to-date with the main repo over time. Therefore you'll need to add another "remote" to your clone that points to [https://github.com/allenai/python-package-template.git](https://github.com/allenai/python-package-template). To do this, run the following: | ||
|
||
git remote add upstream https://github.com/allenai/python-package-template.git | ||
|
||
Now if you do `git remote -v` again, you'll see | ||
|
||
origin https://github.com/USERNAME/python-package-template.git (fetch) | ||
origin https://github.com/USERNAME/python-package-template.git (push) | ||
upstream https://github.com/allenai/python-package-template.git (fetch) | ||
upstream https://github.com/allenai/python-package-template.git (push) | ||
|
||
Finally, you'll need to create a Python 3 virtual environment suitable for working on this project. There a number of tools out there that making working with virtual environments easier. | ||
The most direct way is with the [`venv` module](https://docs.python.org/3.7/library/venv.html) in the standard library, but if you're new to Python or you don't already have a recent Python 3 version installed on your machine, | ||
we recommend [Miniconda](https://docs.conda.io/en/latest/miniconda.html). | ||
|
||
On Mac, for example, you can install Miniconda with [Homebrew](https://brew.sh/): | ||
|
||
brew install miniconda | ||
|
||
Then you can create and activate a new Python environment by running: | ||
|
||
conda create -n xlstm-jax python=3.9 | ||
conda activate xlstm-jax | ||
|
||
Once your virtual environment is activated, you can install your local clone in "editable mode" with | ||
|
||
pip install -U pip setuptools wheel | ||
pip install -e .[dev] | ||
|
||
The "editable mode" comes from the `-e` argument to `pip`, and essential just creates a symbolic link from the site-packages directory of your virtual environment to the source code in your local clone. That way any changes you make will be immediately reflected in your virtual environment. | ||
|
||
</details> | ||
|
||
2. **Ensure your fork is up-to-date** | ||
|
||
<details><summary>Expand details 👇</summary><br/> | ||
|
||
Once you've added an "upstream" remote pointing to [https://github.com/allenai/python-package-temlate.git](https://github.com/allenai/python-package-template), keeping your fork up-to-date is easy: | ||
|
||
git checkout main # if not already on main | ||
git pull --rebase upstream main | ||
git push | ||
|
||
</details> | ||
|
||
3. **Create a new branch to work on your fix or enhancement** | ||
|
||
<details><summary>Expand details 👇</summary><br/> | ||
|
||
Committing directly to the main branch of your fork is not recommended. It will be easier to keep your fork clean if you work on a separate branch for each contribution you intend to make. | ||
|
||
You can create a new branch with | ||
|
||
# replace BRANCH with whatever name you want to give it | ||
git checkout -b BRANCH | ||
git push -u origin BRANCH | ||
|
||
</details> | ||
|
||
4. **Test your changes** | ||
|
||
<details><summary>Expand details 👇</summary><br/> | ||
|
||
Our continuous integration (CI) testing runs [a number of checks](https://github.com/allenai/python-package-template/actions) for each pull request on [GitHub Actions](https://github.com/features/actions). You can run most of these tests locally, which is something you should do *before* opening a PR to help speed up the review process and make it easier for us. | ||
|
||
First, you should run [`isort`](https://github.com/PyCQA/isort) and [`black`](https://github.com/psf/black) to make sure you code is formatted consistently. | ||
Many IDEs support code formatters as plugins, so you may be able to setup isort and black to run automatically everytime you save. | ||
For example, [`black.vim`](https://github.com/psf/black/tree/master/plugin) will give you this functionality in Vim. But both `isort` and `black` are also easy to run directly from the command line. | ||
Just run this from the root of your clone: | ||
|
||
isort . | ||
black . | ||
|
||
Our CI also uses [`ruff`](https://github.com/astral-sh/ruff) to lint the code base and [`mypy`](http://mypy-lang.org/) for type-checking. You should run both of these next with | ||
|
||
ruff check . | ||
|
||
and | ||
|
||
mypy . | ||
|
||
We also strive to maintain high test coverage, so most contributions should include additions to [the unit tests](https://github.com/allenai/python-package-template/tree/main/tests). These tests are run with [`pytest`](https://docs.pytest.org/en/latest/), which you can use to locally run any test modules that you've added or changed. | ||
|
||
For example, if you've fixed a bug in `xlstm_jax/a/b.py`, you can run the tests specific to that module with | ||
|
||
pytest -v tests/a/b_test.py | ||
|
||
If your contribution involves additions to any public part of the API, we require that you write docstrings | ||
for each function, method, class, or module that you add. | ||
See the [Writing docstrings](#writing-docstrings) section below for details on the syntax. | ||
You should test to make sure the API documentation can build without errors by running | ||
|
||
make docs | ||
|
||
If the build fails, it's most likely due to small formatting issues. If the error message isn't clear, feel free to comment on this in your pull request. | ||
|
||
And finally, please update the [CHANGELOG](https://github.com/allenai/python-package-template/blob/main/CHANGELOG.md) with notes on your contribution in the "Unreleased" section at the top. | ||
|
||
After all of the above checks have passed, you can now open [a new GitHub pull request](https://github.com/allenai/python-package-template/pulls). | ||
Make sure you have a clear description of the problem and the solution, and include a link to relevant issues. | ||
|
||
We look forward to reviewing your PR! | ||
|
||
</details> | ||
|
||
### Writing docstrings | ||
|
||
We use [Sphinx](https://www.sphinx-doc.org/en/master/index.html) to build our API docs, which automatically parses all docstrings | ||
of public classes and methods using the [autodoc](https://www.sphinx-doc.org/en/master/usage/extensions/autodoc.html) extension. | ||
Please refer to autoc's documentation to learn about the docstring syntax. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
name: 🐛 Bug Report | ||
description: Create a report to help us reproduce and fix the bug | ||
labels: 'bug' | ||
|
||
body: | ||
- type: markdown | ||
attributes: | ||
value: > | ||
#### Before submitting a bug, please make sure the issue hasn't been already addressed by searching through [the existing and past issues](https://github.com/allenai/python-package-template/issues?q=is%3Aissue+sort%3Acreated-desc+). | ||
- type: textarea | ||
attributes: | ||
label: 🐛 Describe the bug | ||
description: | | ||
Please provide a clear and concise description of what the bug is. | ||
If relevant, add a minimal example so that we can reproduce the error by running the code. It is very important for the snippet to be as succinct (minimal) as possible, so please take time to trim down any irrelevant code to help us debug efficiently. We are going to copy-paste your code and we expect to get the same result as you did: avoid any external data, and include the relevant imports, etc. For example: | ||
```python | ||
# All necessary imports at the beginning | ||
import xlstm_jax | ||
# A succinct reproducing example trimmed down to the essential parts: | ||
assert False is True, "Oh no!" | ||
``` | ||
If the code is too long (hopefully, it isn't), feel free to put it in a public gist and link it in the issue: https://gist.github.com. | ||
Please also paste or describe the results you observe instead of the expected results. If you observe an error, please paste the error message including the **full** traceback of the exception. It may be relevant to wrap error messages in ```` ```triple quotes blocks``` ````. | ||
placeholder: | | ||
A clear and concise description of what the bug is. | ||
validations: | ||
required: true | ||
- type: textarea | ||
attributes: | ||
label: Versions | ||
description: | | ||
Please run the following and paste the output below. | ||
```sh | ||
python --version && pip freeze | ||
``` | ||
validations: | ||
required: true | ||
- type: markdown | ||
attributes: | ||
value: > | ||
Thanks for contributing 🎉! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
name: 📚 Documentation | ||
description: Report an issue related to https://xlstm-jax.readthedocs.io/latest | ||
labels: 'documentation' | ||
|
||
body: | ||
- type: textarea | ||
attributes: | ||
label: 📚 The doc issue | ||
description: > | ||
A clear and concise description of what content in https://xlstm-jax.readthedocs.io/latest is an issue. | ||
validations: | ||
required: true | ||
- type: textarea | ||
attributes: | ||
label: Suggest a potential alternative/fix | ||
description: > | ||
Tell us how we could improve the documentation in this regard. | ||
- type: markdown | ||
attributes: | ||
value: > | ||
Thanks for contributing 🎉! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
name: 🚀 Feature request | ||
description: Submit a proposal/request for a new feature | ||
labels: 'feature request' | ||
|
||
body: | ||
- type: textarea | ||
attributes: | ||
label: 🚀 The feature, motivation and pitch | ||
description: > | ||
A clear and concise description of the feature proposal. Please outline the motivation for the proposal. Is your feature request related to a specific problem? e.g., *"I'm working on X and would like Y to be possible"*. If this is related to another GitHub issue, please link here too. | ||
validations: | ||
required: true | ||
- type: textarea | ||
attributes: | ||
label: Alternatives | ||
description: > | ||
A description of any alternative solutions or features you've considered, if any. | ||
- type: textarea | ||
attributes: | ||
label: Additional context | ||
description: > | ||
Add any other context or screenshots about the feature request. | ||
- type: markdown | ||
attributes: | ||
value: > | ||
Thanks for contributing 🎉! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
name: Python virtualenv | ||
description: Set up a Python virtual environment with caching | ||
inputs: | ||
python-version: | ||
description: The Python version to use | ||
required: true | ||
cache-prefix: | ||
description: Update this to invalidate the cache | ||
required: true | ||
default: v0 | ||
runs: | ||
using: composite | ||
steps: | ||
- name: Setup Python | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: ${{ inputs.python-version }} | ||
|
||
- shell: bash | ||
run: | | ||
# Install prerequisites. | ||
pip install --upgrade pip setuptools wheel virtualenv | ||
- shell: bash | ||
run: | | ||
# Get the exact Python version to use in the cache key. | ||
echo "PYTHON_VERSION=$(python --version)" >> $GITHUB_ENV | ||
- uses: actions/cache@v2 | ||
id: virtualenv-cache | ||
with: | ||
path: .venv | ||
key: ${{ inputs.cache-prefix }}-${{ runner.os }}-${{ env.PYTHON_VERSION }}-${{ hashFiles('pyproject.toml') }} | ||
|
||
- if: steps.virtualenv-cache.outputs.cache-hit != 'true' | ||
shell: bash | ||
run: | | ||
# Set up virtual environment without cache hit. | ||
test -d .venv || virtualenv -p $(which python) --copies --reset-app-data .venv | ||
. .venv/bin/activate | ||
pip install -e .[dev] | ||
- if: steps.virtualenv-cache.outputs.cache-hit == 'true' | ||
shell: bash | ||
run: | | ||
# Set up virtual environment from cache hit. | ||
. .venv/bin/activate | ||
pip install --no-deps -e .[dev] | ||
- shell: bash | ||
run: | | ||
# Show environment info. | ||
. .venv/bin/activate | ||
echo "✓ Installed $(python --version) virtual environment to $(which python)" | ||
echo "Packages:" | ||
pip freeze |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
version: 2 | ||
updates: | ||
- package-ecosystem: "pip" | ||
directory: "/" | ||
schedule: | ||
interval: "daily" | ||
open-pull-requests-limit: 10 | ||
- package-ecosystem: "github-actions" | ||
directory: "/" | ||
schedule: | ||
interval: "daily" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<!-- To ensure we can review your pull request promptly please complete this template entirely. --> | ||
|
||
<!-- Please reference the issue number here. You can replace "Fixes" with "Closes" if it makes more sense. --> | ||
Fixes # | ||
|
||
Changes proposed in this pull request: | ||
<!-- Please list all changes/additions here. --> | ||
- | ||
|
||
## Before submitting | ||
|
||
<!-- Please complete this checklist BEFORE submitting your PR to speed along the review process. --> | ||
- [ ] I've read and followed all steps in the [Making a pull request](https://github.com/allenai/python-package-template/blob/main/.github/CONTRIBUTING.md#making-a-pull-request) | ||
section of the `CONTRIBUTING` docs. | ||
- [ ] I've updated or added any relevant docstrings following the syntax described in the | ||
[Writing docstrings](https://github.com/allenai/python-package-template/blob/main/.github/CONTRIBUTING.md#writing-docstrings) section of the `CONTRIBUTING` docs. | ||
- [ ] If this PR fixes a bug, I've added a test that will fail without my fix. | ||
- [ ] If this PR adds a new feature, I've added tests that sufficiently cover my new functionality. |
Oops, something went wrong.