Update handler.py
Browse files- handler.py +3 -3
handler.py
CHANGED
|
@@ -1,11 +1,11 @@
|
|
| 1 |
from typing import Dict, List, Any
|
| 2 |
from transformers import pipeline
|
| 3 |
-
|
| 4 |
|
| 5 |
class EndpointHandler():
|
| 6 |
def __init__(self, path=""):
|
| 7 |
self.pipeline = pipeline("text-classification",model=path)
|
| 8 |
-
|
| 9 |
|
| 10 |
def __call__(self, data: Dict[str, Any]) -> List[Dict[str, Any]]:
|
| 11 |
"""
|
|
@@ -19,7 +19,7 @@ class EndpointHandler():
|
|
| 19 |
inputs = data.pop("inputs",data)
|
| 20 |
date = data.pop("date", None)
|
| 21 |
# check if date exists and if it is a holiday
|
| 22 |
-
if date is
|
| 23 |
return [{"label": "happy", "score": 1}]
|
| 24 |
# run normal prediction
|
| 25 |
prediction = self.pipeline(inputs)
|
|
|
|
| 1 |
from typing import Dict, List, Any
|
| 2 |
from transformers import pipeline
|
| 3 |
+
|
| 4 |
|
| 5 |
class EndpointHandler():
|
| 6 |
def __init__(self, path=""):
|
| 7 |
self.pipeline = pipeline("text-classification",model=path)
|
| 8 |
+
|
| 9 |
|
| 10 |
def __call__(self, data: Dict[str, Any]) -> List[Dict[str, Any]]:
|
| 11 |
"""
|
|
|
|
| 19 |
inputs = data.pop("inputs",data)
|
| 20 |
date = data.pop("date", None)
|
| 21 |
# check if date exists and if it is a holiday
|
| 22 |
+
if date is None:
|
| 23 |
return [{"label": "happy", "score": 1}]
|
| 24 |
# run normal prediction
|
| 25 |
prediction = self.pipeline(inputs)
|