Skip to content

Commit 4d2aac0

Browse files
Support Python 3.9 in knowledge_store and knowledge_graph (#462)
* Support Python 3.8.1 * Update ci-unit-tests.yml * Test knowledge-store and knowledge-graph on py38 and py39 * Remove 3.8 from test matrix * Use 3.9 as min python version --------- Co-authored-by: Nicolò Boschi <[email protected]>
1 parent 0cbbac4 commit 4d2aac0

File tree

11 files changed

+21
-23
lines changed

11 files changed

+21
-23
lines changed

.github/workflows/ci-unit-tests.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -79,26 +79,26 @@ jobs:
7979
run: tox -e unit-tests && rm -rf .tox
8080

8181
- name: "Unit tests (colbert)"
82-
if: ${{ needs.preconditions.outputs.libs_colbert == 'true'}}
82+
if: ${{ needs.preconditions.outputs.libs_colbert == 'true' }}
8383
run: tox -e unit-tests -c libs/colbert && rm -rf libs/colbert/.tox
8484

8585
- name: "Unit tests (langchain)"
86-
if: ${{ needs.preconditions.outputs.libs_langchain == 'true'}}
86+
if: ${{ needs.preconditions.outputs.libs_langchain == 'true' }}
8787
run: tox -e unit-tests -c libs/langchain && rm -rf libs/langchain/.tox
8888

8989
- name: "Unit tests (llamaindex)"
90-
if: ${{ needs.preconditions.outputs.libs_llamaindex == 'true'}}
90+
if: ${{ needs.preconditions.outputs.libs_llamaindex == 'true' }}
9191
run: tox -e unit-tests -c libs/llamaindex && rm -rf libs/llamaindex/.tox
9292

9393
- name: "Unit tests (knowledge-store)"
94-
if: ${{ needs.preconditions.outputs.libs_knowledge_store == 'true' && matrix.python-version != '3.9' }}
94+
if: ${{ needs.preconditions.outputs.libs_knowledge_store == 'true' }}
9595
env:
9696
OPENAI_API_KEY: "${{ secrets.E2E_TESTS_OPEN_AI_KEY }}"
9797
run: tox -e unit-tests -c libs/knowledge-store && rm -rf libs/knowledge-store/.tox
9898

9999
- name: "Unit tests (knowledge-graph)"
100100
# yamllint disable-line rule:line-length
101-
if: ${{ needs.preconditions.outputs.libs_knowledge_graph == 'true' && matrix.python-version != '3.9' && matrix.python-version != '3.10' }}
101+
if: ${{ needs.preconditions.outputs.libs_knowledge_graph == 'true' }}
102102
env:
103103
OPENAI_API_KEY: "${{ secrets.E2E_TESTS_OPEN_AI_KEY }}"
104104
run: tox -e unit-tests -c libs/knowledge-graph && rm -rf libs/knowledge-graph/.tox

libs/colbert/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ documentation = "https://docs.datastax.com/en/ragstack"
1010
packages = [{ include = "ragstack_colbert" }]
1111

1212
[tool.poetry.dependencies]
13-
python = ">=3.9,<3.13"
13+
python = ">=3.9,<4.0"
1414
colbert-ai = "0.2.19"
1515
pyarrow = "14.0.1"
1616
torch = "2.2.1"

libs/knowledge-graph/pyproject.toml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ include = [
1414

1515

1616
[tool.poetry.dependencies]
17-
python = ">=3.11,<3.13"
17+
python = ">=3.8.1,<4.0"
1818
langchain = "^0.1.14"
1919
langchain-community = "^0.0.31"
2020
langchain-openai = "^0.1.1"
@@ -24,7 +24,6 @@ graphviz = "^0.20.3"
2424
pydantic-yaml = "^1.3.0"
2525
pyyaml = "^6.0.1"
2626

27-
2827
[tool.poetry.group.dev.dependencies]
2928
python-dotenv = "^1.0.1"
3029
ipykernel = "^6.29.4"
@@ -34,8 +33,8 @@ requests = "^2.32.2"
3433
pytest = "^8.1.1"
3534
pytest-asyncio = "^0.23.6"
3635
pytest-dotenv = "^0.5.2"
36+
pytest-rerunfailures = "^14.0"
3737
setuptools = "^70.0.0"
38-
pytest-retry = "^1.6.3"
3938

4039
[build-system]
4140
requires = ["poetry-core"]

libs/knowledge-graph/ragstack_knowledge_graph/knowledge_graph.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ def insert(
221221

222222
def subgraph(
223223
self,
224-
start: Node | Sequence[Node],
224+
start: Union[Node, Sequence[Node]],
225225
edge_filters: Sequence[str] = (),
226226
steps: int = 3,
227227
) -> Tuple[Iterable[Node], Iterable[Relation]]:
@@ -249,7 +249,7 @@ def subgraph(
249249

250250
def traverse(
251251
self,
252-
start: Node | Sequence[Node],
252+
start: Union[Node, Sequence[Node]],
253253
edge_filters: Sequence[str] = (),
254254
steps: int = 3,
255255
) -> Iterable[Relation]:
@@ -280,7 +280,7 @@ def traverse(
280280

281281
async def atraverse(
282282
self,
283-
start: Node | Sequence[Node],
283+
start: Union[Node, Sequence[Node]],
284284
edge_filters: Sequence[str] = (),
285285
steps: int = 3,
286286
) -> Iterable[Relation]:

libs/knowledge-graph/ragstack_knowledge_graph/knowledge_schema.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from pathlib import Path
2-
from typing import Dict, List, Self, Sequence, Union
2+
from typing import Dict, List, Sequence, Union
33

44
from langchain_community.graphs.graph_document import GraphDocument
55
from langchain_core.pydantic_v1 import BaseModel
@@ -56,7 +56,7 @@ class KnowledgeSchema(BaseModel):
5656
"""Allowed relationships for the knowledge schema."""
5757

5858
@classmethod
59-
def from_file(cls, path: Union[str, Path]) -> Self:
59+
def from_file(cls, path: Union[str, Path]) -> "KnowledgeSchema":
6060
"""Load a KnowledgeSchema from a JSON or YAML file.
6161
6262
Parameters:

libs/knowledge-graph/ragstack_knowledge_graph/traverse.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import asyncio
22
import threading
3-
from typing import Any, Dict, Iterable, NamedTuple, Optional, Sequence
3+
from typing import Any, Dict, Iterable, NamedTuple, Optional, Sequence, Union
44

55
from cassandra.cluster import PreparedStatement, ResponseFuture, Session
66
from cassio.config import check_resolve_keyspace, check_resolve_session
@@ -69,7 +69,7 @@ def _prepare_edge_query(
6969

7070

7171
def traverse(
72-
start: Node | Sequence[Node],
72+
start: Union[Node, Sequence[Node]],
7373
edge_table: str,
7474
edge_source_name: str = "source_name",
7575
edge_source_type: str = "source_type",
@@ -214,7 +214,7 @@ async def next(self):
214214

215215

216216
async def atraverse(
217-
start: Node | Sequence[Node],
217+
start: Union[Node, Sequence[Node]],
218218
edge_table: str,
219219
edge_source_name: str = "source_name",
220220
edge_source_type: str = "source_type",

libs/knowledge-graph/tests/test_extraction.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def extractor(llm: BaseChatModel) -> KnowledgeSchemaExtractor:
3434
"""
3535

3636

37-
@pytest.mark.flaky(retries=10, delay=0)
37+
@pytest.mark.flaky(reruns=10, reruns_delay=0)
3838
def test_extraction(extractor: KnowledgeSchemaExtractor):
3939
results = extractor.extract([Document(page_content=MARIE_CURIE_SOURCE)])
4040

libs/knowledge-graph/tests/test_schema_inference.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"""
1919

2020

21-
@pytest.mark.flaky(retries=5, delay=0)
21+
@pytest.mark.flaky(reruns=5, reruns_delay=0)
2222
def test_schema_inference(llm: BaseChatModel):
2323
schema_inferer = KnowledgeSchemaInferer(llm)
2424

libs/knowledge-store/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ documentation = "https://docs.datastax.com/en/ragstack"
1010
packages = [{ include = "ragstack_knowledge_store" }]
1111

1212
[tool.poetry.dependencies]
13-
python = ">=3.10,<3.13"
13+
python = ">=3.8.1,<4.0"
1414
langchain-core = "^0.2"
1515
cassio = "^0.1.7"
1616

libs/knowledge-store/ragstack_knowledge_store/cassandra.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222

2323
from ragstack_knowledge_store.edge_extractor import get_link_tags
2424

25-
from ._utils import strict_zip
2625
from .base import KnowledgeStore, Node, TextNode
2726
from .concurrency import ConcurrentQueries
2827
from .content import Kind
@@ -331,7 +330,7 @@ def add_nodes(
331330

332331
# Step 1: Add the nodes, collecting the tags and new sources / targets.
333332
with self._concurrent_queries() as cq:
334-
tuples = strict_zip(texts, text_embeddings, metadatas)
333+
tuples = zip(texts, text_embeddings, metadatas)
335334
for text, text_embedding, metadata in tuples:
336335
if CONTENT_ID not in metadata:
337336
metadata[CONTENT_ID] = secrets.token_hex(8)

0 commit comments

Comments
 (0)