Commit
·
b1e7bb8
1
Parent(s):
6ccb51f
42
Browse files- handler.py +2 -17
handler.py
CHANGED
@@ -1,12 +1,8 @@
|
|
1 |
from typing import Dict, List, Any
|
2 |
-
from transformers import pipeline
|
3 |
-
import holidays
|
4 |
-
|
5 |
|
6 |
class EndpointHandler:
|
7 |
def __init__(self, path=""):
|
8 |
-
|
9 |
-
self.holidays = holidays.US()
|
10 |
|
11 |
def __call__(self, data: Dict[str, Any]) -> List[Dict[str, Any]]:
|
12 |
"""
|
@@ -16,15 +12,4 @@ class EndpointHandler:
|
|
16 |
Return:
|
17 |
A :obj:`list` | `dict`: will be serialized and returned
|
18 |
"""
|
19 |
-
|
20 |
-
inputs = data.pop("inputs", data)
|
21 |
-
# get additional date field
|
22 |
-
date = data.pop("date", None)
|
23 |
-
|
24 |
-
# check if date exists and if it is a holiday
|
25 |
-
if date is not None and date in self.holidays:
|
26 |
-
return [{"label": "happy", "score": 1}]
|
27 |
-
|
28 |
-
# run normal prediction
|
29 |
-
prediction = self.pipeline(inputs)
|
30 |
-
return prediction
|
|
|
1 |
from typing import Dict, List, Any
|
|
|
|
|
|
|
2 |
|
3 |
class EndpointHandler:
|
4 |
def __init__(self, path=""):
|
5 |
+
pass
|
|
|
6 |
|
7 |
def __call__(self, data: Dict[str, Any]) -> List[Dict[str, Any]]:
|
8 |
"""
|
|
|
12 |
Return:
|
13 |
A :obj:`list` | `dict`: will be serialized and returned
|
14 |
"""
|
15 |
+
return [{"text": "Hello World"}, {"text": "Hello World2"}]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|