Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: set docarray version on load flow data (#159)
* fix: set docarray version on load flow data * test: fix unit tests * fix: set jcloud versions * ci: fix python version * test: update jina new test * fix: use venv in jina new test
- Loading branch information
1 parent
b4018e1
commit 8e9788b
Showing
6 changed files
with
119 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,47 @@ | ||
import os | ||
import sys | ||
import shutil | ||
import subprocess | ||
import tempfile | ||
|
||
import pytest | ||
from jina import Client, DocumentArray | ||
|
||
from pathlib import Path | ||
from venv import create | ||
from jina import Client, DocumentArray | ||
from jcloud.flow import CloudFlow | ||
|
||
cur_dir = os.path.dirname(os.path.abspath(__file__)) | ||
|
||
|
||
def test_jina_new(): | ||
subprocess.run(["jina", "new", os.path.join(cur_dir, "hello-world")]) | ||
def setup_venv(): | ||
v_dir = Path(tempfile.mkdtemp()) | ||
create(v_dir, with_pip=True) | ||
|
||
_pip_path = v_dir / 'bin' / 'pip' | ||
subprocess.run([_pip_path, 'install', '-U', 'pip', '-q']) | ||
subprocess.run([_pip_path, 'install', 'jina[standard]==3.18.0', '-q']) | ||
return v_dir | ||
|
||
|
||
assert os.path.exists(os.path.join(cur_dir, "hello-world")) | ||
assert os.path.isdir(os.path.join(cur_dir, "hello-world")) | ||
def test_jina_new_project(): | ||
v_dir = setup_venv() | ||
subprocess.run( | ||
[v_dir / 'bin' / 'jina', 'new', os.path.join(cur_dir, 'hello-world')], | ||
) | ||
assert os.path.exists(os.path.join(cur_dir, 'hello-world')) | ||
assert os.path.isdir(os.path.join(cur_dir, 'hello-world')) | ||
|
||
with CloudFlow(path=os.path.join(cur_dir, "hello-world")) as flow: | ||
with CloudFlow(path=os.path.join(cur_dir, 'hello-world')) as flow: | ||
assert flow.endpoints != {} | ||
assert 'gateway (grpc)' in flow.endpoints | ||
assert 'gateway (http)' in flow.endpoints | ||
assert 'gateway (websocket)' in flow.endpoints | ||
gateway = flow.endpoints['gateway (grpc)'] | ||
|
||
da = Client(host=gateway).post(on="/", inputs=DocumentArray.empty(2)) | ||
assert da.texts == ["hello, world!", "goodbye, world!"] | ||
da = Client(host=gateway).post(on='/', inputs=DocumentArray.empty(2)) | ||
assert da.texts == ['hello, world!', 'goodbye, world!'] | ||
|
||
shutil.rmtree(os.path.join(cur_dir, "hello-world")) | ||
shutil.rmtree(os.path.join(cur_dir, 'hello-world')) | ||
|
||
assert not os.path.exists(os.path.join(cur_dir, "hello-world")) | ||
assert not os.path.exists(os.path.join(cur_dir, 'hello-world')) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters