Merge remote-tracking branch 'origin/release/quivr-core-0.1' into feat/separate-celery-workers

This commit is contained in:
aminediro 2024-08-07 14:46:42 +02:00
commit 4517af8bb5
7 changed files with 334 additions and 228 deletions

View File

@ -96,11 +96,11 @@ def oauth2callback_notion(request: Request, background_tasks: BackgroundTasks):
sync_user_state = sync_user_service.get_sync_user_by_state(state_dict)
if not sync_user_state or state_dict != sync_user_state.state:
logger.error("Invalid state parameter")
logger.error(f"Invalid state parameter for {sync_user_state}")
raise HTTPException(status_code=400, detail="Invalid state parameter")
else:
logger.info(
f"CURRENT USER: {current_user}, SYNC USER STATE USER: {sync_user_state.user_id}"
f"Current user: {current_user}, sync user state: {sync_user_state.state}"
)
if sync_user_state.user_id != current_user:

View File

@ -118,7 +118,7 @@ async def get_user_syncs(current_user: UserIdentity = Depends(get_current_user))
List: A list of syncs for the user.
"""
logger.debug(f"Fetching user syncs for user: {current_user.id}")
return sync_user_service.get_syncs_user(str(current_user.id))
return sync_user_service.get_syncs_user(current_user.id)
@sync_router.delete(
@ -327,7 +327,7 @@ async def get_files_folder_user_sync(
f"Fetching files for user sync: {user_sync_id} for user: {current_user.id}"
)
return await sync_user_service.get_files_folder_user_sync(
user_sync_id, str(current_user.id), folder_id, notion_service=notion_service
user_sync_id, current_user.id, folder_id, notion_service=notion_service
)

View File

@ -10,7 +10,6 @@ from quivr_api.modules.notification.service.notification_service import (
)
from quivr_api.modules.sync.dto.inputs import SyncsUserInput, SyncUserUpdateInput
from quivr_api.modules.sync.entity.sync import SyncFile, SyncsUser
from quivr_api.modules.sync.repository.sync_interfaces import SyncUserInterface
from quivr_api.modules.sync.service.sync_notion import SyncNotionService
from quivr_api.modules.sync.utils.sync import (
AzureDriveSync,
@ -26,7 +25,7 @@ knowledge_service = KnowledgeService()
logger = get_logger(__name__)
class SyncUser(SyncUserInterface):
class SyncUser:
def __init__(self):
"""
Initialize the Sync class with a Supabase client.

View File

@ -25,7 +25,7 @@ from quivr_api.modules.sync.service.sync_notion import SyncNotionService
from quivr_api.modules.sync.utils.normalize import remove_special_characters
logger = get_logger(__name__)
redis_client = redis.Redis(host="redis", port=os.getenv("REDIS_PORT"), db=0)
redis_client = redis.Redis(host="redis", port=int(os.getenv("REDIS_PORT", 6379)), db=0)
class BaseSync(ABC):
@ -433,9 +433,11 @@ class AzureDriveSync(BaseSync):
for item in items:
file_data = SyncFile(
name=item.get("name") if site_folder_id else item.get("displayName"),
id=f'{item.get("id", {}).split(",")[1]}:'
if not site_folder_id
else f'{site_id}:{item.get("id")}',
id=(
f'{item.get("id", {}).split(",")[1]}:'
if not site_folder_id
else f'{site_id}:{item.get("id")}'
),
is_folder="folder" in item or not site_folder_id,
last_modified=item.get("lastModifiedDateTime"),
mime_type=item.get("file", {}).get("mimeType", "folder"),

View File

@ -37,4 +37,4 @@ grant references on table "public"."notion_sync" to "service_role";
grant select on table "public"."notion_sync" to "service_role";
grant trigger on table "public"."notion_sync" to "service_role";
grant truncate on table "public"."notion_sync" to "service_role";
grant update on table "public"."notion_sync" to "service_role";
grant update on table "public"."notion_sync" to "service_role";

View File

@ -41,13 +41,6 @@ ENV PATH="/root/.cargo/bin:${PATH}" \
ENV PYTHONPATH=/code/worker
# Copy monorepo dependencies
# CORE
# COPY core/pyproject.toml core/README.md core/poetry.lock /code/core/
# COPY core/quivr_core /code/core/quivr_core
# # API
# COPY api/pyproject.toml api/poetry.lock api/README.md /code/api/
# COPY api/quivr_api /code/api/quivr_api
# WORKER
COPY worker/pyproject.toml worker/poetry.lock* /code/worker/

File diff suppressed because it is too large Load Diff