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:
Debanjum Singh Solanky 2021-09-30 04:12:14 -07:00
parent 58bb420f69
commit d2905c4be6
18 changed files with 27 additions and 27 deletions

View file

@ -8,10 +8,10 @@ import uvicorn
from fastapi import FastAPI from fastapi import FastAPI
# Internal Packages # Internal Packages
from search_type import asymmetric, symmetric_ledger, image_search from src.search_type import asymmetric, symmetric_ledger, image_search
from utils.helpers import get_from_dict from src.utils.helpers import get_from_dict
from utils.cli import cli from src.utils.cli import cli
from utils.config import SearchType, SearchModels, TextSearchConfig, ImageSearchConfig, SearchConfig from src.utils.config import SearchType, SearchModels, TextSearchConfig, ImageSearchConfig, SearchConfig
# Application Global State # Application Global State

View file

@ -8,8 +8,8 @@ import glob
import gzip import gzip
# Internal Packages # Internal Packages
from processor.org_mode import orgnode from src.processor.org_mode import orgnode
from utils.helpers import get_absolute_path, is_none_or_empty from src.utils.helpers import get_absolute_path, is_none_or_empty
# Define Functions # Define Functions

View file

@ -8,8 +8,8 @@ import glob
import gzip import gzip
# Internal Packages # Internal Packages
from processor.org_mode import orgnode from src.processor.org_mode import orgnode
from utils.helpers import get_absolute_path, is_none_or_empty from src.utils.helpers import get_absolute_path, is_none_or_empty
# Define Functions # Define Functions

View file

@ -15,9 +15,9 @@ import torch
from sentence_transformers import SentenceTransformer, CrossEncoder, util from sentence_transformers import SentenceTransformer, CrossEncoder, util
# Internal Packages # Internal Packages
from utils.helpers import get_absolute_path, resolve_absolute_path from src.utils.helpers import get_absolute_path, resolve_absolute_path
from processor.org_mode.org_to_jsonl import org_to_jsonl from src.processor.org_mode.org_to_jsonl import org_to_jsonl
from utils.config import TextSearchModel, TextSearchConfig from src.utils.config import TextSearchModel, TextSearchConfig
def initialize_model(): def initialize_model():
@ -106,7 +106,7 @@ def explicit_filter(hits, entries, required_words, blocked_words):
hits_by_word_set = [(set(word.lower() hits_by_word_set = [(set(word.lower()
for word for word
in re.split( in re.split(
',|\.| |\]|\[\(|\)|\{|\}', r',|\.| |\]|\[\(|\)|\{|\}',
entries[hit['corpus_id']]) entries[hit['corpus_id']])
if word != ""), if word != ""),
hit) hit)

View file

@ -10,9 +10,9 @@ from tqdm import trange
import torch import torch
# Internal Packages # Internal Packages
from utils.helpers import get_absolute_path, resolve_absolute_path from src.utils.helpers import get_absolute_path, resolve_absolute_path
import utils.exiftool as exiftool import src.utils.exiftool as exiftool
from utils.config import ImageSearchModel, ImageSearchConfig from src.utils.config import ImageSearchModel, ImageSearchConfig
def initialize_model(): def initialize_model():

View file

@ -13,9 +13,9 @@ import torch
from sentence_transformers import SentenceTransformer, CrossEncoder, util from sentence_transformers import SentenceTransformer, CrossEncoder, util
# Internal Packages # Internal Packages
from utils.helpers import get_absolute_path, resolve_absolute_path from src.utils.helpers import get_absolute_path, resolve_absolute_path
from processor.ledger.beancount_to_jsonl import beancount_to_jsonl from src.processor.ledger.beancount_to_jsonl import beancount_to_jsonl
from utils.config import TextSearchModel, TextSearchConfig from src.utils.config import TextSearchModel, TextSearchConfig
def initialize_model(): def initialize_model():
@ -98,7 +98,7 @@ def explicit_filter(hits, entries, required_words, blocked_words):
hits_by_word_set = [(set(word.lower() hits_by_word_set = [(set(word.lower()
for word for word
in re.split( in re.split(
',|\.| |\]|\[\(|\)|\{|\}', r',|\.| |\]|\[\(|\)|\{|\}',
entries[hit['corpus_id']]) entries[hit['corpus_id']])
if word != ""), if word != ""),
hit) hit)

View file

@ -6,7 +6,7 @@ import pathlib
import yaml import yaml
# Internal Packages # 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): def cli(args=None):
if is_none_or_empty(args): if is_none_or_empty(args):

View file

@ -4,7 +4,7 @@ from dataclasses import dataclass
from pathlib import Path from pathlib import Path
# Internal Packages # Internal Packages
from utils.helpers import get_from_dict from src.utils.helpers import get_from_dict
class SearchType(str, Enum): class SearchType(str, Enum):

View file

Before

Width:  |  Height:  |  Size: 170 KiB

After

Width:  |  Height:  |  Size: 170 KiB

View file

Before

Width:  |  Height:  |  Size: 330 KiB

After

Width:  |  Height:  |  Size: 330 KiB

View file

Before

Width:  |  Height:  |  Size: 268 KiB

After

Width:  |  Height:  |  Size: 268 KiB

View file

@ -2,7 +2,7 @@
from pathlib import Path from pathlib import Path
# Internal Packages # Internal Packages
from utils.cli import cli from src.utils.cli import cli
# Test # Test

View file

@ -1,4 +1,4 @@
from utils import helpers from src.utils import helpers
def test_get_from_null_dict(): def test_get_from_null_dict():
# null handling # null handling

View file

@ -6,10 +6,10 @@ import pytest
from fastapi.testclient import TestClient from fastapi.testclient import TestClient
# Internal Packages # Internal Packages
from main import app, search_config, model from src.main import app, search_config, model
from search_type import asymmetric, image_search from src.search_type import asymmetric, image_search
from utils.config import SearchConfig, TextSearchConfig, ImageSearchConfig from src.utils.config import SearchConfig, TextSearchConfig, ImageSearchConfig
from utils.helpers import resolve_absolute_path from src.utils.helpers import resolve_absolute_path
# Arrange # Arrange