Skip to content

Commit

Permalink
setup workspaces and builds (#22)
Browse files Browse the repository at this point in the history
* setup workspaces and builds

* fix tests
  • Loading branch information
epinzur authored Jan 17, 2025
1 parent f9f3722 commit 6c6080a
Show file tree
Hide file tree
Showing 51 changed files with 254 additions and 158 deletions.
2 changes: 1 addition & 1 deletion .github/actions/setup-python-env/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@ runs:
cache-suffix: ${{ matrix.python-version }}

- name: Install Python dependencies
run: uv sync --frozen
run: uv sync --frozen --package langchain-graph-rag
shell: bash
4 changes: 3 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,9 @@ jobs:

- name: Run `make test`
run:
uv run python -m pytest -vs ./tests/unit_tests ./tests/integration_tests/
uv run --package langchain-graph-rag python -m pytest -vs
./packages/langchain-graph-rag/tests/unit_tests/
./packages/langchain-graph-rag/tests/integration_tests/
--stores=mem_norm --stores=mem --stores=cassandra --stores=chroma --stores=opensearch
--junitxml=junit/test-results-${{ matrix.python-version }}.xml

Expand Down
34 changes: 26 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ check-lock:
.PHONY: deptry
deptry:
@echo "🚀 Checking for obsolete dependencies: Running deptry"
@uvx $(DEPTRY) src tests
@uvx $(DEPTRY) packages/langchain-graph-rag/src packages/langchain-graph-rag/tests

.PHONY: docker-up
docker-up:
Expand All @@ -39,24 +39,42 @@ docker-up:
docker-down:
docker compose down --rmi local

.PHONY: sync-langchain-graph-rag
sync-langchain-graph-rag:
@uv sync --package langchain-graph-rag

.PHONY: sync-graph-rag
sync-graph-rag:
@uv sync --package graph-rag

.PHONY: integration
integration:
@echo "🚀 Testing code: Running pytest ./tests/inegration_tests (in memory only)"
@uv run pytest -vs ./tests/integration_tests/
@echo "🚀 Testing code: Running pytest ./packages/langchain-graph-rag/tests/integration_tests (in memory only)"
@uv run --project langchain-graph-rag pytest -vs ./packages/langchain-graph-rag/tests/integration_tests/

.PHONY: unit
unit:
@echo "🚀 Testing code: Running pytest ./tests/unit_tests"
@uv run pytest -vs ./tests/unit_tests/
@echo "🚀 Testing code: Running pytest ./packages/langchain-graph-rag/tests/unit_tests/"
@uv run --project langchain-graph-rag pytest -vs ./packages/langchain-graph-rag/tests/unit_tests/

.PHONY: test
test:
test: sync-langchain-graph-rag
@echo "🚀 Testing code: Running pytest"
@uv run python -m pytest -vs ./tests/unit_tests ./tests/integration_tests/ --stores=all
@uv run --project langchain-graph-rag python -m pytest -vs ./packages/langchain-graph-rag/tests/ --stores=all

.PHONY: mypy
mypy:
@echo "🚀 Static type checking: Running mypy"
@uv run mypy .
@uv run --project langchain-graph-rag mypy ./packages/langchain-graph-rag

lint: fmt fix mypy

.PHONY: build-langchain-graph-rag
build-langchain-graph-rag: sync-langchain-graph-rag
@echo "🚀 Building langchain-graph-rag package"
@uv build --package langchain-graph-rag

.PHONY: build-graph-rag
build-graph-rag: sync-graph-rag
@echo "🚀 Building graph-rag package"
@uv build --package graph-rag
File renamed without changes.
1 change: 1 addition & 0 deletions packages/graph-rag/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# graph-rag
27 changes: 27 additions & 0 deletions packages/graph-rag/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
[project]
name = "graph-rag"
version = "0.0.0"
description = "Add your description here"
readme = "README.md"
requires-python = ">=3.10"
dependencies = []

[project.optional-dependencies]


[tool.pytest.ini_options]
asyncio_mode = "auto"
pythonpath = ["."]
testpaths = ["tests"]


[tool.uv.sources]


[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"

[dependency-groups]
dev = []

File renamed without changes.
1 change: 1 addition & 0 deletions packages/langchain-graph-rag/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# langchain-graph-rag
60 changes: 60 additions & 0 deletions packages/langchain-graph-rag/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
[project]
name = "langchain-graph-rag"
version = "0.0.1"
description = "Add your description here"
readme = "README.md"
requires-python = ">=3.10"
dependencies = [
"langchain-core>=0.3.29",
"numpy>=1.26.4",
"pydantic>=2.10.4",
]

[project.optional-dependencies]
astra = [
"langchain-astradb>=0.5.2",
]
beautifulsoup4 = [
"beautifulsoup4>=4.12.3",
]
cassandra = [
"cassio>=0.1.10",
"langchain-community>=0.3.14",
]
chroma = [
"langchain-chroma>=0.2.0",
"chromadb>=0.5.23",
]
gliner = [
"gliner==0.2.13",
]
keybert = [
"keybert>=0.8.5",
]
opensearch = [
"langchain-community>=0.3.14",
"opensearch-py>=2.8.0",
]
simsimd = [
"simsimd>=6.2.1",
]

[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"

[dependency-groups]
dev = [
"cassio>=0.1.10",
"langchain-astradb>=0.5.2",
"langchain-chroma>=0.2.0",
"langchain-community>=0.3.14",
"langchain-opensearch>=0.0.2",
"mypy>=1.14.1",
"pytest>=8.3.4",
"pytest-cov>=4.0.0",
"pytest-asyncio>=0.25.2",
"simsimd>=6.2.1",
"testcontainers>=4.9.0",
]

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@
from typing import Iterable

import numpy as np
from langchain_graph_rag.utils.math import cosine_similarity
from numpy.typing import NDArray
from pydantic import Field

from graph_pancake.utils.math import cosine_similarity

from ..node import Node
from .base import TraversalStrategy

Expand Down
File renamed without changes.
File renamed without changes.
Empty file.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import pytest
from pytest import Parser

from tests.integration_tests.stores import ALL_STORES, TESTCONTAINER_STORES


Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,14 @@

import pytest
from langchain_core.documents import Document

from tests.embeddings import AnimalEmbeddings
from tests.integration_tests.stores import StoreAdapter, StoreFactory


@pytest.fixture(scope="session")
def animal_docs() -> list[Document]:
documents = []
with open("tests/data/animals.jsonl", "r") as file:
with open("data/animals.jsonl", "r") as file:
for line in file:
data = json.loads(line.strip())
documents.append(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import pytest
from langchain_core.documents import Document

from graph_pancake.retrievers.store_adapters import StoreAdapter
from langchain_graph_rag.retrievers.store_adapters import StoreAdapter
from tests.embeddings.simple_embeddings import EarthEmbeddings
from tests.integration_tests.stores import StoreFactory

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import pytest
from langchain_core.documents import Document

from tests.embeddings.simple_embeddings import ParserEmbeddings
from tests.integration_tests.stores import StoreAdapter, StoreFactory

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
from langchain_core.documents import Document

from graph_pancake.retrievers.graph_traversal_retriever import (
from langchain_graph_rag.retrievers.graph_traversal_retriever import (
GraphTraversalRetriever,
)
from graph_pancake.retrievers.strategy.eager import (
from langchain_graph_rag.retrievers.strategy.eager import (
Eager,
)
from tests.integration_tests.assertions import assert_document_format, sorted_doc_ids
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
from langchain_core.documents import Document
from langchain_core.vectorstores import InMemoryVectorStore

from graph_pancake.retrievers.graph_traversal_retriever import (
from langchain_graph_rag.retrievers.graph_traversal_retriever import (
GraphTraversalRetriever,
)
from graph_pancake.retrievers.store_adapters.in_memory import (
from langchain_graph_rag.retrievers.store_adapters.in_memory import (
InMemoryStoreAdapter,
)
from graph_pancake.retrievers.strategy.mmr import (
from langchain_graph_rag.retrievers.strategy.mmr import (
Mmr,
)
from tests.embeddings.simple_embeddings import Angular2DEmbeddings
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,10 @@
from langchain_core.documents import Document
from langchain_core.embeddings import Embeddings
from langchain_core.vectorstores import VectorStore

from graph_pancake.document_transformers.metadata_denormalizer import (
from langchain_graph_rag.document_transformers.metadata_denormalizer import (
MetadataDenormalizer,
)
from graph_pancake.retrievers.store_adapters import StoreAdapter
from langchain_graph_rag.retrievers.store_adapters import StoreAdapter

ALL_STORES = ["mem_norm", "mem", "astra", "cassandra", "chroma", "opensearch"]
TESTCONTAINER_STORES = ["cassandra", "opensearch"]
Expand Down Expand Up @@ -86,8 +85,7 @@ def _cassandra_store_factory(request: pytest.FixtureRequest):

from cassandra.cluster import Cluster # type: ignore
from langchain_community.vectorstores.cassandra import Cassandra

from graph_pancake.retrievers.store_adapters.cassandra import (
from langchain_graph_rag.retrievers.store_adapters.cassandra import (
CassandraStoreAdapter,
)

Expand Down Expand Up @@ -150,8 +148,7 @@ def teardown_cassandra(cassandra: Cassandra):

def _opensearch_store_factory(request: pytest.FixtureRequest):
from langchain_community.vectorstores import OpenSearchVectorSearch

from graph_pancake.retrievers.store_adapters.open_search import (
from langchain_graph_rag.retrievers.store_adapters.open_search import (
OpenSearchStoreAdapter,
)

Expand Down Expand Up @@ -204,8 +201,7 @@ def _astra_store_factory(_request: pytest.FixtureRequest) -> StoreFactory:
from astrapy.authentication import StaticTokenProvider
from dotenv import load_dotenv
from langchain_astradb import AstraDBVectorStore

from graph_pancake.retrievers.store_adapters.astra import (
from langchain_graph_rag.retrievers.store_adapters.astra import (
AstraStoreAdapter,
)

Expand Down Expand Up @@ -252,8 +248,7 @@ def _in_memory_store_factory(
_request: pytest.FixtureRequest, support_normalized_metadata: bool
) -> StoreFactory:
from langchain_core.vectorstores import InMemoryVectorStore

from graph_pancake.retrievers.store_adapters.in_memory import (
from langchain_graph_rag.retrievers.store_adapters.in_memory import (
InMemoryStoreAdapter,
)

Expand All @@ -274,8 +269,7 @@ def create_in_memory(

def _chroma_store_factory(_request: pytest.FixtureRequest) -> StoreFactory:
from langchain_chroma.vectorstores import Chroma

from graph_pancake.retrievers.store_adapters.chroma import (
from langchain_graph_rag.retrievers.store_adapters.chroma import (
ChromaStoreAdapter,
)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import pytest

from graph_pancake.retrievers.edge import Edge
from graph_pancake.retrievers.edge_helper import EdgeHelper
from langchain_graph_rag.retrievers.edge import Edge
from langchain_graph_rag.retrievers.edge_helper import EdgeHelper


def test_edge_helper_initialization():
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from graph_pancake.retrievers.strategy.mmr import Mmr
from langchain_graph_rag.retrievers.strategy.mmr import Mmr


def test_mmr_parameters() -> None:
Expand Down
Loading

0 comments on commit 6c6080a

Please sign in to comment.