Skip to content

Adding a few pytest filterwarnings for clean test logs #27

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Sep 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ repos:
- fhaviary>=0.6 # Match pyproject.toml
- httpx
- litellm>=1.42.1 # Match pyproject.toml
- numpy
- numpy>=1.20 # Match pyproject.toml
- pydantic~=2.0 # Match pyproject.toml
- tenacity
- torch
Expand Down
8 changes: 6 additions & 2 deletions ldp/graph/memory.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@
from abc import ABC, abstractmethod
from collections.abc import AsyncIterator
from contextlib import asynccontextmanager
from typing import Any, ClassVar, Generic, TypeVar
from typing import Any, ClassVar, Generic, TypeVar, cast
from uuid import UUID

import numpy as np
import numpy.typing as npt
from pydantic import (
BaseModel,
ConfigDict,
Expand Down Expand Up @@ -134,7 +135,10 @@ def __init__(self, **kwargs):

async def _add_to_index(self, embedding: np.ndarray) -> int:
async with self.safe_access_index() as index:
return int(index.add(len(self.memories), embedding))
added_value = cast(
npt.NDArray[np.int_], index.add(len(self.memories), embedding)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😮

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah it's informing mypy, in general this numpy deprecation makes the code look more complex haha

)
return added_value.item()

async def _search_index(
self, embedding: np.ndarray, matches: int = MemoryModel.DEFAULT_MEMORY_MATCHES
Expand Down
10 changes: 9 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ dependencies = [
"httpx",
"litellm",
"networkx[default]~=3.0", # Pin just to keep recent
"numpy",
"numpy>=1.20", # For numpy.typing
"openai>=1",
"pydantic~=2.0",
"tenacity",
Expand Down Expand Up @@ -228,6 +228,14 @@ min-similarity-lines = 12
# Add the specified OPTS to the set of command line arguments as if they had been
# specified by the user.
addopts = "--doctest-modules"
# Sets a list of filters and actions that should be taken for matched warnings.
# By default all warnings emitted during the test session will be displayed in
# a summary at the end of the test session.
filterwarnings = [
"ignore:'imghdr' is deprecated and slated for removal in Python 3.13:DeprecationWarning", # SEE: https://github.com/BerriAI/litellm/issues/2929#issuecomment-2345224633
"ignore:Support for class-based `config` is deprecated, use ConfigDict instead", # SEE: https://github.com/BerriAI/litellm/issues/5648
'ignore:open_text is deprecated. Use files\(\) instead:DeprecationWarning', # SEE: https://github.com/BerriAI/litellm/issues/5647
]
# List of directories that should be searched for tests when no specific directories,
# files or test ids are given in the command line when executing pytest from the rootdir
# directory. File system paths may use shell-style wildcards, including the recursive **
Expand Down
22 changes: 11 additions & 11 deletions uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.