Skip to content

Commit

Permalink
resolve circular import
Browse files Browse the repository at this point in the history
  • Loading branch information
zMardone committed Jul 17, 2024
1 parent 9c1281e commit ea5ea0e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
11 changes: 2 additions & 9 deletions app/celery.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

from app.indexer.indexer_file_manager import IndexerFileManager

from app.indexer.content_bases import ContentBaseIndexer
from app.downloaders.s3 import S3FileDownloader
from app.handlers.nexus import NexusRESTClient
from app.text_splitters import TextSplitter, character_text_splitter
Expand Down Expand Up @@ -62,23 +61,17 @@ def index_file_data(content_base: Dict) -> bool:
@celery.task(name="document_save")
def document_save(
docs: dict,
content_base_uuid: str
content_base_uuid: str,
search_results: dict = None,
) -> bool:
from app.main import main_app
from app.indexer.indexer_file_manager import add_file_metadata

storage = main_app.content_base_vectorstore
docs = add_file_metadata(docs, content_base_uuid)
content_base_indexer = ContentBaseIndexer(storage)

file_uuid = docs[0].metadata["file_uuid"]
content_base_uuid = docs[0].metadata["content_base_uuid"]

search_results = content_base_indexer._search_docs_by_content_base_uuid(
content_base_uuid=content_base_uuid,
file_uuid=file_uuid,
)

ids = []
if len(search_results) > 0:
ids = [item["_id"] for item in search_results]
Expand Down
10 changes: 9 additions & 1 deletion app/indexer/content_bases.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,18 @@ def __init__(self, storage: IStorage):
self.storage = storage

def index_documents(self, dict_docs: dict, content_base_uuid: str):

file_uuid = dict_docs[0].get("metadata").get("file_uuid")
search_results = self._search_docs_by_content_base_uuid(
content_base_uuid=content_base_uuid,
file_uuid=file_uuid,
)

print("mandou para task")
task_status = document_save.delay(
content_base_uuid=content_base_uuid,
docs=dict_docs
docs=dict_docs,
search_results=search_results
)
return task_status.wait()

Expand Down

0 comments on commit ea5ea0e

Please sign in to comment.