Maameri commited on
Commit
3f6d4d2
1 Parent(s): 8092cc9

add base handler

Browse files
Files changed (3) hide show
  1. __pycache__/handler.cpython-310.pyc +0 -0
  2. handler.py +20 -0
  3. test.py +7 -0
__pycache__/handler.cpython-310.pyc ADDED
Binary file (926 Bytes). View file
 
handler.py ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from typing import Dict, List, Any
2
+
3
+
4
+ class EndpointHandler():
5
+ def __init__(self, path=""):
6
+ self.path = path
7
+
8
+ # Preload all the elements you are going to need at inference.
9
+ # pseudo:
10
+ # self.model= load_model(path)
11
+
12
+ def __call__(self, data: Dict[str, Any]) -> List[Dict[str, Any]]:
13
+ """
14
+ data args:
15
+ inputs (:obj: `str` | `PIL.Image` | `np.array`)
16
+ kwargs
17
+ Return:
18
+ A :obj:`list` | `dict`: will be serialized and returned
19
+ """
20
+ return 'hello world'
test.py ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ from handler import EndpointHandler
2
+
3
+ # init handler
4
+ my_handler = EndpointHandler(path=".")
5
+
6
+ # show results
7
+ print(my_handler({'name': 'sami'}))