8000 refactor: remove ssh and zmqmany runtimes by JoanFM · Pull Request #2698 · jina-ai/serve · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

refactor: remove ssh and zmqmany runtimes #2698

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 18, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions jina/peapods/runtimes/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@
from .asyncio.rest import RESTRuntime
from .container import ContainerRuntime
from .jinad import JinadRuntime
from .ssh import SSHRuntime
from .zmq.zed import ZEDRuntime


def list_all_runtimes():
"""List all public runtimes that can be used directly with :class:`jina.peapods.peas.BasePea`"""
"""List all public runtimes that can be used directly with :class:`jina.peapods.peas.BasePea`

# noqa: DAR101
# noqa: DAR201
"""
from ...peapods.runtimes.base import BaseRuntime

return [
Expand All @@ -18,7 +21,11 @@ def list_all_runtimes():


def get_runtime(name: str):
"""Get a public runtime by its name"""
"""Get a public runtime by its name

# noqa: DAR101
# noqa: DAR201
"""
from ...peapods.runtimes.base import BaseRuntime

s = globals()[name]
Expand Down
59 changes: 0 additions & 59 deletions jina/peapods/runtimes/ssh/__init__.py

This file was deleted.

69 changes: 0 additions & 69 deletions jina/peapods/runtimes/zmq/base.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import argparse
from abc import ABC
from typing import Union, Dict

from ..base import BaseRuntime
from ...zmq import Zmqlet, send_ctrl_message
Expand Down Expand Up @@ -50,71 +49,3 @@ def is_ready(self) -> bool:
"""
status = self.status
return status and status.is_ready


class ZMQManyRuntime(BaseRuntime, ABC):
"""Multiple Runtime leveraging ZMQ."""

def __init__(self, args: Union['argparse.Namespace', Dict]):
super().__init__(args)
self.many_ctrl_addr = []
if isinstance(args, Dict):
first_args = self.args['peas'][0]
self.timeout_ctrl = first_args.timeout_ctrl
self.host = first_args.host
self.port_expose = first_args.port_expose
for args in self.args['peas']:
ctrl_addr, _ = Zmqlet.get_ctrl_address(
args.host, args.port_ctrl, args.ctrl_with_ipc
)
self.many_ctrl_addr.append(ctrl_addr)
elif isinstance(args, argparse.Namespace):
self.many_ctrl_addr.append(
Zmqlet.get_ctrl_address(
args.host, self.args.port_ctrl, args.ctrl_with_ipc
)[0]
)
self.timeout_ctrl = args.timeout_ctrl
self.host = args.host
self.port_expose = args.port_expose

def cancel(self):
"""Send terminate control messages to all control address."""
# TODO: can use send_message_async to avoid sequential waiting
for ctrl_addr in self.many_ctrl_addr:
send_ctrl_message(ctrl_addr, 'TERMINATE', timeout=self.timeout_ctrl)

def activate(self):
"""Send activate control messages to all control address."""
for ctrl_addr in self.many_ctrl_addr:
send_ctrl_message(ctrl_addr, 'ACTIVATE', timeout=self.timeout_ctrl)

def deactivate(self):
"""Send deactivate control messages to all control address."""
for ctrl_addr in self.many_ctrl_addr:
send_ctrl_message(ctrl_addr, 'DEACTIVATE', timeout=self.timeout_ctrl)

@property
def status(self):
"""
Send get status control messages to all control address.

:return: received messages
"""
# TODO: can use send_ctrl_message to avoid sequential waiting
result = []
for ctrl_addr in self.many_ctrl_addr:
result.append(
send_ctrl_message(ctrl_addr, 'STATUS', timeout=self.timeout_ctrl)
)
return result

@property
def is_ready(self) -> bool:
"""
Check if all the status are ready.

:return: True if all status are ready else False
"""
status = self.status
return status and all(s.is_ready for s in status)
Empty file.
48 changes: 0 additions & 48 deletions tests/unit/peapods/runtimes/remote/ssh/test_ssh_remote.py

This file was deleted.

8 changes: 4 additions & 4 deletions tests/unit/peapods/zmq/test_zmq_addr.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import pytest

from jina.peapods.runtimes.zmq.base import ZMQManyRuntime
from jina.peapods.runtimes.zmq.base import ZMQRuntime
from jina.peapods.zmq import Zmqlet
from jina.parsers import set_pod_parser
from jina.types.message import Message
Expand Down Expand Up @@ -35,7 +35,7 @@ def zmq_args_dict(zmq_args_argparse):

@pytest.fixture
def runtime(zmq_args_argparse):
return ZMQManyRuntime(args=zmq_args_argparse)
return ZMQRuntime(args=zmq_args_argparse)


@pytest.fixture
Expand All @@ -47,7 +47,7 @@ def ctrl_messages():

@pytest.fixture(params=['zmq_args_dict', 'zmq_args_argparse'])
def test_init(request):
runtime = ZMQManyRuntime(args=request.param)
runtime = ZMQRuntime(args=request.param)
assert runtime.host == '0.0.0.0'
assert runtime.port_expose == 45678
assert runtime.timeout_ctrl == 5000
Expand All @@ -59,7 +59,7 @@ def test_cancel(runtime):

def test_status(runtime, ctrl_messages, mocker):
mocker.patch('jina.peapods.runtimes.zmq.base.send_ctrl_message', return_value=123)
assert runtime.status == [123]
assert runtime.status == 123


def test_is_ready(runtime, ctrl_messages, mocker):
Expand Down
0