Skip to content

Commit

Permalink
fix: NexusRESTClient circular import
Browse files Browse the repository at this point in the history
  • Loading branch information
AlisoSouza committed Dec 21, 2023
1 parent ee5cbbb commit 6da7a90
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 23 deletions.
2 changes: 1 addition & 1 deletion app/celery.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from app.indexer.indexer_file_manager import IndexerFileManager
from app.downloaders.s3 import S3FileDownloader

from app.handlers.content_bases import NexusRESTClient
from app.handlers.nexus import NexusRESTClient

celery = Celery(__name__)
celery.conf.broker_url = os.environ.get(
Expand Down
22 changes: 0 additions & 22 deletions app/handlers/content_bases.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
from typing import Annotated
from app.handlers.authorizations import token_verification

import requests, os


class ContentBaseIndexRequest(BaseModel):
file: str
Expand Down Expand Up @@ -76,23 +74,3 @@ def search(self, request: ContentBaseSearchRequest, Authorization: Annotated[str
filter=request.filter
)
return ContentBaseSearchResponse(response=response)


class NexusRESTClient:
token = os.environ.get("NEXUS_AI_TOKEN")
base_url = os.environ.get("NEXUS_AI_URL")

def __init__(self) -> None:
self.headers = {
'Authorization': self.token,
'Content-Type': "application/json"
}

def index_succedded(self, task_succeded: bool, nexus_task_uuid: str) -> None:
endpoint = f'{self.base_url}/api/v1/content-base-file'
data = {
"status": int(task_succeded),
"task_uuid": nexus_task_uuid,
}
response = requests.patch(url=endpoint, data=data, headers=self.headers)
response.raise_for_status()
21 changes: 21 additions & 0 deletions app/handlers/nexus.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import requests, os


class NexusRESTClient:
token = os.environ.get("NEXUS_AI_TOKEN")
base_url = os.environ.get("NEXUS_AI_URL")

def __init__(self) -> None:
self.headers = {
'Authorization': self.token,
'Content-Type': "application/json"
}

def index_succedded(self, task_succeded: bool, nexus_task_uuid: str) -> None:
endpoint = f'{self.base_url}/api/v1/content-base-file'
data = {
"status": int(task_succeded),
"task_uuid": nexus_task_uuid,
}
response = requests.patch(url=endpoint, data=data, headers=self.headers)
response.raise_for_status()

0 comments on commit 6da7a90

Please sign in to comment.