Skip to content

Commit

Permalink
fix: CI lint and test issues (#102)
Browse files Browse the repository at this point in the history
* fix: CI problems

- [x] Update ruff to match CI and apply fmt
- [x] bump timeouts
- [x] fix openapi client
  • Loading branch information
bjchambers authored Mar 1, 2024
1 parent a89dc1b commit a0a280c
Show file tree
Hide file tree
Showing 13 changed files with 287 additions and 85 deletions.
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ jobs:
run: poetry run pytest -v
env:
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
PYTEST_TIMEOUT: 120
- name: check openapi client up to date
run: |
poetry run poe extract-openapi
Expand Down
3 changes: 2 additions & 1 deletion dewy-client/dewy_client/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
""" A client library for accessing Dewy Knowledge Base API """
"""A client library for accessing Dewy Knowledge Base API"""

from .client import AuthenticatedClient, Client

__all__ = (
Expand Down
2 changes: 1 addition & 1 deletion dewy-client/dewy_client/api/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
""" Contains methods for accessing the API """
"""Contains methods for accessing the API"""
8 changes: 4 additions & 4 deletions dewy-client/dewy_client/api/kb/add_document.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def sync_detailed(
) -> Response[Union[Document, HTTPValidationError]]:
"""Add Document
Add a document from a URL.
Add a document to a collection.
Args:
body (AddDocumentRequest):
Expand Down Expand Up @@ -97,7 +97,7 @@ def sync(
) -> Optional[Union[Document, HTTPValidationError]]:
"""Add Document
Add a document from a URL.
Add a document to a collection.
Args:
body (AddDocumentRequest):
Expand All @@ -123,7 +123,7 @@ async def asyncio_detailed(
) -> Response[Union[Document, HTTPValidationError]]:
"""Add Document
Add a document from a URL.
Add a document to a collection.
Args:
body (AddDocumentRequest):
Expand Down Expand Up @@ -152,7 +152,7 @@ async def asyncio(
) -> Optional[Union[Document, HTTPValidationError]]:
"""Add Document
Add a document from a URL.
Add a document to a collection.
Args:
body (AddDocumentRequest):
Expand Down
2 changes: 1 addition & 1 deletion dewy-client/dewy_client/errors.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
""" Contains shared errors types that can be raised from API functions """
"""Contains shared errors types that can be raised from API functions"""


class UnexpectedStatus(Exception):
Expand Down
2 changes: 1 addition & 1 deletion dewy-client/dewy_client/models/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
""" Contains all the data models used in inputs/outputs """
"""Contains all the data models used in inputs/outputs"""

from .add_document_request import AddDocumentRequest
from .body_upload_document_content import BodyUploadDocumentContent
Expand Down
3 changes: 2 additions & 1 deletion dewy-client/dewy_client/types.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
""" Contains some shared types for properties """
"""Contains some shared types for properties"""

from http import HTTPStatus
from typing import BinaryIO, Generic, Literal, MutableMapping, Optional, Tuple, TypeVar

Expand Down
4 changes: 3 additions & 1 deletion dewy-client/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,7 @@ requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"

[tool.ruff]
select = ["F", "I", "UP"]
line-length = 120

[tool.ruff.lint]
select = ["F", "I", "UP"]
2 changes: 1 addition & 1 deletion dewy/common/collection_embeddings.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ def encode_chunk(c: str) -> str:
# (https://github.com/DewyKB/dewy/issues/20). We do not know
# that all of this is truly necessary.
encoded = c.encode("utf-8").decode("utf-8", "ignore")
return encoded.replace("\x00", "\uFFFD")
return encoded.replace("\x00", "\ufffd")

# First, insert the chunks.
await conn.executemany(
Expand Down
2 changes: 1 addition & 1 deletion openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ paths:
tags:
- kb
summary: Add Document
description: Add a document from a URL.
description: Add a document to a collection.
operationId: addDocument
requestBody:
required: true
Expand Down
328 changes: 262 additions & 66 deletions poetry.lock

Large diffs are not rendered by default.

14 changes: 8 additions & 6 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,10 @@ langchain-core = "^0.1.27"
langchain-openai = "^0.0.8"
langchain-community = "^0.0.24"
langchain = "^0.1.9"
sentence-transformers = "^2.5.0"

[tool.poetry.group.dev.dependencies]
ruff = "^0.1.11"
ruff = "^0.3.0"
mypy = "^1.8.0"
ipykernel = "^6.28.0"
asyncpg-stubs = "^0.29.1"
Expand All @@ -93,6 +94,10 @@ build-backend = "poetry.core.masonry.api"
[tool.ruff]
line-length = 98

# Assume Python 3.11.
target-version = "py311"

[tool.ruff.lint]
# Enable Pyflakes `E` and `F` codes by default.
select = [
# Pyflakes
Expand All @@ -108,10 +113,7 @@ ignore = []
# Allow unused variables when underscore-prefixed.
dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$"

# Assume Python 3.11.
target-version = "py311"

[tool.ruff.mccabe]
[tool.ruff.lint.mccabe]
# Unlike Flake8, default to a complexity level of 10.
max-complexity = 10

Expand All @@ -125,4 +127,4 @@ show_error_context = true
[tool.pytest.ini_options]
testpaths = ["tests"]
asyncio_mode = "auto"
timeout = 10
timeout = 20
1 change: 0 additions & 1 deletion tests/test_e2e.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
"embedding_model",
["openai:text-embedding-ada-002", "hf:BAAI/bge-small-en", "hf:BAAI/bge-small-en-v1.5"],
)
@pytest.mark.timeout(120) # slow due to embedding (especially in CI)
async def test_index_retrieval(client, embedding_model):
collection_name = "".join(random.choices(string.ascii_lowercase, k=5))

Expand Down

0 comments on commit a0a280c

Please sign in to comment.