Skip to content

Commit

Permalink
Add github artifacts and cleanup
Browse files Browse the repository at this point in the history
Update typecheck directories

Add pre-commit config

Fix pre-commit failures
  • Loading branch information
benrules3 committed Jun 24, 2024
1 parent 72385df commit 3fba742
Show file tree
Hide file tree
Showing 15 changed files with 159 additions and 8 deletions.
30 changes: 30 additions & 0 deletions .github/workflows/formatting.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Formatting

on:
pull_request: {}
workflow_dispatch: {}

jobs:
build:
name: Formatting
runs-on: ubuntu-latest
strategy:
matrix:
python-version:
- 3.9

steps:
- uses: actions/checkout@v4

- uses: actions/setup-python@v4
id: setup_python
with:
python-version: ${{ matrix.python-version }}

- name: Upgrade pip & install requirements
run: |
pip install pre-commit
- name: Formatting
run: |
pre-commit run --all-files
64 changes: 64 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: "Test"

on:
push:
branches:
- "main"
paths:
# Always run when workflow configs change
- ".github/workflows/**"
# Run when package changes
- "**"
release:
types: [published]

pull_request:
branches:
- "main"
paths:
# Always run when workflow configs change
- ".github/workflows/**"
# Run when package changes
- "**"

workflow_dispatch: {}

jobs:

test_client:
runs-on: large

permissions:
contents: read
id-token: write

strategy:
matrix:
python-version:
- 3.9

steps:
- uses: actions/checkout@v4

- uses: actions/setup-python@v4
id: setup_python
with:
python-version: ${{ matrix.python-version }}
cache: "pip"
cache-dependency-path: |
poetry.lock
- name: Install dependencies (tests)
run: |
pip install pytest pytest-asyncio pytest-mock requests-mock
- name: Install dependencies
working-directory: .
run: |
pip install -e .
- name: Run tests
working-directory: .
run: |
echo $COHERE_API_KEY
pytest -sv tests/test_compass_client.py
35 changes: 35 additions & 0 deletions .github/workflows/typecheck.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Typecheck

on:
pull_request: {}
workflow_dispatch: {}

jobs:
typecheck:
runs-on: ubuntu-latest
strategy:
matrix:
python-version:
- 3.11
package:
- .
fail-fast: false

steps:
- uses: actions/checkout@v4

- uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
cache: "pip"
cache-dependency-path: |
${{ matrix.package }}/poetry.lock
- name: Install dependencies
working-directory: ${{ matrix.package }}
run: |
pip install -e .
- uses: jakebailey/pyright-action@v2
with:
working-directory: ${{ matrix.package }}
16 changes: 16 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
repos:
- repo: https://github.com/pycqa/isort
rev: "5.13.2"
hooks:
- id: isort
args: ["--profile", "black", "--filter-files", "--line-length", "120", "--py", "39"]
- repo: https://github.com/psf/black
rev: "24.4.0"
hooks:
- id: black
args: ["--line-length=120", "--target-version=py39"]
- repo: https://github.com/pycqa/autoflake
rev: "v2.3.1"
hooks:
- id: autoflake
args: ["--in-place", "--remove-all-unused-imports", "--expand-star-imports", "--ignore-init-module-imports", "-r"]
1 change: 1 addition & 0 deletions CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* @cohere-ai/compass
5 changes: 3 additions & 2 deletions compass_sdk/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
from os import getenv
from typing import Any, Callable, Dict, List, Optional, Union

from pydantic import BaseModel
from typing_extensions import TypedDict

from compass_sdk.constants import (
COHERE_API_ENV_VAR,
DEFAULT_COMMANDR_EXTRACTABLE_ATTRIBUTES,
Expand All @@ -16,8 +19,6 @@
METADATA_HEURISTICS_ATTRIBUTES,
SKIP_INFER_TABLE_TYPES,
)
from pydantic import BaseModel
from typing_extensions import TypedDict


class Logger:
Expand Down
Binary file removed compass_sdk/__pycache__/__init__.cpython-311.pyc
Binary file not shown.
Binary file removed compass_sdk/__pycache__/compass.cpython-311.pyc
Binary file not shown.
Binary file removed compass_sdk/__pycache__/constants.cpython-311.pyc
Binary file not shown.
Binary file removed compass_sdk/__pycache__/parser.cpython-311.pyc
Binary file not shown.
Binary file removed compass_sdk/__pycache__/utils.cpython-311.pyc
Binary file not shown.
11 changes: 6 additions & 5 deletions compass_sdk/compass.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@
from typing import Dict, Iterator, List, Optional, Tuple, Union

import requests
from joblib import Parallel, delayed
from pydantic import BaseModel
from requests.exceptions import InvalidSchema
from tenacity import RetryError, retry, retry_if_not_exception_type, stop_after_attempt, wait_fixed
from tqdm import tqdm

from compass_sdk import (
BatchPutDocumentsInput,
Chunk,
Expand All @@ -25,11 +31,6 @@
DEFAULT_MAX_RETRIES,
DEFAULT_SLEEP_RETRY_SECONDS,
)
from joblib import Parallel, delayed
from pydantic import BaseModel
from requests.exceptions import InvalidSchema
from tenacity import RetryError, retry, retry_if_not_exception_type, stop_after_attempt, wait_fixed
from tqdm import tqdm


@dataclass
Expand Down
1 change: 1 addition & 0 deletions compass_sdk/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from typing import Any, Callable, Dict, Iterable, List, Optional, Union

import requests

from compass_sdk import (
BatchProcessFilesParameters,
CompassDocument,
Expand Down
3 changes: 2 additions & 1 deletion compass_sdk/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@
from typing import Callable, Iterable, Iterator, List, Optional, TypeVar

import fsspec
from compass_sdk import CompassDocument, CompassDocumentMetadata, CompassSdkStage
from fsspec import AbstractFileSystem

from compass_sdk import CompassDocument, CompassDocumentMetadata, CompassSdkStage

T = TypeVar("T")
U = TypeVar("U")

Expand Down
1 change: 1 addition & 0 deletions tests/test_parser_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from typing import List

import pytest

from compass_sdk import (
CompassDocumentMetadata,
MetadataConfig,
Expand Down

0 comments on commit 3fba742

Please sign in to comment.