mirror of
https://github.com/khoaliber/khoj.git
synced 2026-03-02 05:29:12 +00:00
Move tests out to project root. Use absolute import in project
tests/ directory in project root is more standard. Just had to use absolute path for internal module imports to get it to work
This commit is contained in:
@@ -8,10 +8,10 @@ import uvicorn
|
||||
from fastapi import FastAPI
|
||||
|
||||
# Internal Packages
|
||||
from search_type import asymmetric, symmetric_ledger, image_search
|
||||
from utils.helpers import get_from_dict
|
||||
from utils.cli import cli
|
||||
from utils.config import SearchType, SearchModels, TextSearchConfig, ImageSearchConfig, SearchConfig
|
||||
from src.search_type import asymmetric, symmetric_ledger, image_search
|
||||
from src.utils.helpers import get_from_dict
|
||||
from src.utils.cli import cli
|
||||
from src.utils.config import SearchType, SearchModels, TextSearchConfig, ImageSearchConfig, SearchConfig
|
||||
|
||||
|
||||
# Application Global State
|
||||
|
||||
@@ -8,8 +8,8 @@ import glob
|
||||
import gzip
|
||||
|
||||
# Internal Packages
|
||||
from processor.org_mode import orgnode
|
||||
from utils.helpers import get_absolute_path, is_none_or_empty
|
||||
from src.processor.org_mode import orgnode
|
||||
from src.utils.helpers import get_absolute_path, is_none_or_empty
|
||||
|
||||
|
||||
# Define Functions
|
||||
|
||||
@@ -8,8 +8,8 @@ import glob
|
||||
import gzip
|
||||
|
||||
# Internal Packages
|
||||
from processor.org_mode import orgnode
|
||||
from utils.helpers import get_absolute_path, is_none_or_empty
|
||||
from src.processor.org_mode import orgnode
|
||||
from src.utils.helpers import get_absolute_path, is_none_or_empty
|
||||
|
||||
|
||||
# Define Functions
|
||||
|
||||
@@ -15,9 +15,9 @@ import torch
|
||||
from sentence_transformers import SentenceTransformer, CrossEncoder, util
|
||||
|
||||
# Internal Packages
|
||||
from utils.helpers import get_absolute_path, resolve_absolute_path
|
||||
from processor.org_mode.org_to_jsonl import org_to_jsonl
|
||||
from utils.config import TextSearchModel, TextSearchConfig
|
||||
from src.utils.helpers import get_absolute_path, resolve_absolute_path
|
||||
from src.processor.org_mode.org_to_jsonl import org_to_jsonl
|
||||
from src.utils.config import TextSearchModel, TextSearchConfig
|
||||
|
||||
|
||||
def initialize_model():
|
||||
@@ -106,7 +106,7 @@ def explicit_filter(hits, entries, required_words, blocked_words):
|
||||
hits_by_word_set = [(set(word.lower()
|
||||
for word
|
||||
in re.split(
|
||||
',|\.| |\]|\[\(|\)|\{|\}',
|
||||
r',|\.| |\]|\[\(|\)|\{|\}',
|
||||
entries[hit['corpus_id']])
|
||||
if word != ""),
|
||||
hit)
|
||||
|
||||
@@ -10,9 +10,9 @@ from tqdm import trange
|
||||
import torch
|
||||
|
||||
# Internal Packages
|
||||
from utils.helpers import get_absolute_path, resolve_absolute_path
|
||||
import utils.exiftool as exiftool
|
||||
from utils.config import ImageSearchModel, ImageSearchConfig
|
||||
from src.utils.helpers import get_absolute_path, resolve_absolute_path
|
||||
import src.utils.exiftool as exiftool
|
||||
from src.utils.config import ImageSearchModel, ImageSearchConfig
|
||||
|
||||
|
||||
def initialize_model():
|
||||
|
||||
@@ -13,9 +13,9 @@ import torch
|
||||
from sentence_transformers import SentenceTransformer, CrossEncoder, util
|
||||
|
||||
# Internal Packages
|
||||
from utils.helpers import get_absolute_path, resolve_absolute_path
|
||||
from processor.ledger.beancount_to_jsonl import beancount_to_jsonl
|
||||
from utils.config import TextSearchModel, TextSearchConfig
|
||||
from src.utils.helpers import get_absolute_path, resolve_absolute_path
|
||||
from src.processor.ledger.beancount_to_jsonl import beancount_to_jsonl
|
||||
from src.utils.config import TextSearchModel, TextSearchConfig
|
||||
|
||||
|
||||
def initialize_model():
|
||||
@@ -98,7 +98,7 @@ def explicit_filter(hits, entries, required_words, blocked_words):
|
||||
hits_by_word_set = [(set(word.lower()
|
||||
for word
|
||||
in re.split(
|
||||
',|\.| |\]|\[\(|\)|\{|\}',
|
||||
r',|\.| |\]|\[\(|\)|\{|\}',
|
||||
entries[hit['corpus_id']])
|
||||
if word != ""),
|
||||
hit)
|
||||
|
||||
@@ -6,7 +6,7 @@ import pathlib
|
||||
import yaml
|
||||
|
||||
# Internal Packages
|
||||
from utils.helpers import is_none_or_empty, get_absolute_path, resolve_absolute_path, get_from_dict, merge_dicts
|
||||
from src.utils.helpers import is_none_or_empty, get_absolute_path, resolve_absolute_path, get_from_dict, merge_dicts
|
||||
|
||||
def cli(args=None):
|
||||
if is_none_or_empty(args):
|
||||
|
||||
@@ -4,7 +4,7 @@ from dataclasses import dataclass
|
||||
from pathlib import Path
|
||||
|
||||
# Internal Packages
|
||||
from utils.helpers import get_from_dict
|
||||
from src.utils.helpers import get_from_dict
|
||||
|
||||
|
||||
class SearchType(str, Enum):
|
||||
|
||||
|
Before Width: | Height: | Size: 170 KiB After Width: | Height: | Size: 170 KiB |
|
Before Width: | Height: | Size: 330 KiB After Width: | Height: | Size: 330 KiB |
|
Before Width: | Height: | Size: 268 KiB After Width: | Height: | Size: 268 KiB |
@@ -2,7 +2,7 @@
|
||||
from pathlib import Path
|
||||
|
||||
# Internal Packages
|
||||
from utils.cli import cli
|
||||
from src.utils.cli import cli
|
||||
|
||||
|
||||
# Test
|
||||
@@ -1,4 +1,4 @@
|
||||
from utils import helpers
|
||||
from src.utils import helpers
|
||||
|
||||
def test_get_from_null_dict():
|
||||
# null handling
|
||||
@@ -6,10 +6,10 @@ import pytest
|
||||
from fastapi.testclient import TestClient
|
||||
|
||||
# Internal Packages
|
||||
from main import app, search_config, model
|
||||
from search_type import asymmetric, image_search
|
||||
from utils.config import SearchConfig, TextSearchConfig, ImageSearchConfig
|
||||
from utils.helpers import resolve_absolute_path
|
||||
from src.main import app, search_config, model
|
||||
from src.search_type import asymmetric, image_search
|
||||
from src.utils.config import SearchConfig, TextSearchConfig, ImageSearchConfig
|
||||
from src.utils.helpers import resolve_absolute_path
|
||||
|
||||
|
||||
# Arrange
|
||||
Reference in New Issue
Block a user