Skip to content

Commit 98176e9

Browse files
authored
Fix rerank server error (#537)
import `__future__` annotation will break mosec.utils.parse_func_type. the `__main__.Request` would be changed to `'Request'`: ``` 2024-06-15T00:55:54.001558Z WARNING mosec::coordinator.py:300 [1869971]: Traceback (most recent call last): File "/home/user/mosec/lib/python3.10/site-packages/mosec/coordinator.py", line 274, in coordinate data = [ File "/home/user/mosec/lib/python3.10/site-packages/mosec/coordinator.py", line 275, in <listcomp> self.decode(payload, state) File "/home/user/mosec/lib/python3.10/site-packages/mosec/coordinator.py", line 243, in decode self.worker.deserialize(payload) File "/home/user/mosec/lib/python3.10/site-packages/mosec/mixin/typed_worker.py", line 45, in deserialize return msgspec.msgpack.decode(data, type=self._input_typ) TypeError: Type ''Request'' is not supported ```
1 parent 9e61baf commit 98176e9

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

examples/rerank/server.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,8 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
from __future__ import annotations
16-
1715
from os import environ
16+
from typing import List
1817

1918
from msgspec import Struct
2019
from sentence_transformers import CrossEncoder
@@ -28,11 +27,11 @@
2827

2928
class Request(Struct, kw_only=True):
3029
query: str
31-
docs: list[str]
30+
docs: List[str]
3231

3332

3433
class Response(Struct, kw_only=True):
35-
scores: list[float]
34+
scores: List[float]
3635

3736

3837
class Encoder(TypedMsgPackMixin, Worker):

0 commit comments

Comments
 (0)