From 2fd52748e09f4975f6901310e12a136afe7619a7 Mon Sep 17 00:00:00 2001 From: emrgnt-cmplxty Date: Sun, 1 Dec 2024 15:14:45 -0800 Subject: [PATCH] rm pull --- py/core/main/api/v3/graph_router.py | 81 ----------------------------- 1 file changed, 81 deletions(-) diff --git a/py/core/main/api/v3/graph_router.py b/py/core/main/api/v3/graph_router.py index 57b8f77da..0f383cb9d 100644 --- a/py/core/main/api/v3/graph_router.py +++ b/py/core/main/api/v3/graph_router.py @@ -1601,87 +1601,6 @@ async def update_community( rating_explanation=rating_explanation, ) - async def _pull(collection_id: UUID, auth_user): - if ( - not auth_user.is_superuser - and collection_id not in auth_user.graph_ids - ): - raise R2RException( - "The currently authenticated user does not have access to the specified graph.", - 403, - ) - - list_graphs_response = await self.services["kg"].list_graphs( - # user_ids=None, - graph_ids=[collection_id], - offset=0, - limit=1, - ) - if len(list_graphs_response["results"]) == 0: - raise R2RException("Graph not found", 404) - collection_id = list_graphs_response["results"][0].collection_id - documents = [] - document_req = ( - await self.providers.database.collections_handler.documents_in_collection( - collection_id, offset=0, limit=100 - ) - )["results"] - documents.extend(document_req) - while len(document_req) == 100: - document_req = ( - await self.providers.database.collections_handler.documents_in_collection( - collection_id, offset=len(documents), limit=100 - ) - )["results"] - documents.extend(document_req) - - success = False - - for document in documents: - if ( - not auth_user.is_superuser - and document.id - not in auth_user.document_ids # TODO - extend to include checks on collections - ): - raise R2RException( - f"The currently authenticated user does not have access to document {document.id}", - 403, - ) - entities = ( - await self.providers.database.graph_handler.entities.get( - document.id, store_type="document" - ) - ) - has_document = ( - await self.providers.database.graph_handler.has_document( - collection_id, document.id - ) - ) - if has_document: - logger.info( - f"Document {document.id} is already in graph {collection_id}, skipping." - ) - continue - if len(entities[0]) == 0: - logger.warning( - f"Document {document.id} has no entities, extraction may not have been called, skipping." - ) - continue - - success = ( - await self.providers.database.graph_handler.add_documents( - id=collection_id, - document_ids=[ - document.id - ], # [doc.id for doc in documents] - ) - ) - if not success: - logger.warning( - f"No documents were added to graph {collection_id}, marking as failed." - ) - return success - @self.router.post( "/graphs/{collection_id}/pull", summary="Pull latest entities to the graph",