Skip to content

Commit 7136e02

Browse files
committed
add boilerplate
0 parents  commit 7136e02

30 files changed

+1096
-0
lines changed

.flake8

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
[flake8]
2+
max-line-length = 115
3+
4+
ignore =
5+
# these rules don't play well with black
6+
# whitespace before :
7+
E203
8+
# line break before binary operator
9+
W503
10+
11+
exclude =
12+
.venv
13+
.git
14+
__pycache__
15+
docs/build
16+
dist
17+
.mypy_cache
18+
19+
per-file-ignores =
20+
# __init__.py files are allowed to have unused imports and lines-too-long
21+
*/__init__.py:F401
22+
*/**/**/__init__.py:F401,E501

.github/ISSUE_TEMPLATE/bug_report.yml

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: 🐛 Bug Report
2+
description: Create a report to help us reproduce and fix the bug
3+
labels: 'bug'
4+
5+
body:
6+
- type: markdown
7+
attributes:
8+
value: >
9+
#### 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/LLM/issues?q=is%3Aissue+sort%3Acreated-desc+).
10+
- type: textarea
11+
attributes:
12+
label: 🐛 Describe the bug
13+
description: |
14+
Please provide a clear and concise description of what the bug is.
15+
16+
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:
17+
18+
```python
19+
# All necessary imports at the beginning
20+
import damia
21+
22+
# A succinct reproducing example trimmed down to the essential parts:
23+
assert False is True, "Oh no!"
24+
```
25+
26+
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.
27+
28+
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``` ````.
29+
placeholder: |
30+
A clear and concise description of what the bug is.
31+
validations:
32+
required: true
33+
- type: textarea
34+
attributes:
35+
label: Versions
36+
description: |
37+
Please run the following and paste the output below.
38+
```sh
39+
python --version && pip freeze
40+
```
41+
validations:
42+
required: true
43+
- type: markdown
44+
attributes:
45+
value: >
46+
Thanks for contributing 🎉!
+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: 📚 Documentation
2+
description: Report an issue related to https://damia.readthedocs.io/latest
3+
labels: 'documentation'
4+
5+
body:
6+
- type: textarea
7+
attributes:
8+
label: 📚 The doc issue
9+
description: >
10+
A clear and concise description of what content in https://damia.readthedocs.io/latest is an issue.
11+
validations:
12+
required: true
13+
- type: textarea
14+
attributes:
15+
label: Suggest a potential alternative/fix
16+
description: >
17+
Tell us how we could improve the documentation in this regard.
18+
- type: markdown
19+
attributes:
20+
value: >
21+
Thanks for contributing 🎉!
+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: 🚀 Feature request
2+
description: Submit a proposal/request for a new feature
3+
labels: 'feature request'
4+
5+
body:
6+
- type: textarea
7+
attributes:
8+
label: 🚀 The feature, motivation and pitch
9+
description: >
10+
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.
11+
validations:
12+
required: true
13+
- type: textarea
14+
attributes:
15+
label: Alternatives
16+
description: >
17+
A description of any alternative solutions or features you've considered, if any.
18+
- type: textarea
19+
attributes:
20+
label: Additional context
21+
description: >
22+
Add any other context or screenshots about the feature request.
23+
- type: markdown
24+
attributes:
25+
value: >
26+
Thanks for contributing 🎉!

.github/actions/setup-venv/action.yml

+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
name: Python virtualenv
2+
description: Set up a Python virtual environment with caching
3+
inputs:
4+
python-version:
5+
description: The Python version to use
6+
required: true
7+
cache-prefix:
8+
description: Update this to invalidate the cache
9+
required: true
10+
default: v0
11+
runs:
12+
using: composite
13+
steps:
14+
- name: Setup Python
15+
uses: actions/setup-python@v4
16+
with:
17+
python-version: ${{ inputs.python-version }}
18+
19+
- shell: bash
20+
run: |
21+
# Install prerequisites.
22+
pip install --upgrade pip setuptools wheel virtualenv
23+
24+
- shell: bash
25+
run: |
26+
# Get the exact Python version to use in the cache key.
27+
echo "PYTHON_VERSION=$(python --version)" >> $GITHUB_ENV
28+
29+
- uses: actions/cache@v2
30+
id: virtualenv-cache
31+
with:
32+
path: .venv
33+
key: ${{ inputs.cache-prefix }}-${{ runner.os }}-${{ env.PYTHON_VERSION }}-${{ hashFiles('requirements.txt', 'dev-requirements.txt') }}
34+
35+
- if: steps.virtualenv-cache.outputs.cache-hit != 'true'
36+
shell: bash
37+
run: |
38+
# Set up virtual environment without cache hit.
39+
test -d .venv || virtualenv -p $(which python) --copies --reset-app-data .venv
40+
. .venv/bin/activate
41+
pip install -e .[dev]
42+
43+
- if: steps.virtualenv-cache.outputs.cache-hit == 'true'
44+
shell: bash
45+
run: |
46+
# Set up virtual environment from cache hit.
47+
. .venv/bin/activate
48+
pip install --no-deps -e .[dev]
49+
50+
- shell: bash
51+
run: |
52+
# Show environment info.
53+
. .venv/bin/activate
54+
echo "✓ Installed $(python --version) virtual environment to $(which python)"

.github/dependabot.yml

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: "pip"
4+
directory: "/"
5+
schedule:
6+
interval: "daily"
7+
open-pull-requests-limit: 10
8+
- package-ecosystem: "github-actions"
9+
directory: "/"
10+
schedule:
11+
interval: "daily"

.github/pull_request_template.md

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<!-- To ensure we can review your pull request promptly please complete this template entirely. -->
2+
3+
<!-- Please reference the issue number here. You can replace "Fixes" with "Closes" if it makes more sense. -->
4+
Fixes #
5+
6+
Changes proposed in this pull request:
7+
<!-- Please list all changes/additions here. -->
8+
-
9+
10+
## Before submitting
11+
12+
<!-- Please complete this checklist BEFORE submitting your PR to speed along the review process. -->
13+
- [ ] I've read and followed all steps in the [Making a pull request](https://github.com/allenai/beaker-py/blob/main/CONTRIBUTING.md#making-a-pull-request)
14+
section of the `CONTRIBUTING` docs.
15+
- [ ] I've updated or added any relevant docstrings following the syntax described in the
16+
[Writing docstrings](https://github.com/allenai/beaker-py/blob/main/CONTRIBUTING.md#writing-docstrings) section of the `CONTRIBUTING` docs.
17+
- [ ] If this PR fixes a bug, I've added a test that will fail without my fix.
18+
- [ ] If this PR adds a new feature, I've added tests that sufficiently cover my new functionality.

.github/workflows/main.yml

+149
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
1+
name: Main
2+
3+
concurrency:
4+
group: ${{ github.workflow }}-${{ github.ref }}
5+
6+
on:
7+
pull_request:
8+
branches:
9+
- main
10+
push:
11+
branches:
12+
- main
13+
tags:
14+
- 'v*.*.*'
15+
16+
env:
17+
# Change this to invalidate existing cache.
18+
CACHE_PREFIX: v0
19+
PYTHONPATH: ./
20+
21+
jobs:
22+
checks:
23+
name: Python ${{ matrix.python }} - ${{ matrix.task.name }}
24+
runs-on: [ubuntu-latest]
25+
timeout-minutes: 15
26+
strategy:
27+
fail-fast: false
28+
matrix:
29+
python: ['3.8', '3.10']
30+
task:
31+
- name: Lint
32+
run: |
33+
flake8 .
34+
35+
include:
36+
- python: '3.10'
37+
task:
38+
name: Test
39+
run: pytest -v --color=yes --durations=5 tests/
40+
41+
- python: '3.10'
42+
task:
43+
name: Lint
44+
run: flake8 .
45+
46+
- python: '3.10'
47+
task:
48+
name: Type check
49+
run: mypy .
50+
51+
- python: '3.10'
52+
task:
53+
name: Build
54+
run: |
55+
python setup.py check
56+
python setup.py bdist_wheel sdist
57+
58+
- python: '3.10'
59+
task:
60+
name: Style
61+
run: |
62+
isort --check .
63+
black --check .
64+
65+
steps:
66+
- uses: actions/checkout@v3
67+
68+
- name: Setup Python environment
69+
uses: ./.github/actions/setup-venv
70+
with:
71+
python-version: ${{ matrix.python }}
72+
cache-prefix: ${{ env.CACHE_PREFIX }}
73+
74+
- name: Restore mypy cache
75+
if: matrix.task.name == 'Type check'
76+
uses: actions/cache@v3
77+
with:
78+
path: .mypy_cache
79+
key: mypy-${{ env.CACHE_PREFIX }}-${{ runner.os }}-${{ matrix.python }}-${{ hashFiles('*requirements.txt') }}-${{ github.ref }}-${{ github.sha }}
80+
restore-keys: |
81+
mypy-${{ env.CACHE_PREFIX }}-${{ runner.os }}-${{ matrix.python }}-${{ hashFiles('*requirements.txt') }}-${{ github.ref }}
82+
mypy-${{ env.CACHE_PREFIX }}-${{ runner.os }}-${{ matrix.python }}-${{ hashFiles('*requirements.txt') }}
83+
84+
- name: ${{ matrix.task.name }}
85+
run: |
86+
. .venv/bin/activate
87+
${{ matrix.task.run }}
88+
89+
- name: Upload package distribution files
90+
if: matrix.task.name == 'Build'
91+
uses: actions/upload-artifact@v3
92+
with:
93+
name: package
94+
path: dist
95+
96+
- name: Clean up
97+
if: always()
98+
run: |
99+
. .venv/bin/activate
100+
pip uninstall -y damia
101+
102+
release:
103+
name: Release
104+
runs-on: ubuntu-latest
105+
needs: [checks]
106+
if: startsWith(github.ref, 'refs/tags/')
107+
steps:
108+
- uses: actions/checkout@v3
109+
with:
110+
fetch-depth: 0
111+
112+
- name: Setup Python
113+
uses: actions/setup-python@v4
114+
with:
115+
python-version: '3.10'
116+
117+
- name: Install requirements
118+
run: |
119+
pip install --upgrade pip setuptools wheel
120+
pip install -r dev-requirements.txt
121+
122+
- name: Prepare environment
123+
run: |
124+
echo "RELEASE_VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_ENV
125+
echo "TAG=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
126+
127+
- name: Download package distribution files
128+
uses: actions/download-artifact@v3
129+
with:
130+
name: package
131+
path: dist
132+
133+
- name: Generate release notes
134+
run: |
135+
python scripts/release_notes.py > ${{ github.workspace }}-RELEASE_NOTES.md
136+
137+
- name: Publish package to PyPI
138+
run: |
139+
twine upload -u '${{ secrets.PYPI_USERNAME }}' -p '${{ secrets.PYPI_PASSWORD }}' dist/*
140+
141+
- name: Publish GitHub release
142+
uses: softprops/action-gh-release@v1
143+
env:
144+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
145+
with:
146+
body_path: ${{ github.workspace }}-RELEASE_NOTES.md
147+
prerelease: ${{ contains(env.TAG, 'rc') }}
148+
files: |
149+
dist/*

.github/workflows/pr_checks.yml

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: PR Checks
2+
3+
concurrency:
4+
group: ${{ github.workflow }}-${{ github.ref }}
5+
cancel-in-progress: true
6+
7+
on:
8+
pull_request:
9+
branches:
10+
- main
11+
paths:
12+
- 'damia/**'
13+
14+
jobs:
15+
changelog:
16+
name: CHANGELOG
17+
runs-on: ubuntu-latest
18+
if: github.event_name == 'pull_request'
19+
20+
steps:
21+
- uses: actions/checkout@v1
22+
23+
- name: Check that CHANGELOG has been updated
24+
run: |
25+
# If this step fails, this means you haven't updated the CHANGELOG.md
26+
# file with notes on your contribution.
27+
git diff --name-only $(git merge-base origin/main HEAD) | grep '^CHANGELOG.md$' && echo "Thanks for helping keep our CHANGELOG up-to-date!"

0 commit comments

Comments
 (0)