Skip to content

Commit

Permalink
feat(server): Add server option 'can stop' and 'step size'
Browse files Browse the repository at this point in the history
  • Loading branch information
cauliyang committed Oct 25, 2023
1 parent 9c4457c commit 9b72742
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 14 deletions.
14 changes: 6 additions & 8 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from pathlib import Path

import pytest
from pxblat import ClientOption
from pxblat import ClientOption , ServerOption
from pxblat.server import Server
from pxblat.server import Status

Expand Down Expand Up @@ -92,16 +92,14 @@ def expected_status_instance():
)


@pytest.fixture()
def server_instance(port, two_bit):
return Server("localhost", port, two_bit, can_stop=True, step_size=5,
use_others=True)


@pytest.fixture()
def start_server(server_instance):
server = server_instance
def server_option():
return ServerOption().withCanStop(True).withStepSize(5).build()

@pytest.fixture()
def start_server(port, two_bit):
server = Server("localhost", port, two_bit, can_stop=True, step_size=5, use_others=True)
server.start()
print(f"{server}")
server.wait_ready(timeout=10, restart=False)
Expand Down
2 changes: 1 addition & 1 deletion tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def test_fa2twobit_cli(tmp_path, two_bit):


@pytest.fixture()
def start_server2(server_instance, port, two_bit):
def start_server2(port, two_bit):
server = Server("localhost", port + 1, two_bit, can_stop=True, step_size=5, use_others=True)
server.start()

Expand Down
3 changes: 1 addition & 2 deletions tests/test_result.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,9 @@ def run_cblat(result_dir: Path, port: int, fa_data: Path):
def run_pxblat_async(result_dir: Path, port: int, fa_data: Path):
cport = port + 20
two_bit = Path("benchmark/data/chr20.2bit")
server_option = pxblat.ServerOption().withCanStop(True).withStepSize(5).build()

print("open python server")
server = pxblat.Server("localhost", cport, two_bit, server_option)
server = pxblat.Server("localhost", cport, two_bit, can_stop=True, step_size=5)
server.start()
server.wait_ready()
results = {}
Expand Down
6 changes: 3 additions & 3 deletions tests/test_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ def test_server_start_free_func(server_option, port):
assert status


def test_server_start_class(server_option, port, two_bit):
def test_server_start_class(port, two_bit):
port += 11
server = Server("localhost", port, two_bit, server_option)
server = Server("localhost", port, two_bit, can_stop=True)
server.start()

assert not server.is_ready()
Expand Down Expand Up @@ -181,7 +181,7 @@ def test_sever_with_context(
min_score=20,
min_identity=90,
)
with Server("localhost", new_port, two_bit, server_option) as server:
with Server("localhost", new_port, two_bit, can_stop=True, step_size=5) as server:
server.wait_ready()
assert server.is_ready()
status = server.status(instance=True)
Expand Down

0 comments on commit 9b72742

Please sign in to comment.