libentry 1.26__py3-none-any.whl → 1.28__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- libentry/mcp/client.py +6 -1
- libentry/mcp/service.py +36 -12
- libentry/mcp/types.py +1 -0
- {libentry-1.26.dist-info → libentry-1.28.dist-info}/METADATA +1 -1
- {libentry-1.26.dist-info → libentry-1.28.dist-info}/RECORD +10 -10
- {libentry-1.26.dist-info → libentry-1.28.dist-info}/LICENSE +0 -0
- {libentry-1.26.dist-info → libentry-1.28.dist-info}/WHEEL +0 -0
- {libentry-1.26.dist-info → libentry-1.28.dist-info}/entry_points.txt +0 -0
- {libentry-1.26.dist-info → libentry-1.28.dist-info}/top_level.txt +0 -0
- {libentry-1.26.dist-info → libentry-1.28.dist-info}/zip-safe +0 -0
libentry/mcp/client.py
CHANGED
@@ -144,11 +144,16 @@ class SubroutineMixIn(abc.ABC):
|
|
144
144
|
|
145
145
|
@staticmethod
|
146
146
|
def _iter_results_from_subroutine(responses: Iterable[SubroutineResponse]) -> Iterable[JSONType]:
|
147
|
+
full_result = None
|
147
148
|
for response in responses:
|
148
149
|
if response.error is None:
|
149
|
-
|
150
|
+
if response.chunk:
|
151
|
+
yield response.result
|
152
|
+
else:
|
153
|
+
full_result = response.result
|
150
154
|
else:
|
151
155
|
raise ServiceError.from_subroutine_error(response.error)
|
156
|
+
return full_result
|
152
157
|
|
153
158
|
def get(
|
154
159
|
self,
|
libentry/mcp/service.py
CHANGED
@@ -10,7 +10,7 @@ from dataclasses import dataclass
|
|
10
10
|
from queue import Empty, Queue
|
11
11
|
from threading import Lock
|
12
12
|
from types import GeneratorType
|
13
|
-
from typing import Any, Callable, Dict, Generator, Iterable, List, Literal, Optional, Tuple,
|
13
|
+
from typing import Any, Callable, Dict, Generator, Iterable, List, Literal, Optional, Tuple, Union
|
14
14
|
|
15
15
|
from flask import Flask, request as flask_request
|
16
16
|
from pydantic import BaseModel, Field, TypeAdapter
|
@@ -98,24 +98,26 @@ class SubroutineAdapter:
|
|
98
98
|
@staticmethod
|
99
99
|
def _iter_response(
|
100
100
|
results: Iterable[Any]
|
101
|
-
) ->
|
101
|
+
) -> Iterable[SubroutineResponse]:
|
102
102
|
it = iter(results)
|
103
103
|
while True:
|
104
104
|
try:
|
105
105
|
result = next(it)
|
106
106
|
if not isinstance(result, SubroutineResponse):
|
107
107
|
result = SubroutineResponse(result=result)
|
108
|
+
result.chunk = True
|
108
109
|
yield result
|
109
110
|
except StopIteration as e:
|
110
111
|
final_result = e.value
|
111
112
|
if not isinstance(final_result, SubroutineResponse):
|
112
113
|
final_result = SubroutineResponse(result=final_result)
|
114
|
+
final_result.chunk = False
|
115
|
+
yield final_result
|
113
116
|
break
|
114
117
|
except Exception as e:
|
115
118
|
final_result = SubroutineResponse(error=SubroutineError.from_exception(e))
|
116
119
|
yield final_result
|
117
120
|
break
|
118
|
-
return final_result
|
119
121
|
|
120
122
|
|
121
123
|
class JSONRPCAdapter:
|
@@ -891,19 +893,41 @@ class GunicornApplication(BaseApplication):
|
|
891
893
|
|
892
894
|
def load(self):
|
893
895
|
logger.info("Initializing the service.")
|
894
|
-
if isinstance(self.service_type,
|
895
|
-
|
896
|
-
|
896
|
+
if isinstance(self.service_type, (List, Tuple)):
|
897
|
+
if isinstance(self.service_config, (List, Tuple)) and len(self.service_config) == len(self.service_type):
|
898
|
+
service = [
|
899
|
+
self._create_service(t, c)
|
900
|
+
for t, c in zip(self.service_type, self.service_config)
|
901
|
+
]
|
902
|
+
elif self.service_config is None:
|
903
|
+
service = [
|
904
|
+
self._create_service(t, self.service_config)
|
905
|
+
for t in self.service_type
|
906
|
+
]
|
907
|
+
else:
|
908
|
+
raise RuntimeError(
|
909
|
+
f"You are going to run {len(self.service_type)} services. "
|
910
|
+
"In the multiple service mode, every `service_type` requires a `service_config` object."
|
911
|
+
)
|
912
|
+
else:
|
913
|
+
service = self._create_service(self.service_type, self.service_config)
|
914
|
+
logger.info("Service initialized.")
|
915
|
+
|
916
|
+
return FlaskServer(service)
|
917
|
+
|
918
|
+
@staticmethod
|
919
|
+
def _create_service(service_type, service_config):
|
920
|
+
if isinstance(service_type, type) or callable(service_type):
|
921
|
+
service = service_type(service_config) if service_config else service_type()
|
922
|
+
elif service_config is None:
|
897
923
|
logger.warning(
|
898
924
|
"Be careful! It is not recommended to start the server from a service instance. "
|
899
925
|
"Use service_type and service_config instead."
|
900
926
|
)
|
901
|
-
service =
|
927
|
+
service = service_type
|
902
928
|
else:
|
903
|
-
raise TypeError(f"Invalid service type \"{type(
|
904
|
-
|
905
|
-
|
906
|
-
return FlaskServer(service)
|
929
|
+
raise TypeError(f"Invalid service type \"{type(service_type)}\".")
|
930
|
+
return service
|
907
931
|
|
908
932
|
|
909
933
|
class RunServiceConfig(BaseModel):
|
@@ -969,7 +993,7 @@ class RunServiceConfig(BaseModel):
|
|
969
993
|
|
970
994
|
|
971
995
|
def run_service(
|
972
|
-
service_type: Union[
|
996
|
+
service_type: Union[Union[type, Callable], List, Tuple],
|
973
997
|
service_config=None,
|
974
998
|
run_config: Optional[RunServiceConfig] = None,
|
975
999
|
*,
|
libentry/mcp/types.py
CHANGED
@@ -12,9 +12,9 @@ libentry/test_api.py,sha256=bs7P8gveLtuUvHxrpujSrfuYqLVJ3fOXVg_MZnZxoJ4,4504
|
|
12
12
|
libentry/utils.py,sha256=vCm6UyAlibnPOlPJHZO57u3TXhw5PZmGM5_vBAPUnB4,1981
|
13
13
|
libentry/mcp/__init__.py,sha256=1oLL20yLB1GL9IbFiZD8OReDqiCpFr-yetIR6x1cNkI,23
|
14
14
|
libentry/mcp/api.py,sha256=GDErVCz_hh_ZeMxLS8bTPyBUhCTHw3Mm-nGFMV2W2yo,3669
|
15
|
-
libentry/mcp/client.py,sha256=
|
16
|
-
libentry/mcp/service.py,sha256=
|
17
|
-
libentry/mcp/types.py,sha256=
|
15
|
+
libentry/mcp/client.py,sha256=OzAgM-hZ5t24A7MC-i_FkchxQaYM17T6E6M0jPuZJwk,23243
|
16
|
+
libentry/mcp/service.py,sha256=cE6K6RVDQ9Jc4pxcJUWOr5zWJMpSvROL54cq8vbJWHE,39130
|
17
|
+
libentry/mcp/types.py,sha256=P4lnwDCdETTzfoD7u1XMqx9ZKN4mXl0KSEMk4e_o_k0,12413
|
18
18
|
libentry/service/__init__.py,sha256=1oLL20yLB1GL9IbFiZD8OReDqiCpFr-yetIR6x1cNkI,23
|
19
19
|
libentry/service/common.py,sha256=OVaW2afgKA6YqstJmtnprBCqQEUZEWotZ6tHavmJJeU,42
|
20
20
|
libentry/service/flask.py,sha256=2egCFFhRAfLpmSyibgaJ-3oexI-j27P1bmaPEn-hSlc,13817
|
@@ -22,10 +22,10 @@ libentry/service/list.py,sha256=ElHWhTgShGOhaxMUEwVbMXos0NQKjHsODboiQ-3AMwE,1397
|
|
22
22
|
libentry/service/running.py,sha256=FrPJoJX6wYxcHIysoatAxhW3LajCCm0Gx6l7__6sULQ,5105
|
23
23
|
libentry/service/start.py,sha256=mZT7b9rVULvzy9GTZwxWnciCHgv9dbGN2JbxM60OMn4,1270
|
24
24
|
libentry/service/stop.py,sha256=wOpwZgrEJ7QirntfvibGq-XsTC6b3ELhzRW2zezh-0s,1187
|
25
|
-
libentry-1.
|
26
|
-
libentry-1.
|
27
|
-
libentry-1.
|
28
|
-
libentry-1.
|
29
|
-
libentry-1.
|
30
|
-
libentry-1.
|
31
|
-
libentry-1.
|
25
|
+
libentry-1.28.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
26
|
+
libentry-1.28.dist-info/METADATA,sha256=NmtlVZk1U8IW_q8pw22_e6UF3UvAhgIhFLyzF3i1BRU,1133
|
27
|
+
libentry-1.28.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
|
28
|
+
libentry-1.28.dist-info/entry_points.txt,sha256=1v_nLVDsjvVJp9SWhl4ef2zZrsLTBtFWgrYFgqvQBgc,61
|
29
|
+
libentry-1.28.dist-info/top_level.txt,sha256=u2uF6-X5fn2Erf9PYXOg_6tntPqTpyT-yzUZrltEd6I,9
|
30
|
+
libentry-1.28.dist-info/zip-safe,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
|
31
|
+
libentry-1.28.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|