Skip to content

Commit fc781ee

Browse files
authored
v1.0.0 code changes (#71)
* WIP v0.3.0 * Update packages * Updates 02/21 * Linter * Clean up * Remove httpx dependency * Add new modules for chat * update self._client instances * function calling & json mode support! * fmt * fix typing in TogetherResponse * fix async client * Add embeddings client * ruff fmt * chore: async create function typings * Add finetune typing and abstract BaseModel to include extra="allow" * Bump version to v1.0.0 * Update finetuning classes * Fmt and fixes * Add filelock dependency * Refactor APIRequestor and add finetuning client * Init commit for Files/AsyncFiles class * Placeholder files for images and models endpoint * fmt * Mypy typing clean up * Add types-requests dependency * Update packages * Comments and fmting * Initial pytests * more formatting * Add pre-commit hook and update packages * Rename _*.py files to *.py * Add pdoc generated documentation * Update packages * Update contributing guide to include pdoc and pre-commit * Add Client/AsyncClient aliases to __init__.py * Update docs * Updates & rm docs * remove unused dependency * Add Makefile with formatting and tests; add new test workflows * fix test workflows -- remove unused input * fix #2 to workflow -- fix dependency group * remove editable install * fix client error type * update workflow comments and cancel policy * __future__ annotations for backward compat * Remove unions and optional typing hints * Add eval_type_backport package for typing backward compat * Extend python version coverage to 3.7.1 - 3.12 * remove 3.7.1 support -- incompatible dependencies * layer with-as statements for backward compatibility for python <3.10 * Add initial integration test * fmt * Add comments to types * Add comments * Add retries and better error handling logic * Fix tests -- remove top level requestor * Fix error type * Add more files methods, update url naming schema, remove multi-part download * Fix file downloads and integegration_tests * noqa for integration_test imports * Update Upload/DownloadManager, refactor request_raw calls, add file.upload * Fix tests -- bring back data_bytes encode post json data * Update client and file manager types * Initial CLI commits * Remove accidentally committed print log statements * Require keyword arguments over positional arguments for inputs * Tune api_key/base_url validation * Add Images class * Add Models class * Add more completions tests and tox * rename unit test workflow * Finish up CLI commands -- functionally finished * Add comments and update CLI --help * Update version to v0.3.0 * Lint + formatter * Update pre-commit-hook * Add files check command * Annotations futures for older python versions * Start updating README, contribution guide
1 parent 81f238b commit fc781ee

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

88 files changed

+6976
-5046
lines changed

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ Issue #
44

55
## Describe your changes
66

7-
*Clearly and concisely describe what's in this pull request. Include screenshots, if necessary.*
7+
*Clearly and concisely describe what's in this pull request. Include screenshots, if necessary.*
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
# An action for setting up poetry install with caching.
2+
# Using a custom action since the default action does not
3+
# take poetry install groups into account.
4+
# Action code from:
5+
# https://github.com/actions/setup-python/issues/505#issuecomment-1273013236
6+
name: poetry-install-with-caching
7+
description: Poetry install with support for caching of dependency groups.
8+
9+
inputs:
10+
python-version:
11+
description: Python version, supporting MAJOR.MINOR only
12+
required: true
13+
14+
poetry-version:
15+
description: Poetry version
16+
required: true
17+
18+
cache-key:
19+
description: Cache key to use for manual handling of caching
20+
required: true
21+
22+
working-directory:
23+
description: Directory whose poetry.lock file should be cached
24+
required: true
25+
26+
runs:
27+
using: composite
28+
steps:
29+
- uses: actions/setup-python@v5
30+
name: Setup python ${{ inputs.python-version }}
31+
id: setup-python
32+
with:
33+
python-version: ${{ inputs.python-version }}
34+
35+
- uses: actions/cache@v4
36+
id: cache-bin-poetry
37+
name: Cache Poetry binary - Python ${{ inputs.python-version }}
38+
env:
39+
SEGMENT_DOWNLOAD_TIMEOUT_MIN: "1"
40+
with:
41+
path: |
42+
/opt/pipx/venvs/poetry
43+
# This step caches the poetry installation, so make sure it's keyed on the poetry version as well.
44+
key: bin-poetry-${{ runner.os }}-${{ runner.arch }}-py-${{ inputs.python-version }}-${{ inputs.poetry-version }}
45+
46+
- name: Refresh shell hashtable and fixup softlinks
47+
if: steps.cache-bin-poetry.outputs.cache-hit == 'true'
48+
shell: bash
49+
env:
50+
POETRY_VERSION: ${{ inputs.poetry-version }}
51+
PYTHON_VERSION: ${{ inputs.python-version }}
52+
run: |
53+
set -eux
54+
55+
# Refresh the shell hashtable, to ensure correct `which` output.
56+
hash -r
57+
58+
# `actions/cache@v3` doesn't always seem able to correctly unpack softlinks.
59+
# Delete and recreate the softlinks pipx expects to have.
60+
rm /opt/pipx/venvs/poetry/bin/python
61+
cd /opt/pipx/venvs/poetry/bin
62+
ln -s "$(which "python$PYTHON_VERSION")" python
63+
chmod +x python
64+
cd /opt/pipx_bin/
65+
ln -s /opt/pipx/venvs/poetry/bin/poetry poetry
66+
chmod +x poetry
67+
68+
# Ensure everything got set up correctly.
69+
/opt/pipx/venvs/poetry/bin/python --version
70+
/opt/pipx_bin/poetry --version
71+
72+
- name: Install poetry
73+
if: steps.cache-bin-poetry.outputs.cache-hit != 'true'
74+
shell: bash
75+
env:
76+
POETRY_VERSION: ${{ inputs.poetry-version }}
77+
PYTHON_VERSION: ${{ inputs.python-version }}
78+
# Install poetry using the python version installed by setup-python step.
79+
run: pipx install "poetry==$POETRY_VERSION" --python '${{ steps.setup-python.outputs.python-path }}' --verbose
80+
81+
- name: Restore pip and poetry cached dependencies
82+
uses: actions/cache@v4
83+
env:
84+
SEGMENT_DOWNLOAD_TIMEOUT_MIN: "4"
85+
WORKDIR: ${{ inputs.working-directory == '' && '.' || inputs.working-directory }}
86+
with:
87+
path: |
88+
~/.cache/pip
89+
~/.cache/pypoetry/virtualenvs
90+
~/.cache/pypoetry/cache
91+
~/.cache/pypoetry/artifacts
92+
${{ env.WORKDIR }}/.venv
93+
key: py-deps-${{ runner.os }}-${{ runner.arch }}-py-${{ inputs.python-version }}-poetry-${{ inputs.poetry-version }}-${{ inputs.cache-key }}-${{ hashFiles(format('{0}/**/poetry.lock', env.WORKDIR)) }}
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
name: integration-tests
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
paths:
7+
- "**.py"
8+
9+
pull_request:
10+
branches: [ main ]
11+
paths:
12+
- "**.py"
13+
14+
concurrency:
15+
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
16+
cancel-in-progress: true
17+
18+
env:
19+
POETRY_VERSION: "1.7.1"
20+
21+
jobs:
22+
build:
23+
runs-on: ubuntu-latest
24+
strategy:
25+
matrix:
26+
python-version:
27+
- "3.8"
28+
- "3.9"
29+
- "3.10"
30+
- "3.11"
31+
- "3.12"
32+
name: "integration_test python v${{ matrix.python-version }}"
33+
steps:
34+
- uses: actions/checkout@v4
35+
36+
- name: Set up Python ${{ matrix.python-version }} + Poetry ${{ env.POETRY_VERSION }}
37+
uses: "./.github/actions/poetry_setup"
38+
with:
39+
python-version: ${{ matrix.python-version }}
40+
poetry-version: ${{ env.POETRY_VERSION }}
41+
cache-key: core
42+
43+
- name: Install dependencies
44+
shell: bash
45+
run: poetry install --with quality,tests
46+
47+
- name: Install together
48+
run: |
49+
poetry run pip install .
50+
51+
- name: Run integration tests
52+
shell: bash
53+
env:
54+
TOGETHER_API_KEY: ${{ secrets.TOGETHER_API_KEY }}
55+
run: |
56+
make integration_tests
57+
58+
- name: Check no new files were created
59+
shell: bash
60+
run: |
61+
set -eu
62+
63+
STATUS="$(git status)"
64+
echo "$STATUS"
65+
66+
# grep will exit non-zero if the target message isn't found,
67+
# and `set -e` above will cause the step to fail.
68+
echo "$STATUS" | grep 'nothing to commit, working tree clean'

.github/workflows/_tests.yml

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
name: unit-tests
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
paths:
7+
- "**.py"
8+
9+
pull_request:
10+
branches: [ main ]
11+
paths:
12+
- "**.py"
13+
14+
concurrency:
15+
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
16+
cancel-in-progress: true
17+
18+
env:
19+
POETRY_VERSION: "1.7.1"
20+
21+
jobs:
22+
build:
23+
runs-on: ubuntu-latest
24+
strategy:
25+
matrix:
26+
python-version:
27+
- "3.8"
28+
- "3.9"
29+
- "3.10"
30+
- "3.11"
31+
- "3.12"
32+
name: "unittest python v${{ matrix.python-version }}"
33+
steps:
34+
- uses: actions/checkout@v4
35+
36+
- name: Set up Python ${{ matrix.python-version }} + Poetry ${{ env.POETRY_VERSION }}
37+
uses: "./.github/actions/poetry_setup"
38+
with:
39+
python-version: ${{ matrix.python-version }}
40+
poetry-version: ${{ env.POETRY_VERSION }}
41+
cache-key: core
42+
43+
- name: Install dependencies
44+
shell: bash
45+
run: poetry install --with quality,tests
46+
47+
- name: Install together
48+
run: |
49+
poetry run pip install .
50+
51+
- name: Run core tests
52+
shell: bash
53+
run: |
54+
make test
55+
56+
- name: Check no new files were created
57+
shell: bash
58+
run: |
59+
set -eu
60+
61+
STATUS="$(git status)"
62+
echo "$STATUS"
63+
64+
# grep will exit non-zero if the target message isn't found,
65+
# and `set -e` above will cause the step to fail.
66+
echo "$STATUS" | grep 'nothing to commit, working tree clean'
Lines changed: 6 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: check_code_quality
1+
name: pre-commit
22

33
on:
44
push:
@@ -16,43 +16,10 @@ concurrency:
1616
cancel-in-progress: true
1717

1818
jobs:
19-
build:
20-
strategy:
21-
fail-fast: false
22-
matrix:
23-
python-version: ['3.10']
24-
os: [ubuntu-20.04]
25-
26-
runs-on: ${{ matrix.os }}
19+
pre-commit:
20+
runs-on: ubuntu-latest
2721
steps:
28-
- uses: actions/checkout@v2
29-
- name: Set up Python ${{ matrix.python-version }}
30-
uses: actions/[email protected]
31-
with:
32-
python-version: ${{ matrix.python-version }}
33-
34-
- name: Install poetry
35-
run: curl -sSL https://install.python-poetry.org | python3 -
36-
37-
- name: Set up cache
38-
uses: actions/[email protected]
39-
with:
40-
path: .venv
41-
key: venv-${{ matrix.python-version }}-${{ hashFiles('pyproject.toml') }}-${{ hashFiles('poetry.lock') }}
42-
43-
- name: Install dependencies
44-
run: |
45-
poetry config virtualenvs.in-project true
46-
poetry install --with quality,tests
47-
48-
- name: Check formatting with mypy
49-
run: |
50-
poetry run mypy --strict .
51-
52-
- name: Check style with black
53-
run: |
54-
poetry run black --check .
22+
- name: Checkout
23+
uses: actions/checkout@v3
5524

56-
- name: Check style with ruff
57-
run: |
58-
poetry run ruff .
25+
- uses: pre-commit/[email protected]

.github/workflows/rdme-docs.yml

Lines changed: 0 additions & 22 deletions
This file was deleted.

.pre-commit-config.yaml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
repos:
2+
- repo: https://github.com/pre-commit/pre-commit-hooks
3+
rev: v4.5.0
4+
hooks:
5+
- id: check-yaml
6+
- id: end-of-file-fixer
7+
- id: trailing-whitespace
8+
- id: check-docstring-first
9+
- id: check-merge-conflict
10+
- id: check-toml
11+
- repo: https://github.com/psf/black
12+
rev: 24.3.0
13+
hooks:
14+
- id: black
15+
- repo: https://github.com/astral-sh/ruff-pre-commit
16+
# Ruff version.
17+
rev: v0.3.2
18+
hooks:
19+
- id: ruff
20+
args: [ --fix ]
21+
# Run the formatter.
22+
- id: ruff-format
23+
- repo: https://github.com/pre-commit/mirrors-mypy
24+
rev: 'v1.8.0'
25+
hooks:
26+
- id: mypy
27+
args: [--strict]
28+
additional_dependencies: [types-requests, types-tqdm, types-tabulate, types-click, types-filelock, pydantic, aiohttp]
29+
exclude: ^tests/

0 commit comments

Comments
 (0)