Skip to content

Commit

Permalink
Fix test with new required body, remove print statements and add check
Browse files Browse the repository at this point in the history
  • Loading branch information
NolanTrem committed Dec 11, 2024
1 parent 1c07de4 commit e5612fa
Show file tree
Hide file tree
Showing 14 changed files with 21 additions and 32 deletions.
9 changes: 9 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,15 @@ repos:
types: [python]
pass_filenames: false

- repo: local
hooks:
- id: check-print-statements
name: Check for print statements
entry: bash -c 'echo "Checking for print statements..." && find . -name "*.py" ! -path "./py/cli/*" ! -path "./py/core/examples/*" ! -path "./py/migrations/*" ! -path "./py/tests/*" | xargs grep -n "print(" || exit 0 && echo "Found print statements!" && exit 1'
language: system
types: [python]
pass_filenames: false

- repo: local
hooks:
- id: isort
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ describe("r2rClient V3 System Integration Tests User", () => {

expect(response.results.document_id).toBeDefined();
user1DocumentId = response.results.document_id;
}, 10000);
}, 15000);

test("Create document as user 2 with file path", async () => {
const response = await user2Client.documents.create({
Expand All @@ -126,7 +126,7 @@ describe("r2rClient V3 System Integration Tests User", () => {

expect(response.results.document_id).toBeDefined();
user2DocumentId = response.results.document_id;
}, 10000);
}, 15000);

test("Retrieve document as user 1", async () => {
const response = await user1Client.documents.retrieve({
Expand Down
2 changes: 2 additions & 0 deletions js/sdk/__tests__/GraphsIntegrationSuperUser.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@ describe("r2rClient V3 Graphs Integration Tests", () => {
predicate: "falls in love with",
object: "Dunia",
objectId: entity2Id,
description: "Razumikhn and Dunia are central to the story",
});

relationshipId = response.results.id;
Expand All @@ -236,6 +237,7 @@ describe("r2rClient V3 Graphs Integration Tests", () => {
expect(response.results.subject).toBe("Razumikhin");
expect(response.results.object).toBe("Dunia");
expect(response.results.predicate).toBe("falls in love with");
expect(response.results.description).toBe("Razumikhn and Dunia are central to the story");
});

test("Retrieve the relationship", async () => {
Expand Down
4 changes: 2 additions & 2 deletions js/sdk/src/v3/clients/graphs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ export class GraphsClient {
predicate: string;
object: string;
objectId: string;
description?: string;
description: string;
weight?: number;
metadata?: Record<string, any>;
}): Promise<WrappedRelationshipResponse> {
Expand All @@ -243,7 +243,7 @@ export class GraphsClient {
predicate: options.predicate,
object: options.object,
object_id: options.objectId,
...(options.description && { description: options.description }),
description: options.description,
...(options.weight && { weight: options.weight }),
...(options.metadata && { metadata: options.metadata }),
};
Expand Down
2 changes: 1 addition & 1 deletion py/core/main/api/v3/chunks_router.py
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ async def delete_chunk(
"""
# Get the existing chunk to get its chunk_id
existing_chunk = await self.services["ingestion"].get_chunk(id)
print("existing_chunk = ", existing_chunk)

if existing_chunk is None:
raise R2RException(
message=f"Chunk {id} not found", status_code=404
Expand Down
1 change: 0 additions & 1 deletion py/core/main/api/v3/conversations_router.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,6 @@ async def get_conversation(
str(id),
branch_id,
)
print("conversation", conversation)
return conversation

@self.router.delete(
Expand Down
12 changes: 0 additions & 12 deletions py/core/main/api/v3/indices_router.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,13 +258,6 @@ async def create_index(
offset=0,
limit=10
)
# Print index details
for idx in indices:
print(f"Index: {idx['name']}")
print(f"Method: {idx['method']}")
print(f"Size: {idx['size_bytes'] / 1024 / 1024:.2f} MB")
print(f"Row count: {idx['row_count']}")
"""
),
},
Expand Down Expand Up @@ -363,11 +356,6 @@ async def list_indices(
# Get detailed information about a specific index
index = client.indices.retrieve("index_1")
# Access index details
print(f"Index Method: {index['method']}")
print(f"Parameters: {index['parameters']}")
print(f"Performance Stats: {index['stats']}")
"""
),
},
Expand Down
6 changes: 0 additions & 6 deletions py/core/main/orchestration/hatchet/kg_workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,10 +197,6 @@ async def kg_extract(self, context: Context) -> dict:
document_id=document_id,
**input_data["graph_creation_settings"],
):
print(
"found extraction w/ entities = = ",
len(extraction.entities),
)
extractions.append(extraction)
await service.store_kg_extractions(extractions)

Expand Down Expand Up @@ -283,7 +279,6 @@ def __init__(self, kg_service: KgService):
@orchestration_provider.step(retries=1)
async def kg_extraction(self, context: Context) -> dict:
request = context.workflow_input()["request"]
print('context.workflow_input()["request"] = ', request)

input_data = get_input_data_dict(request)
document_id = input_data.get("document_id", None)
Expand All @@ -299,7 +294,6 @@ async def kg_extraction(self, context: Context) -> dict:
workflows = []

for document_id in document_ids:
print("extracting = ", document_id)
input_data_copy = input_data.copy()
input_data_copy["collection_id"] = str(
input_data_copy["collection_id"]
Expand Down
4 changes: 2 additions & 2 deletions py/core/main/services/kg_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -1041,11 +1041,11 @@ async def parse_fn(response_str: str) -> Any:
if attempt < retries - 1:
await asyncio.sleep(delay)
else:
print(
logger.warning(
f"Failed after retries with for chunk {chunks[0].id} of document {chunks[0].document_id}: {e}"
)

print(
logger.info(
f"KGExtractionPipe: Completed task number {task_id} of {total_tasks} for document {chunks[0].document_id}",
)

Expand Down
1 change: 0 additions & 1 deletion py/core/main/services/management_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,6 @@ def transform_chunk_id_to_id(
vector_delete_results = await self.providers.database.delete(
filters_xf
)
print("vector_delete_results = ", vector_delete_results)
except Exception as e:
logger.error(f"Error deleting from vector database: {e}")
vector_delete_results = {}
Expand Down
2 changes: 1 addition & 1 deletion py/core/providers/database/graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -2246,7 +2246,7 @@ async def get_entity_map(
)

return entity_map

async def graph_search(
self, query: str, **kwargs: Any
) -> AsyncGenerator[Any, None]:
Expand Down
1 change: 0 additions & 1 deletion py/core/providers/database/postgres.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,6 @@ def _get_postgres_configuration_settings(
if value is None:
value = os.getenv(env_var)

print(f"Setting: {setting}, Value: {value}")
if value is not None:
field_type = settings.__annotations__[setting]
if field_type == Optional[int]:
Expand Down
1 change: 0 additions & 1 deletion py/sdk/v3/documents.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,6 @@ async def download(
version="v3",
# No json parsing here, if possible
)
print(response)
if not isinstance(response, BytesIO):
raise ValueError("Expected BytesIO response")
return response
Expand Down
4 changes: 2 additions & 2 deletions py/tests/integration/runner_user_documents_collections.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import time
import uuid
from dataclasses import dataclass
from typing import List, Optional
from typing import Optional

from r2r import R2RClient, R2RException

Expand Down Expand Up @@ -39,7 +39,7 @@ def create_test_user(base_url: str) -> TestUser:


def create_test_document(
client: R2RClient, content: str, collection_ids: List[str] = None
client: R2RClient, content: str, collection_ids: list[str] = None
) -> str:
"""Create a test document and return its ID"""
response = client.documents.create(
Expand Down

0 comments on commit e5612fa

Please sign in to comment.