From 4134a5e665e99b54c8e8f99cf1074b5d3ca7a1d3 Mon Sep 17 00:00:00 2001 From: Francis Charette Migneault Date: Wed, 6 Dec 2023 18:02:12 -0500 Subject: [PATCH] fix module resolution for pytest --- .github/workflows/tests.yml | 4 +++- nlp/notebooks/nl2q_eval/query_eval.py | 2 +- nlp/notebooks/nl2query/V1/Vars_values_textsearch.py | 2 +- nlp/notebooks/stac_wrapper/query_handler.py | 3 ++- nlp/tests/test_MetricsClasses.py | 3 ++- nlp/tests/test_query_eval.py | 3 ++- setup.cfg | 4 ++-- 7 files changed, 13 insertions(+), 8 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 80cee9e..259e81c 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -101,4 +101,6 @@ jobs: - name: Run Tests if: ${{ steps.check_tests.outputs.HAS_TEST_DIR == 'true' }} - run: pytest -vvv ${{ matrix.domain }}/tests + run: | + cd ${{ matrix.domain }}/notebooks + python -m pytest -vvv ../tests diff --git a/nlp/notebooks/nl2q_eval/query_eval.py b/nlp/notebooks/nl2q_eval/query_eval.py index 59f12fe..862bf8e 100644 --- a/nlp/notebooks/nl2q_eval/query_eval.py +++ b/nlp/notebooks/nl2q_eval/query_eval.py @@ -11,7 +11,6 @@ import sys from typing import Any, Dict, List, MutableMapping, Tuple -from typedefs import JSON from nl2q_eval.MetricsClasses import ( ANNOTATION_TYPES, DATA_TYPES, @@ -23,6 +22,7 @@ SpanMeasures, ValueMeasures ) +from typedefs import JSON def eval_query(gold: JSON, test: JSON) -> (DataMeasures, SpanMeasures, AttributeMeasures, ValueMeasures): diff --git a/nlp/notebooks/nl2query/V1/Vars_values_textsearch.py b/nlp/notebooks/nl2query/V1/Vars_values_textsearch.py index 74f79bb..8bb2bee 100644 --- a/nlp/notebooks/nl2query/V1/Vars_values_textsearch.py +++ b/nlp/notebooks/nl2query/V1/Vars_values_textsearch.py @@ -1,6 +1,5 @@ from textsearch import TextSearch -from nl2query.V1.vocab.Vocabulary import Vocabulary from nl2query.NL2QueryInterface import ( LocationAnnotation, NL2QueryInterface, @@ -9,6 +8,7 @@ TargetAnnotation, TemporalAnnotation ) +from nl2query.V1.vocab.Vocabulary import Vocabulary class Vars_values_textsearch(NL2QueryInterface): diff --git a/nlp/notebooks/stac_wrapper/query_handler.py b/nlp/notebooks/stac_wrapper/query_handler.py index b984cb5..17a10f5 100644 --- a/nlp/notebooks/stac_wrapper/query_handler.py +++ b/nlp/notebooks/stac_wrapper/query_handler.py @@ -4,9 +4,10 @@ from configparser import ConfigParser import ipywidgets as widgets -from typedefs import JSON from pystac_client import Client +from typedefs import JSON + class STAC_query_handler: """ class to handle running a stac query""" diff --git a/nlp/tests/test_MetricsClasses.py b/nlp/tests/test_MetricsClasses.py index f472034..bed6cb5 100644 --- a/nlp/tests/test_MetricsClasses.py +++ b/nlp/tests/test_MetricsClasses.py @@ -1,9 +1,10 @@ import unittest -from tests import GOLD_FILE, TEST_FILE from nl2q_eval.MetricsClasses import AttributeMeasures, DataMeasures, SpanMeasures, ValueMeasures from nl2q_eval.query_eval import read_files +from ..tests import GOLD_FILE, TEST_FILE + class MetricsClassesTests(unittest.TestCase): diff --git a/nlp/tests/test_query_eval.py b/nlp/tests/test_query_eval.py index a3a58a0..3388d6f 100644 --- a/nlp/tests/test_query_eval.py +++ b/nlp/tests/test_query_eval.py @@ -1,6 +1,5 @@ import unittest -from tests import GOLD_FILE, TEST_FILE from nl2q_eval.MetricsClasses import ( ANNOTATION_TYPES, VALUE_TYPES, @@ -11,6 +10,8 @@ ) from nl2q_eval.query_eval import global_stats, read_files +from ..tests import GOLD_FILE, TEST_FILE + annot_counts = {"property": 20, "location": 6, "tempex": 3, "target": 5, "global": 34} diff --git a/setup.cfg b/setup.cfg index f763949..6917156 100644 --- a/setup.cfg +++ b/setup.cfg @@ -10,6 +10,6 @@ treat_all_comments_as_code = true default_section = THIRDPARTY sections = FUTURE,STDLIB,THIRDPARTY,FIRSTPARTY,LOCALFOLDER extra_standard_library = posixpath,typing,typing_extensions -known_third_party = cornice_swagger,cwltool,cwt,docker,mock -known_first_party = nl2q_eval,nl2query,stac_wrapper,tests +known_third_party = docker,mock +known_first_party = nl2q_eval,nl2query,stac_wrapper,typedefs,tests skip = *.egg*,build,env,src,venv,reports,node_modules