Skip to content

Commit

Permalink
ci(unittest): change relative paths in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
JoanFM committed Jul 3, 2020
1 parent ee7a227 commit 54c12d1
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 7 deletions.
4 changes: 3 additions & 1 deletion tests/executors/indexers/keyvalue/test_leveldb.py
Expand Up @@ -7,6 +7,8 @@
from jina.executors.indexers.keyvalue.leveldb import LeveldbIndexer
from tests import JinaTestCase

cur_dir = os.path.dirname(os.path.abspath(__file__))


class MyTestCase(JinaTestCase):
def _create_Document(self, doc_id, text, weight, length):
Expand Down Expand Up @@ -40,7 +42,7 @@ def test_add_query(self):

def test_load_yaml(self):
from jina.executors import BaseExecutor
indexer = BaseExecutor.load_config('../../../yaml/test-leveldb.yml')
indexer = BaseExecutor.load_config(os.path.join(cur_dir, '../../../yaml/test-leveldb.yml'))
self.run_test(indexer)


Expand Down
5 changes: 3 additions & 2 deletions tests/executors/indexers/vector/test_annoy.py
Expand Up @@ -14,6 +14,7 @@
vec_idx = np.random.randint(0, high=100, size=[10])
vec = np.random.random([10, 10])
query = np.array(np.random.random([10, 10]), dtype=np.float32)
cur_dir = os.path.dirname(os.path.abspath(__file__))


class MyTestCase(JinaTestCase):
Expand All @@ -25,7 +26,7 @@ def test_annoy_wrap_indexer(self):
a.save()
a.close()

b = BaseIndexer.load_config('annoy-wrap.yml')
b = BaseIndexer.load_config(os.path.join(cur_dir, 'annoy-wrap.yml'))
idx, dist = b.query(query, top_k=4)
print(idx, dist)
global retr_idx
Expand All @@ -36,7 +37,7 @@ def test_annoy_wrap_indexer(self):
self.assertEqual(idx.shape, dist.shape)
self.assertEqual(idx.shape, (10, 4))

c = BaseIndexer.load_config('nmslib-wrap.yml')
c = BaseIndexer.load_config(os.path.join(cur_dir, 'nmslib-wrap.yml'))
idx, dist = c.query(query, top_k=4)
print(idx, dist)
if retr_idx is None:
Expand Down
4 changes: 3 additions & 1 deletion tests/executors/test_comp_exec.py
Expand Up @@ -5,6 +5,8 @@
from jina.executors.compound import CompoundExecutor
from tests import JinaTestCase

cur_dir = os.path.dirname(os.path.abspath(__file__))


class dummyA(BaseExecutor):
def say(self):
Expand Down Expand Up @@ -76,7 +78,7 @@ def test_compositional_dump(self):
self.assertTrue(os.path.exists(a.config_abspath))

def test_compound_from_yaml(self):
a = BaseExecutor.load_config('../yaml/npvec.yml')
a = BaseExecutor.load_config(os.path.join(cur_dir, '../yaml/npvec.yml'))
for c in a.components:
self.add_tmpfile(c.index_abspath)
self.assertTrue(isinstance(a, CompoundExecutor))
Expand Down
3 changes: 1 addition & 2 deletions tests/test_container.py
Expand Up @@ -37,8 +37,7 @@ def build_image():
if not built:
import docker
client = docker.from_env()
print(os.path.dirname(__file__))
client.images.build(path='mwu-encoder/', tag=img_name)
client.images.build(path=os.path.join(cur_dir, 'mwu-encoder/'), tag=img_name)
client.close()


Expand Down
6 changes: 5 additions & 1 deletion tests/test_hub.py
@@ -1,12 +1,16 @@
import os

from jina.hubapi.docker import HubIO
from jina.main.parser import set_hub_build_parser, set_hub_pushpull_parser
from tests import JinaTestCase

cur_dir = os.path.dirname(os.path.abspath(__file__))


class MyTestCase(JinaTestCase):

def test_hub_build_pull(self):
args = set_hub_build_parser().parse_args(['./hub-mwu', '--pull', '--push'])
args = set_hub_build_parser().parse_args([os.path.join(cur_dir, 'hub-mwu'), '--pull', '--push'])
HubIO(args).build()

args = set_hub_pushpull_parser().parse_args(['jinahub/pod.dummy_mwu_encoder'])
Expand Down

0 comments on commit 54c12d1

Please sign in to comment.