Skip to content

Commit

Permalink
Merge pull request #7 from jina-ai/refactor-migration-jina3
Browse files Browse the repository at this point in the history
refactor: change folder
  • Loading branch information
numb3r3 authored Feb 21, 2022
2 parents f39f3b9 + 8455681 commit 14a8001
Show file tree
Hide file tree
Showing 17 changed files with 45 additions and 3 deletions.
1 change: 0 additions & 1 deletion __init__.py

This file was deleted.

2 changes: 1 addition & 1 deletion config.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
jtype: MeshDataEncoder
metas:
py_modules:
- __init__.py
- executor/__init__.py
1 change: 1 addition & 0 deletions executor/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from .encoder import MeshDataEncoder
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion finetune.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from finetuner.tuner.pytorch.miner import TripletEasyHardMiner
from docarray import Document, DocumentArray

from models import MeshDataModel
from executor.models import MeshDataModel


def random_sample(pc, num):
Expand Down
Empty file added tests/__init__.py
Empty file.
Empty file added tests/integration/__init__.py
Empty file.
24 changes: 24 additions & 0 deletions tests/integration/test_encoder.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import numpy as np
import pytest
from jina import DocumentArray, Flow

from executor import MeshDataEncoder


@pytest.mark.parametrize('model_name', ['pointconv', 'pointnet'])
def test_integration(model_name: str):
docs = DocumentArray.empty(5)
docs.tensors = np.random.random((5, 1024, 3))
with Flow(return_results=True).add(
uses=MeshDataEncoder,
uses_with={'pretrained_model': None, 'default_model_name': model_name},
) as flow:
resp = flow.post(
on='/index',
inputs=docs,
return_results=True,
)

for doc in resp:
assert doc.embedding is not None
assert doc.embedding.shape == (1024,)
1 change: 1 addition & 0 deletions tests/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pytest
Empty file added tests/unit/__init__.py
Empty file.
17 changes: 17 additions & 0 deletions tests/unit/test_exec.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import numpy as np
import pytest
from jina import Document, DocumentArray

from executor import MeshDataEncoder


@pytest.mark.parametrize('model_name', ['pointconv', 'pointnet'])
def test_encoder(model_name):
encoder = MeshDataEncoder(pretrained_model=None, default_model_name=model_name)

docs = DocumentArray(Document(tensor=np.random.random((1024, 3))))

encoder.encode(docs)

assert docs[0].embedding is not None
assert docs[0].embedding.shape == (1024,)

0 comments on commit 14a8001

Please sign in to comment.