Skip to content

Commit 43e56c5

Browse files
authored
Merge pull request #54 from togethercomputer/orangetin/pypi
Pypi push on github release creation
2 parents fb5b85b + d0849da commit 43e56c5

File tree

8 files changed

+873
-75
lines changed

8 files changed

+873
-75
lines changed

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
*Have you read the [Contributing Guidelines](https://github.com/togethercomputer/together/blob/main/CONTRIBUTING.md)?*
2+
3+
Issue #
4+
5+
## Describe your changes
6+
7+
*Clearly and concisely describe what's in this pull request. Include screenshots, if necessary.*

.github/workflows/check_code_quality.yml

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -26,30 +26,33 @@ jobs:
2626
runs-on: ${{ matrix.os }}
2727
steps:
2828
- uses: actions/checkout@v2
29-
- name: Setup Python ${{ matrix.python-version }}
30-
uses: actions/setup-python@v2
29+
- name: Set up Python ${{ matrix.python-version }}
30+
uses: actions/setup-python@v2.2.2
3131
with:
3232
python-version: ${{ matrix.python-version }}
33-
- name: Create and start a virtual environment
34-
run: |
35-
python -m venv venv
36-
source venv/bin/activate
33+
34+
- name: Install poetry
35+
run: curl -sSL https://install.python-poetry.org | python3 -
36+
37+
- name: Set up cache
38+
uses: actions/cache@v2.1.6
39+
with:
40+
path: .venv
41+
key: venv-${{ matrix.python-version }}-${{ hashFiles('pyproject.toml') }}-${{ hashFiles('poetry.lock') }}
42+
3743
- name: Install dependencies
3844
run: |
39-
source venv/bin/activate
40-
pip install --upgrade pip
41-
pip install .[quality]
42-
pip install .[tests]
45+
poetry config virtualenvs.in-project true
46+
poetry install --with quality,tests
47+
4348
- name: Check formatting with mypy
4449
run: |
45-
source venv/bin/activate
46-
pip install types-requests
47-
mypy --strict .
50+
poetry run mypy --strict .
51+
4852
- name: Check style with black
4953
run: |
50-
source venv/bin/activate
51-
black --check .
54+
poetry run black --check .
55+
5256
- name: Check style with ruff
5357
run: |
54-
source venv/bin/activate
55-
ruff .
58+
poetry run ruff .
Lines changed: 37 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,43 @@
1-
name: Upload to PyPI
1+
name: publish
22

33
on:
4-
workflow_dispatch:
5-
inputs:
6-
PYPI_API_TOKEN:
7-
required: true
8-
description: your API token on PyPI
4+
release:
5+
types: [published]
96

107
jobs:
11-
Upload-Library-to-PyPI:
8+
build:
129
runs-on: ubuntu-latest
10+
strategy:
11+
matrix:
12+
python-version: ["3.10"]
13+
1314
steps:
14-
- name: Check out repository code
15-
uses: actions/checkout@v2
16-
- name: To build the dist archives into the dist/ directory, first install build
17-
run: |
18-
python3 -m pip install --upgrade build
19-
- name: Then install twine
20-
run: |
21-
python3 -m pip install --upgrade twine
22-
- name: List files in the repository to check you have the .toml file
23-
run: |
24-
ls ${{ github.workspace }}
25-
- name: Use `python3 -m build` to build the dist archives run, You will see the `dist/` folder appear in the main directory of your repository
26-
run: |
27-
python3 -m build
28-
- name: Publish distribution 📦 to PyPI
29-
if: startsWith(github.ref, 'refs/tags')
30-
uses: pypa/gh-action-pypi-publish@release/v1
31-
with:
32-
password: ${{ github.event.inputs.PYPI_API_TOKEN }}
33-
15+
- uses: actions/checkout@v2
16+
- name: Set up Python ${{ matrix.python-version }}
17+
uses: actions/setup-python@v2.2.2
18+
with:
19+
python-version: ${{ matrix.python-version }}
20+
21+
- name: Install poetry
22+
run: make poetry-download
23+
24+
- name: Set up cache
25+
uses: actions/cache@v2.1.6
26+
with:
27+
path: .venv
28+
key: venv-${{ matrix.python-version }}-${{ hashFiles('pyproject.toml') }}-${{ hashFiles('poetry.lock') }}
29+
30+
- name: Install dependencies
31+
run: |
32+
poetry config virtualenvs.in-project true
33+
poetry install
34+
35+
- name: Build
36+
run: |
37+
poetry run python3 -m build
38+
39+
- name: Publish distribution to PyPI
40+
if: startsWith(github.ref, 'refs/tags')
41+
uses: pypa/gh-action-pypi-publish@release/v1
42+
with:
43+
password: ${{ secrets.PYPI_API_TOKEN }}

CONTRIBUTING.md

Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
# Contributing Guidelines
2+
3+
*Pull requests, bug reports, and all other forms of contribution are welcomed and highly encouraged!* :octocat:
4+
5+
### Contents
6+
7+
- [Code of Conduct](#book-code-of-conduct)
8+
- [Asking Questions](#bulb-asking-questions)
9+
- [Opening an Issue](#inbox_tray-opening-an-issue)
10+
- [Feature Requests](#love_letter-feature-requests)
11+
- [Triaging Issues](#mag-triaging-issues)
12+
- [Submitting Pull Requests](#repeat-submitting-pull-requests)
13+
- [Writing Commit Messages](#memo-writing-commit-messages)
14+
- [Code Review](#white_check_mark-code-review)
15+
- [Coding Style](#nail_care-coding-style)
16+
- [Certificate of Origin](#medal_sports-certificate-of-origin)
17+
18+
> **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.**
19+
20+
## Contributing Code
21+
22+
To contribute to this project, please follow the ["fork and pull request"](https://docs.github.com/en/get-started/quickstart/contributing-to-projects) workflow.
23+
Please do not try to push directly to this repo unless you are a maintainer.
24+
25+
Please follow the checked-in pull request template when opening pull requests. Note related issues and tag relevant
26+
maintainers.
27+
28+
Pull requests cannot land without passing the formatting, linting, and testing checks first. See [Testing](#testing) and
29+
[Formatting and Linting](#formatting-and-linting) for how to run these checks locally.
30+
31+
### Dependency Management: Poetry and other env/dependency managers
32+
33+
This project utilizes [Poetry](https://python-poetry.org/) v1.6.1+ as a dependency manager.
34+
35+
❗Note: *Before installing Poetry*, if you use `Conda`, create and activate a new Conda env (e.g. `conda create -n together python=3.10`)
36+
37+
Install Poetry: **[documentation on how to install it](https://python-poetry.org/docs/#installation)**.
38+
39+
❗Note: If you use `Conda` or `Pyenv` as your environment/package manager, after installing Poetry,
40+
tell Poetry to use the virtualenv python environment (`poetry config virtualenvs.prefer-active-python true`)
41+
42+
### Local Development Dependencies
43+
44+
Install Together development requirements (for running Together, running examples, linting, formatting, and tests):
45+
46+
```bash
47+
poetry install --with --with quality,tests
48+
```
49+
50+
### Formatting and Linting
51+
52+
Run these locally before submitting a PR; the CI system will check also.
53+
54+
```
55+
$ black .
56+
$ ruff --fix .
57+
$ mypy --strict .
58+
```
59+
60+
### Working with Optional Dependencies
61+
62+
If you're adding a new dependency to Together, assume that it will be an optional dependency, and
63+
that most users won't have it installed.
64+
65+
Users who do not have the dependency installed should be able to **import** your code without
66+
any side effects (no warnings, no errors, no exceptions).
67+
68+
To introduce the dependency to the pyproject.toml file correctly, please do the following:
69+
70+
1. Add the dependency to the main group as an optional dependency
71+
```bash
72+
poetry add --optional [package_name]
73+
```
74+
2. Open pyproject.toml and add the dependency to the `extended_testing` extra
75+
3. Relock the poetry file to update the extra.
76+
```bash
77+
poetry lock --no-update
78+
```
79+
4. Add a unit test that the very least attempts to import the new code. Ideally, the unit
80+
test makes use of lightweight fixtures to test the logic of the code.
81+
5. Please use the `@pytest.mark.requires(package_name)` decorator for any tests that require the dependency.
82+
83+
84+
## :repeat: Submitting Pull Requests
85+
86+
We **love** pull requests! Before [forking the repo](https://help.github.com/en/github/getting-started-with-github/fork-a-repo) and [creating a pull request](https://help.github.com/en/github/collaborating-with-issues-and-pull-requests/proposing-changes-to-your-work-with-pull-requests) 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.
87+
88+
For most contributions, after your first pull request is accepted and merged, you will be [invited to the project](https://help.github.com/en/github/setting-up-and-managing-your-github-user-account/inviting-collaborators-to-a-personal-repository) and given **push access**. :tada:
89+
90+
*Note: All contributions will be licensed under the project's license.*
91+
92+
- **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.
93+
94+
- **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!
95+
96+
- **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.
97+
98+
- **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.
99+
100+
- **Include test coverage.** Add unit tests or UI tests when possible. Follow existing patterns for implementing tests.
101+
102+
- **Update the example project** if one exists to exercise any new functionality you have added.
103+
104+
- **Add documentation.** Document your changes with code doc comments or in existing guides.
105+
106+
- **Update the CHANGELOG** for all enhancements and bug fixes. Include the corresponding issue number if one exists, and your GitHub username. (example: "- Fixed crash in profile view. #123 @orangetin")
107+
108+
- **Use the repo's default branch.** Branch from and [submit your pull request](https://help.github.com/en/github/collaborating-with-issues-and-pull-requests/creating-a-pull-request-from-a-fork) to the repo's default branch. Usually this is `main`, but it could be `dev`, `develop`, or `master`.
109+
110+
- **[Resolve any merge conflicts](https://help.github.com/en/github/collaborating-with-issues-and-pull-requests/resolving-a-merge-conflict-on-github)** that occur.
111+
112+
- **Promptly address any CI failures**. If your pull request fails to build or pass tests, please push another commit to fix it.
113+
114+
- When writing comments, use properly constructed sentences, including punctuation.
115+
116+
- Use spaces, not tabs.
117+
118+
119+
## :medal_sports: Certificate of Origin
120+
121+
*Developer's Certificate of Origin 1.1*
122+
123+
By making a contribution to this project, I certify that:
124+
125+
> 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
126+
> 1. 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
127+
> 1. The contribution was provided directly to me by some other person who certified (1), (2) or (3) and I have not modified it.
128+
> 1. 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.

0 commit comments

Comments
 (0)