From 19e042037a0e99f8efd551468a8ac2a447d35759 Mon Sep 17 00:00:00 2001 From: Debanjum Singh Solanky Date: Tue, 21 Nov 2023 12:48:12 -0800 Subject: [PATCH 1/3] Run isort with black profile to avoid conflicts between the two --- .pre-commit-config.yaml | 1 + pyproject.toml | 3 +++ 2 files changed, 4 insertions(+) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index b7253585..e5fc54cc 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -9,6 +9,7 @@ repos: hooks: - id: isort name: isort (python) + args: ["--profile", "black", "--filter-files"] - repo: https://github.com/pre-commit/pre-commit-hooks rev: v4.4.0 diff --git a/pyproject.toml b/pyproject.toml index 17c11e77..63a50fac 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -128,6 +128,9 @@ warn_unused_ignores = false [tool.black] line-length = 120 +[tool.isort] +profile = "black" + [tool.pytest.ini_options] addopts = "--strict-markers" markers = [ From 341abf03ff0ba3e311ca7bab55060272f4437eed Mon Sep 17 00:00:00 2001 From: sabaimran Date: Tue, 21 Nov 2023 12:55:09 -0800 Subject: [PATCH 2/3] Handle none for search_type and use equals comparator rather than in for determining Notion type --- src/khoj/routers/indexer.py | 42 +++++++++++++------------------------ 1 file changed, 15 insertions(+), 27 deletions(-) diff --git a/src/khoj/routers/indexer.py b/src/khoj/routers/indexer.py index 7a7be03e..9362c4b3 100644 --- a/src/khoj/routers/indexer.py +++ b/src/khoj/routers/indexer.py @@ -1,40 +1,25 @@ -# Standard Packages -import logging -from typing import Optional, Union, Dict import asyncio +import logging +from typing import Dict, Optional, Union -# External Packages from fastapi import APIRouter, Header, Request, Response, UploadFile from pydantic import BaseModel from starlette.authentication import requires -# Internal Packages -from khoj.utils import state, constants +from khoj.database.models import GithubConfig, KhojUser, NotionConfig +from khoj.processor.github.github_to_entries import GithubToEntries from khoj.processor.markdown.markdown_to_entries import MarkdownToEntries +from khoj.processor.notion.notion_to_entries import NotionToEntries from khoj.processor.org_mode.org_to_entries import OrgToEntries from khoj.processor.pdf.pdf_to_entries import PdfToEntries -from khoj.processor.github.github_to_entries import GithubToEntries -from khoj.processor.notion.notion_to_entries import NotionToEntries from khoj.processor.plaintext.plaintext_to_entries import PlaintextToEntries -from khoj.search_type import text_search, image_search from khoj.routers.helpers import update_telemetry_state -from khoj.utils.yaml import save_config_to_file_updated_state -from khoj.utils.config import SearchModels +from khoj.search_type import image_search, text_search +from khoj.utils import constants, state +from khoj.utils.config import ContentIndex, SearchModels from khoj.utils.helpers import LRU, get_file_type -from khoj.utils.rawconfig import ( - ContentConfig, - FullConfig, - SearchConfig, -) -from khoj.utils.config import ( - ContentIndex, - SearchModels, -) -from khoj.database.models import ( - KhojUser, - GithubConfig, - NotionConfig, -) +from khoj.utils.rawconfig import ContentConfig, FullConfig, SearchConfig +from khoj.utils.yaml import save_config_to_file_updated_state logger = logging.getLogger(__name__) @@ -189,6 +174,9 @@ def configure_content( content_index = ContentIndex() success = True + if t == None: + t = state.SearchType.All + if t is not None and t in [type.value for type in state.SearchType]: t = state.SearchType(t) @@ -315,7 +303,7 @@ def configure_content( # Initialize Notion Search notion_config = NotionConfig.objects.filter(user=user).first() if ( - search_type == state.SearchType.All.value or search_type in state.SearchType.Notion.value + search_type == state.SearchType.All.value or search_type == state.SearchType.Notion.value ) and notion_config: logger.info("🔌 Setting up search for notion") text_search.setup( @@ -328,7 +316,7 @@ def configure_content( ) except Exception as e: - logger.error(f"🚨 Failed to setup GitHub: {e}", exc_info=True) + logger.error(f"🚨 Failed to setup Notion: {e}", exc_info=True) success = False # Invalidate Query Cache From 6d9091bef5bf260f0601e69319bf8e6bb3d5c9d3 Mon Sep 17 00:00:00 2001 From: Debanjum Singh Solanky Date: Tue, 21 Nov 2023 13:02:57 -0800 Subject: [PATCH 3/3] Disable isort for now --- .pre-commit-config.yaml | 7 ------- 1 file changed, 7 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index e5fc54cc..77d4ec6c 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -4,13 +4,6 @@ repos: hooks: - id: black -- repo: https://github.com/pycqa/isort - rev: 5.12.0 - hooks: - - id: isort - name: isort (python) - args: ["--profile", "black", "--filter-files"] - - repo: https://github.com/pre-commit/pre-commit-hooks rev: v4.4.0 hooks: