-
Notifications
You must be signed in to change notification settings - Fork 1
/
meteorite.pyi
42 lines (35 loc) · 1.32 KB
/
meteorite.pyi
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import typing
class Meteorite:
"""
A fast and simple server app for machine learning models.
"""
def __init__(self) -> None:
"""
Initializes the Meteorite server app
"""
def predict(
self, wraps: typing.Callable[[bytes], typing.Union[str, dict[str, typing.Any]]]
) -> None:
"""
Decorator to wrap a model inference function.
The inference function should take in a bytes object and return a string or a dictionary.
The inference endpoint will be available at `/predict`.
:param wraps: model inference function
>>> app = Meteorite()
>>> @app.predict
>>> def infer(data: bytes) -> str:
>>> return "Hello World"
"""
def set_webhook_url(self, webhook_url: str) -> None:
"""
Sets the webhook url for the `predict` inference endpoint.
After the model inference function finishes processing one inference request,
the object returned by the function will be sent to the webhook url as a POST request.
:param webhook_url: webhook url
>>> app.set_webhook_url("https://example.com")
"""
def start(self, port: int = 4000) -> None:
"""
Starts the server app
:param port: port to run the server on, defaults to 4000
"""