From a474c31e02e0400a8253e7ca2c77d9de11df0a85 Mon Sep 17 00:00:00 2001 From: sabaimran Date: Tue, 21 Nov 2023 10:56:04 -0800 Subject: [PATCH] Move the django app into the src/khoj folder for better organization and functionality - Our pypi package currently does not work because the django app and associated database is not included. To remedy this issue, move the app into the src/khoj folder. This has the added benefit of improved organization of the codebase, as all server related code is now in a single folder - Update associated file paths and system references --- Dockerfile | 2 +- prod.Dockerfile | 2 +- pytest.ini | 2 +- src/{ => khoj}/app/README.md | 0 src/{ => khoj}/app/__init__.py | 0 src/{ => khoj}/app/settings.py | 4 ++-- src/{ => khoj}/app/urls.py | 0 src/{ => khoj}/app/wsgi.py | 0 src/khoj/configure.py | 6 +++--- src/{ => khoj}/database/__init__.py | 0 src/{ => khoj}/database/adapters/__init__.py | 2 +- src/{ => khoj}/database/admin.py | 2 +- src/{ => khoj}/database/apps.py | 2 +- src/{ => khoj}/database/migrations/0001_khojuser.py | 0 src/{ => khoj}/database/migrations/0002_googleuser.py | 0 src/{ => khoj}/database/migrations/0003_vector_extension.py | 0 .../database/migrations/0004_content_types_and_more.py | 0 .../database/migrations/0005_embeddings_corpus_id.py | 0 src/{ => khoj}/database/migrations/0006_embeddingsdates.py | 0 src/{ => khoj}/database/migrations/0007_add_conversation.py | 0 .../migrations/0008_alter_conversation_conversation_log.py | 0 src/{ => khoj}/database/migrations/0009_khojapiuser.py | 0 .../database/migrations/0010_chatmodeloptions_and_more.py | 0 .../migrations/0010_rename_embeddings_entry_and_more.py | 0 .../database/migrations/0011_merge_20231102_0138.py | 0 .../database/migrations/0012_entry_file_source.py | 0 src/{ => khoj}/database/migrations/0013_subscription.py | 0 .../database/migrations/0014_alter_googleuser_picture.py | 0 .../database/migrations/0015_alter_subscription_user.py | 0 .../migrations/0016_alter_subscription_renewal_date.py | 0 src/{ => khoj}/database/migrations/0017_searchmodel.py | 0 .../migrations/0018_searchmodelconfig_delete_searchmodel.py | 0 .../0019_alter_googleuser_family_name_and_more.py | 0 src/{ => khoj}/database/migrations/__init__.py | 0 src/{ => khoj}/database/models/__init__.py | 0 src/{ => khoj}/database/tests.py | 0 src/khoj/main.py | 2 +- src/{ => khoj}/manage.py | 2 +- src/khoj/migrations/migrate_server_pg.py | 2 +- src/khoj/processor/github/github_to_entries.py | 2 +- src/khoj/processor/markdown/markdown_to_entries.py | 2 +- src/khoj/processor/notion/notion_to_entries.py | 2 +- src/khoj/processor/org_mode/org_to_entries.py | 2 +- src/khoj/processor/pdf/pdf_to_entries.py | 2 +- src/khoj/processor/plaintext/plaintext_to_entries.py | 2 +- src/khoj/processor/text_to_entries.py | 4 ++-- src/khoj/routers/api.py | 6 +++--- src/khoj/routers/auth.py | 4 ++-- src/khoj/routers/helpers.py | 4 ++-- src/khoj/routers/indexer.py | 2 +- src/khoj/routers/subscription.py | 2 +- src/khoj/routers/web_client.py | 6 +++--- src/khoj/search_type/text_search.py | 4 ++-- src/khoj/utils/fs_syncer.py | 2 +- src/khoj/utils/initialization.py | 4 ++-- tests/conftest.py | 2 +- tests/helpers.py | 2 +- tests/test_client.py | 4 ++-- tests/test_multiple_users.py | 4 ++-- tests/test_openai_chat_director.py | 2 +- tests/test_plaintext_to_entries.py | 2 +- tests/test_text_search.py | 2 +- 62 files changed, 48 insertions(+), 48 deletions(-) rename src/{ => khoj}/app/README.md (100%) rename src/{ => khoj}/app/__init__.py (100%) rename src/{ => khoj}/app/settings.py (97%) rename src/{ => khoj}/app/urls.py (100%) rename src/{ => khoj}/app/wsgi.py (100%) rename src/{ => khoj}/database/__init__.py (100%) rename src/{ => khoj}/database/adapters/__init__.py (99%) rename src/{ => khoj}/database/admin.py (93%) rename src/{ => khoj}/database/apps.py (82%) rename src/{ => khoj}/database/migrations/0001_khojuser.py (100%) rename src/{ => khoj}/database/migrations/0002_googleuser.py (100%) rename src/{ => khoj}/database/migrations/0003_vector_extension.py (100%) rename src/{ => khoj}/database/migrations/0004_content_types_and_more.py (100%) rename src/{ => khoj}/database/migrations/0005_embeddings_corpus_id.py (100%) rename src/{ => khoj}/database/migrations/0006_embeddingsdates.py (100%) rename src/{ => khoj}/database/migrations/0007_add_conversation.py (100%) rename src/{ => khoj}/database/migrations/0008_alter_conversation_conversation_log.py (100%) rename src/{ => khoj}/database/migrations/0009_khojapiuser.py (100%) rename src/{ => khoj}/database/migrations/0010_chatmodeloptions_and_more.py (100%) rename src/{ => khoj}/database/migrations/0010_rename_embeddings_entry_and_more.py (100%) rename src/{ => khoj}/database/migrations/0011_merge_20231102_0138.py (100%) rename src/{ => khoj}/database/migrations/0012_entry_file_source.py (100%) rename src/{ => khoj}/database/migrations/0013_subscription.py (100%) rename src/{ => khoj}/database/migrations/0014_alter_googleuser_picture.py (100%) rename src/{ => khoj}/database/migrations/0015_alter_subscription_user.py (100%) rename src/{ => khoj}/database/migrations/0016_alter_subscription_renewal_date.py (100%) rename src/{ => khoj}/database/migrations/0017_searchmodel.py (100%) rename src/{ => khoj}/database/migrations/0018_searchmodelconfig_delete_searchmodel.py (100%) rename src/{ => khoj}/database/migrations/0019_alter_googleuser_family_name_and_more.py (100%) rename src/{ => khoj}/database/migrations/__init__.py (100%) rename src/{ => khoj}/database/models/__init__.py (100%) rename src/{ => khoj}/database/tests.py (100%) rename src/{ => khoj}/manage.py (89%) diff --git a/Dockerfile b/Dockerfile index 9882a236..4512e884 100644 --- a/Dockerfile +++ b/Dockerfile @@ -17,7 +17,7 @@ RUN sed -i 's/dynamic = \["version"\]/version = "0.0.0"/' pyproject.toml && \ COPY . . # Set the PYTHONPATH environment variable in order for it to find the Django app. -ENV PYTHONPATH=/app/src:$PYTHONPATH +ENV PYTHONPATH=/app/src/khoj:$PYTHONPATH # Run the Application # There are more arguments required for the application to run, diff --git a/prod.Dockerfile b/prod.Dockerfile index 693a3a8b..a935f3c6 100644 --- a/prod.Dockerfile +++ b/prod.Dockerfile @@ -20,7 +20,7 @@ COPY . . RUN apt install vim -y # Set the PYTHONPATH environment variable in order for it to find the Django app. -ENV PYTHONPATH=/app/src:$PYTHONPATH +ENV PYTHONPATH=/app/src/khoj:$PYTHONPATH # Run the Application # There are more arguments required for the application to run, diff --git a/pytest.ini b/pytest.ini index b3e418d0..36d842ae 100644 --- a/pytest.ini +++ b/pytest.ini @@ -1,5 +1,5 @@ [pytest] -DJANGO_SETTINGS_MODULE = app.settings +DJANGO_SETTINGS_MODULE = khoj.app.settings pythonpath = . src testpaths = tests markers = diff --git a/src/app/README.md b/src/khoj/app/README.md similarity index 100% rename from src/app/README.md rename to src/khoj/app/README.md diff --git a/src/app/__init__.py b/src/khoj/app/__init__.py similarity index 100% rename from src/app/__init__.py rename to src/khoj/app/__init__.py diff --git a/src/app/settings.py b/src/khoj/app/settings.py similarity index 97% rename from src/app/settings.py rename to src/khoj/app/settings.py index 0803081d..721bcc87 100644 --- a/src/app/settings.py +++ b/src/khoj/app/settings.py @@ -14,7 +14,7 @@ from pathlib import Path import os # Build paths inside the project like this: BASE_DIR / 'subdir'. -BASE_DIR = Path(__file__).resolve().parent.parent.parent +BASE_DIR = Path(__file__).resolve().parent.parent.parent.parent # Quick-start development settings - unsuitable for production @@ -53,7 +53,7 @@ SESSION_COOKIE_SAMESITE = "None" INSTALLED_APPS = [ "django.contrib.auth", "django.contrib.contenttypes", - "database.apps.DatabaseConfig", + "khoj.database.apps.DatabaseConfig", "django.contrib.admin", "django.contrib.sessions", "django.contrib.messages", diff --git a/src/app/urls.py b/src/khoj/app/urls.py similarity index 100% rename from src/app/urls.py rename to src/khoj/app/urls.py diff --git a/src/app/wsgi.py b/src/khoj/app/wsgi.py similarity index 100% rename from src/app/wsgi.py rename to src/khoj/app/wsgi.py diff --git a/src/khoj/configure.py b/src/khoj/configure.py index 5ed92727..d34205d9 100644 --- a/src/khoj/configure.py +++ b/src/khoj/configure.py @@ -20,8 +20,8 @@ from starlette.authentication import ( ) # Internal Packages -from database.models import KhojUser, Subscription -from database.adapters import get_all_users, get_or_create_search_model +from khoj.database.models import KhojUser, Subscription +from khoj.database.adapters import get_all_users, get_or_create_search_model from khoj.processor.embeddings import CrossEncoderModel, EmbeddingsModel from khoj.routers.indexer import configure_content, load_content, configure_search from khoj.utils import constants, state @@ -45,7 +45,7 @@ class UserAuthenticationBackend(AuthenticationBackend): def __init__( self, ): - from database.models import KhojUser, KhojApiUser + from khoj.database.models import KhojUser, KhojApiUser self.khojuser_manager = KhojUser.objects self.khojapiuser_manager = KhojApiUser.objects diff --git a/src/database/__init__.py b/src/khoj/database/__init__.py similarity index 100% rename from src/database/__init__.py rename to src/khoj/database/__init__.py diff --git a/src/database/adapters/__init__.py b/src/khoj/database/adapters/__init__.py similarity index 99% rename from src/database/adapters/__init__.py rename to src/khoj/database/adapters/__init__.py index 4141d3bb..ea0c0a85 100644 --- a/src/database/adapters/__init__.py +++ b/src/khoj/database/adapters/__init__.py @@ -17,7 +17,7 @@ from asgiref.sync import sync_to_async from fastapi import HTTPException -from database.models import ( +from khoj.database.models import ( KhojUser, GoogleUser, KhojApiUser, diff --git a/src/database/admin.py b/src/khoj/database/admin.py similarity index 93% rename from src/database/admin.py rename to src/khoj/database/admin.py index 8d2130ba..69f15b2f 100644 --- a/src/database/admin.py +++ b/src/khoj/database/admin.py @@ -3,7 +3,7 @@ from django.contrib.auth.admin import UserAdmin # Register your models here. -from database.models import ( +from khoj.database.models import ( KhojUser, ChatModelOptions, OpenAIProcessorConversationConfig, diff --git a/src/database/apps.py b/src/khoj/database/apps.py similarity index 82% rename from src/database/apps.py rename to src/khoj/database/apps.py index a3b71b13..eed64812 100644 --- a/src/database/apps.py +++ b/src/khoj/database/apps.py @@ -3,4 +3,4 @@ from django.apps import AppConfig class DatabaseConfig(AppConfig): default_auto_field = "django.db.models.BigAutoField" - name = "database" + name = "khoj.database" diff --git a/src/database/migrations/0001_khojuser.py b/src/khoj/database/migrations/0001_khojuser.py similarity index 100% rename from src/database/migrations/0001_khojuser.py rename to src/khoj/database/migrations/0001_khojuser.py diff --git a/src/database/migrations/0002_googleuser.py b/src/khoj/database/migrations/0002_googleuser.py similarity index 100% rename from src/database/migrations/0002_googleuser.py rename to src/khoj/database/migrations/0002_googleuser.py diff --git a/src/database/migrations/0003_vector_extension.py b/src/khoj/database/migrations/0003_vector_extension.py similarity index 100% rename from src/database/migrations/0003_vector_extension.py rename to src/khoj/database/migrations/0003_vector_extension.py diff --git a/src/database/migrations/0004_content_types_and_more.py b/src/khoj/database/migrations/0004_content_types_and_more.py similarity index 100% rename from src/database/migrations/0004_content_types_and_more.py rename to src/khoj/database/migrations/0004_content_types_and_more.py diff --git a/src/database/migrations/0005_embeddings_corpus_id.py b/src/khoj/database/migrations/0005_embeddings_corpus_id.py similarity index 100% rename from src/database/migrations/0005_embeddings_corpus_id.py rename to src/khoj/database/migrations/0005_embeddings_corpus_id.py diff --git a/src/database/migrations/0006_embeddingsdates.py b/src/khoj/database/migrations/0006_embeddingsdates.py similarity index 100% rename from src/database/migrations/0006_embeddingsdates.py rename to src/khoj/database/migrations/0006_embeddingsdates.py diff --git a/src/database/migrations/0007_add_conversation.py b/src/khoj/database/migrations/0007_add_conversation.py similarity index 100% rename from src/database/migrations/0007_add_conversation.py rename to src/khoj/database/migrations/0007_add_conversation.py diff --git a/src/database/migrations/0008_alter_conversation_conversation_log.py b/src/khoj/database/migrations/0008_alter_conversation_conversation_log.py similarity index 100% rename from src/database/migrations/0008_alter_conversation_conversation_log.py rename to src/khoj/database/migrations/0008_alter_conversation_conversation_log.py diff --git a/src/database/migrations/0009_khojapiuser.py b/src/khoj/database/migrations/0009_khojapiuser.py similarity index 100% rename from src/database/migrations/0009_khojapiuser.py rename to src/khoj/database/migrations/0009_khojapiuser.py diff --git a/src/database/migrations/0010_chatmodeloptions_and_more.py b/src/khoj/database/migrations/0010_chatmodeloptions_and_more.py similarity index 100% rename from src/database/migrations/0010_chatmodeloptions_and_more.py rename to src/khoj/database/migrations/0010_chatmodeloptions_and_more.py diff --git a/src/database/migrations/0010_rename_embeddings_entry_and_more.py b/src/khoj/database/migrations/0010_rename_embeddings_entry_and_more.py similarity index 100% rename from src/database/migrations/0010_rename_embeddings_entry_and_more.py rename to src/khoj/database/migrations/0010_rename_embeddings_entry_and_more.py diff --git a/src/database/migrations/0011_merge_20231102_0138.py b/src/khoj/database/migrations/0011_merge_20231102_0138.py similarity index 100% rename from src/database/migrations/0011_merge_20231102_0138.py rename to src/khoj/database/migrations/0011_merge_20231102_0138.py diff --git a/src/database/migrations/0012_entry_file_source.py b/src/khoj/database/migrations/0012_entry_file_source.py similarity index 100% rename from src/database/migrations/0012_entry_file_source.py rename to src/khoj/database/migrations/0012_entry_file_source.py diff --git a/src/database/migrations/0013_subscription.py b/src/khoj/database/migrations/0013_subscription.py similarity index 100% rename from src/database/migrations/0013_subscription.py rename to src/khoj/database/migrations/0013_subscription.py diff --git a/src/database/migrations/0014_alter_googleuser_picture.py b/src/khoj/database/migrations/0014_alter_googleuser_picture.py similarity index 100% rename from src/database/migrations/0014_alter_googleuser_picture.py rename to src/khoj/database/migrations/0014_alter_googleuser_picture.py diff --git a/src/database/migrations/0015_alter_subscription_user.py b/src/khoj/database/migrations/0015_alter_subscription_user.py similarity index 100% rename from src/database/migrations/0015_alter_subscription_user.py rename to src/khoj/database/migrations/0015_alter_subscription_user.py diff --git a/src/database/migrations/0016_alter_subscription_renewal_date.py b/src/khoj/database/migrations/0016_alter_subscription_renewal_date.py similarity index 100% rename from src/database/migrations/0016_alter_subscription_renewal_date.py rename to src/khoj/database/migrations/0016_alter_subscription_renewal_date.py diff --git a/src/database/migrations/0017_searchmodel.py b/src/khoj/database/migrations/0017_searchmodel.py similarity index 100% rename from src/database/migrations/0017_searchmodel.py rename to src/khoj/database/migrations/0017_searchmodel.py diff --git a/src/database/migrations/0018_searchmodelconfig_delete_searchmodel.py b/src/khoj/database/migrations/0018_searchmodelconfig_delete_searchmodel.py similarity index 100% rename from src/database/migrations/0018_searchmodelconfig_delete_searchmodel.py rename to src/khoj/database/migrations/0018_searchmodelconfig_delete_searchmodel.py diff --git a/src/database/migrations/0019_alter_googleuser_family_name_and_more.py b/src/khoj/database/migrations/0019_alter_googleuser_family_name_and_more.py similarity index 100% rename from src/database/migrations/0019_alter_googleuser_family_name_and_more.py rename to src/khoj/database/migrations/0019_alter_googleuser_family_name_and_more.py diff --git a/src/database/migrations/__init__.py b/src/khoj/database/migrations/__init__.py similarity index 100% rename from src/database/migrations/__init__.py rename to src/khoj/database/migrations/__init__.py diff --git a/src/database/models/__init__.py b/src/khoj/database/models/__init__.py similarity index 100% rename from src/database/models/__init__.py rename to src/khoj/database/models/__init__.py diff --git a/src/database/tests.py b/src/khoj/database/tests.py similarity index 100% rename from src/database/tests.py rename to src/khoj/database/tests.py diff --git a/src/khoj/main.py b/src/khoj/main.py index 022efcc1..cded9841 100644 --- a/src/khoj/main.py +++ b/src/khoj/main.py @@ -26,7 +26,7 @@ from django.core.management import call_command # Initialize Django sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) -os.environ.setdefault("DJANGO_SETTINGS_MODULE", "app.settings") +os.environ.setdefault("DJANGO_SETTINGS_MODULE", "khoj.app.settings") django.setup() # Initialize Django Database diff --git a/src/manage.py b/src/khoj/manage.py similarity index 89% rename from src/manage.py rename to src/khoj/manage.py index 1a64b14a..9b8f4b27 100755 --- a/src/manage.py +++ b/src/khoj/manage.py @@ -6,7 +6,7 @@ import sys def main(): """Run administrative tasks.""" - os.environ.setdefault("DJANGO_SETTINGS_MODULE", "app.settings") + os.environ.setdefault("DJANGO_SETTINGS_MODULE", "khoj.app.settings") try: from django.core.management import execute_from_command_line except ImportError as exc: diff --git a/src/khoj/migrations/migrate_server_pg.py b/src/khoj/migrations/migrate_server_pg.py index 434e27d7..097ae0d6 100644 --- a/src/khoj/migrations/migrate_server_pg.py +++ b/src/khoj/migrations/migrate_server_pg.py @@ -60,7 +60,7 @@ import logging from packaging import version from khoj.utils.yaml import load_config_from_file, save_config_to_file -from database.models import ( +from khoj.database.models import ( OpenAIProcessorConversationConfig, OfflineChatProcessorConversationConfig, ChatModelOptions, diff --git a/src/khoj/processor/github/github_to_entries.py b/src/khoj/processor/github/github_to_entries.py index 56279453..21344eca 100644 --- a/src/khoj/processor/github/github_to_entries.py +++ b/src/khoj/processor/github/github_to_entries.py @@ -13,7 +13,7 @@ from khoj.utils.rawconfig import Entry, GithubContentConfig, GithubRepoConfig from khoj.processor.markdown.markdown_to_entries import MarkdownToEntries from khoj.processor.org_mode.org_to_entries import OrgToEntries from khoj.processor.text_to_entries import TextToEntries -from database.models import Entry as DbEntry, GithubConfig, KhojUser +from khoj.database.models import Entry as DbEntry, GithubConfig, KhojUser logger = logging.getLogger(__name__) diff --git a/src/khoj/processor/markdown/markdown_to_entries.py b/src/khoj/processor/markdown/markdown_to_entries.py index 0dd71740..08ba4a77 100644 --- a/src/khoj/processor/markdown/markdown_to_entries.py +++ b/src/khoj/processor/markdown/markdown_to_entries.py @@ -10,7 +10,7 @@ from khoj.processor.text_to_entries import TextToEntries from khoj.utils.helpers import timer from khoj.utils.constants import empty_escape_sequences from khoj.utils.rawconfig import Entry -from database.models import Entry as DbEntry, KhojUser +from khoj.database.models import Entry as DbEntry, KhojUser logger = logging.getLogger(__name__) diff --git a/src/khoj/processor/notion/notion_to_entries.py b/src/khoj/processor/notion/notion_to_entries.py index 7a88e2a1..1e3c0553 100644 --- a/src/khoj/processor/notion/notion_to_entries.py +++ b/src/khoj/processor/notion/notion_to_entries.py @@ -10,7 +10,7 @@ from khoj.utils.helpers import timer from khoj.utils.rawconfig import Entry, NotionContentConfig from khoj.processor.text_to_entries import TextToEntries from khoj.utils.rawconfig import Entry -from database.models import Entry as DbEntry, KhojUser, NotionConfig +from khoj.database.models import Entry as DbEntry, KhojUser, NotionConfig from enum import Enum diff --git a/src/khoj/processor/org_mode/org_to_entries.py b/src/khoj/processor/org_mode/org_to_entries.py index e42b7498..80ccdb08 100644 --- a/src/khoj/processor/org_mode/org_to_entries.py +++ b/src/khoj/processor/org_mode/org_to_entries.py @@ -9,7 +9,7 @@ from khoj.processor.text_to_entries import TextToEntries from khoj.utils.helpers import timer from khoj.utils.rawconfig import Entry from khoj.utils import state -from database.models import Entry as DbEntry, KhojUser +from khoj.database.models import Entry as DbEntry, KhojUser logger = logging.getLogger(__name__) diff --git a/src/khoj/processor/pdf/pdf_to_entries.py b/src/khoj/processor/pdf/pdf_to_entries.py index 3a47096a..62f94d32 100644 --- a/src/khoj/processor/pdf/pdf_to_entries.py +++ b/src/khoj/processor/pdf/pdf_to_entries.py @@ -11,7 +11,7 @@ from langchain.document_loaders import PyMuPDFLoader from khoj.processor.text_to_entries import TextToEntries from khoj.utils.helpers import timer from khoj.utils.rawconfig import Entry -from database.models import Entry as DbEntry, KhojUser +from khoj.database.models import Entry as DbEntry, KhojUser logger = logging.getLogger(__name__) diff --git a/src/khoj/processor/plaintext/plaintext_to_entries.py b/src/khoj/processor/plaintext/plaintext_to_entries.py index d42dae30..081cc327 100644 --- a/src/khoj/processor/plaintext/plaintext_to_entries.py +++ b/src/khoj/processor/plaintext/plaintext_to_entries.py @@ -9,7 +9,7 @@ from bs4 import BeautifulSoup from khoj.processor.text_to_entries import TextToEntries from khoj.utils.helpers import timer from khoj.utils.rawconfig import Entry -from database.models import Entry as DbEntry, KhojUser +from khoj.database.models import Entry as DbEntry, KhojUser logger = logging.getLogger(__name__) diff --git a/src/khoj/processor/text_to_entries.py b/src/khoj/processor/text_to_entries.py index ac42105a..109c58e6 100644 --- a/src/khoj/processor/text_to_entries.py +++ b/src/khoj/processor/text_to_entries.py @@ -13,8 +13,8 @@ from khoj.utils.helpers import is_none_or_empty, timer, batcher # Internal Packages from khoj.utils.rawconfig import Entry from khoj.search_filter.date_filter import DateFilter -from database.models import KhojUser, Entry as DbEntry, EntryDates -from database.adapters import EntryAdapters +from khoj.database.models import KhojUser, Entry as DbEntry, EntryDates +from khoj.database.adapters import EntryAdapters logger = logging.getLogger(__name__) diff --git a/src/khoj/routers/api.py b/src/khoj/routers/api.py index 6d67fcbe..f2e5c966 100644 --- a/src/khoj/routers/api.py +++ b/src/khoj/routers/api.py @@ -44,9 +44,9 @@ from khoj.processor.conversation.openai.gpt import extract_questions from khoj.processor.conversation.gpt4all.chat_model import extract_questions_offline from fastapi.requests import Request -from database import adapters -from database.adapters import EntryAdapters, ConversationAdapters -from database.models import ( +from khoj.database import adapters +from khoj.database.adapters import EntryAdapters, ConversationAdapters +from khoj.database.models import ( LocalMarkdownConfig, LocalOrgConfig, LocalPdfConfig, diff --git a/src/khoj/routers/auth.py b/src/khoj/routers/auth.py index a9a88325..df119548 100644 --- a/src/khoj/routers/auth.py +++ b/src/khoj/routers/auth.py @@ -15,8 +15,8 @@ from google.oauth2 import id_token from google.auth.transport import requests as google_requests # Internal Packages -from database.adapters import get_khoj_tokens, get_or_create_user, create_khoj_token, delete_khoj_token -from database.models import KhojApiUser +from khoj.database.adapters import get_khoj_tokens, get_or_create_user, create_khoj_token, delete_khoj_token +from khoj.database.models import KhojApiUser from khoj.routers.helpers import update_telemetry_state from khoj.utils import state diff --git a/src/khoj/routers/helpers.py b/src/khoj/routers/helpers.py index 272f962d..63991263 100644 --- a/src/khoj/routers/helpers.py +++ b/src/khoj/routers/helpers.py @@ -18,8 +18,8 @@ from khoj.utils.helpers import ConversationCommand, log_telemetry from khoj.processor.conversation.openai.gpt import converse from khoj.processor.conversation.gpt4all.chat_model import converse_offline from khoj.processor.conversation.utils import message_to_log, ThreadedGenerator -from database.models import KhojUser, Subscription -from database.adapters import ConversationAdapters +from khoj.database.models import KhojUser, Subscription +from khoj.database.adapters import ConversationAdapters logger = logging.getLogger(__name__) diff --git a/src/khoj/routers/indexer.py b/src/khoj/routers/indexer.py index ccb65063..7a7be03e 100644 --- a/src/khoj/routers/indexer.py +++ b/src/khoj/routers/indexer.py @@ -30,7 +30,7 @@ from khoj.utils.config import ( ContentIndex, SearchModels, ) -from database.models import ( +from khoj.database.models import ( KhojUser, GithubConfig, NotionConfig, diff --git a/src/khoj/routers/subscription.py b/src/khoj/routers/subscription.py index 62e50d72..edcbc135 100644 --- a/src/khoj/routers/subscription.py +++ b/src/khoj/routers/subscription.py @@ -10,7 +10,7 @@ from starlette.authentication import requires import stripe # Internal Packages -from database import adapters +from khoj.database import adapters # Stripe integration for Khoj Cloud Subscription diff --git a/src/khoj/routers/web_client.py b/src/khoj/routers/web_client.py index f30499d8..dab16fa8 100644 --- a/src/khoj/routers/web_client.py +++ b/src/khoj/routers/web_client.py @@ -8,8 +8,8 @@ from fastapi import Request from fastapi.responses import HTMLResponse, FileResponse, RedirectResponse from fastapi.templating import Jinja2Templates from starlette.authentication import requires -from database import adapters -from database.models import KhojUser +from khoj.database import adapters +from khoj.database.models import KhojUser from khoj.utils.rawconfig import ( GithubContentConfig, GithubRepoConfig, @@ -18,7 +18,7 @@ from khoj.utils.rawconfig import ( # Internal Packages from khoj.utils import constants, state -from database.adapters import ( +from khoj.database.adapters import ( EntryAdapters, get_user_github_config, get_user_notion_config, diff --git a/src/khoj/search_type/text_search.py b/src/khoj/search_type/text_search.py index 7e295903..a78ce522 100644 --- a/src/khoj/search_type/text_search.py +++ b/src/khoj/search_type/text_search.py @@ -19,8 +19,8 @@ from khoj.utils.state import SearchType from khoj.utils.rawconfig import SearchResponse, Entry from khoj.utils.jsonl import load_jsonl from khoj.processor.text_to_entries import TextToEntries -from database.adapters import EntryAdapters -from database.models import KhojUser, Entry as DbEntry +from khoj.database.adapters import EntryAdapters +from khoj.database.models import KhojUser, Entry as DbEntry logger = logging.getLogger(__name__) diff --git a/src/khoj/utils/fs_syncer.py b/src/khoj/utils/fs_syncer.py index fc7e4a2d..57c79d9d 100644 --- a/src/khoj/utils/fs_syncer.py +++ b/src/khoj/utils/fs_syncer.py @@ -7,7 +7,7 @@ from bs4 import BeautifulSoup from khoj.utils.helpers import get_absolute_path, is_none_or_empty from khoj.utils.rawconfig import TextContentConfig from khoj.utils.config import SearchType -from database.models import LocalMarkdownConfig, LocalOrgConfig, LocalPdfConfig, LocalPlaintextConfig +from khoj.database.models import LocalMarkdownConfig, LocalOrgConfig, LocalPdfConfig, LocalPlaintextConfig logger = logging.getLogger(__name__) diff --git a/src/khoj/utils/initialization.py b/src/khoj/utils/initialization.py index b2d7aad5..ffc4d47e 100644 --- a/src/khoj/utils/initialization.py +++ b/src/khoj/utils/initialization.py @@ -1,7 +1,7 @@ import logging import os -from database.models import ( +from khoj.database.models import ( KhojUser, OfflineChatProcessorConversationConfig, OpenAIProcessorConversationConfig, @@ -11,7 +11,7 @@ from database.models import ( from khoj.utils.constants import default_offline_chat_model, default_online_chat_model from khoj.processor.conversation.utils import model_to_prompt_size, model_to_tokenizer -from database.adapters import ConversationAdapters +from khoj.database.adapters import ConversationAdapters logger = logging.getLogger(__name__) diff --git a/tests/conftest.py b/tests/conftest.py index 902994a0..d1df341a 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -26,7 +26,7 @@ from khoj.utils.rawconfig import ( from khoj.utils import state, fs_syncer from khoj.routers.indexer import configure_content from khoj.processor.org_mode.org_to_entries import OrgToEntries -from database.models import ( +from khoj.database.models import ( KhojApiUser, LocalOrgConfig, LocalMarkdownConfig, diff --git a/tests/helpers.py b/tests/helpers.py index 079eb475..d0f9babc 100644 --- a/tests/helpers.py +++ b/tests/helpers.py @@ -1,7 +1,7 @@ import factory import os -from database.models import ( +from khoj.database.models import ( KhojUser, KhojApiUser, ChatModelOptions, diff --git a/tests/test_client.py b/tests/test_client.py index 5324e3c1..4e707e5f 100644 --- a/tests/test_client.py +++ b/tests/test_client.py @@ -16,8 +16,8 @@ from khoj.utils.state import search_models, content_index, config from khoj.search_type import text_search, image_search from khoj.utils.rawconfig import ContentConfig, SearchConfig from khoj.processor.org_mode.org_to_entries import OrgToEntries -from database.models import KhojUser, KhojApiUser -from database.adapters import EntryAdapters +from khoj.database.models import KhojUser, KhojApiUser +from khoj.database.adapters import EntryAdapters # Test diff --git a/tests/test_multiple_users.py b/tests/test_multiple_users.py index a94c173e..b5785350 100644 --- a/tests/test_multiple_users.py +++ b/tests/test_multiple_users.py @@ -17,8 +17,8 @@ from khoj.utils.state import search_models, content_index, config from khoj.search_type import text_search, image_search from khoj.utils.rawconfig import ContentConfig, SearchConfig from khoj.processor.org_mode.org_to_entries import OrgToEntries -from database.models import KhojUser, KhojApiUser -from database.adapters import EntryAdapters +from khoj.database.models import KhojUser, KhojApiUser +from khoj.database.adapters import EntryAdapters # ---------------------------------------------------------------------------------------------------- diff --git a/tests/test_openai_chat_director.py b/tests/test_openai_chat_director.py index 07c4e0d8..b4e63364 100644 --- a/tests/test_openai_chat_director.py +++ b/tests/test_openai_chat_director.py @@ -10,7 +10,7 @@ from khoj.processor.conversation import prompts # Internal Packages from khoj.processor.conversation.utils import message_to_log from tests.helpers import ConversationFactory -from database.models import KhojUser +from khoj.database.models import KhojUser # Initialize variables for tests api_key = os.getenv("OPENAI_API_KEY") diff --git a/tests/test_plaintext_to_entries.py b/tests/test_plaintext_to_entries.py index 23b0d652..0bbba6de 100644 --- a/tests/test_plaintext_to_entries.py +++ b/tests/test_plaintext_to_entries.py @@ -7,7 +7,7 @@ from pathlib import Path from khoj.utils.fs_syncer import get_plaintext_files from khoj.utils.rawconfig import TextContentConfig from khoj.processor.plaintext.plaintext_to_entries import PlaintextToEntries -from database.models import LocalPlaintextConfig, KhojUser +from khoj.database.models import LocalPlaintextConfig, KhojUser def test_plaintext_file(tmp_path): diff --git a/tests/test_text_search.py b/tests/test_text_search.py index b4507feb..025c1241 100644 --- a/tests/test_text_search.py +++ b/tests/test_text_search.py @@ -13,7 +13,7 @@ from khoj.utils.rawconfig import ContentConfig, SearchConfig from khoj.processor.org_mode.org_to_entries import OrgToEntries from khoj.processor.github.github_to_entries import GithubToEntries from khoj.utils.fs_syncer import collect_files, get_org_files -from database.models import LocalOrgConfig, KhojUser, Entry, GithubConfig +from khoj.database.models import LocalOrgConfig, KhojUser, Entry, GithubConfig logger = logging.getLogger(__name__)