Upload task.py with huggingface_hub
Browse files
task.py
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from .operator import StreamInstanceOperator
|
2 |
+
|
3 |
+
from typing import Dict, List, Any
|
4 |
+
|
5 |
+
|
6 |
+
class Tasker:
|
7 |
+
pass
|
8 |
+
|
9 |
+
|
10 |
+
class FormTask(Tasker, StreamInstanceOperator):
|
11 |
+
inputs: List[str]
|
12 |
+
outputs: List[str]
|
13 |
+
metrics: List[str]
|
14 |
+
|
15 |
+
def process(self, instance: Dict[str, Any], stream_name: str = None) -> Dict[str, Any]:
|
16 |
+
inputs = {key: instance[key] for key in self.inputs}
|
17 |
+
outputs = {key: instance[key] for key in self.outputs}
|
18 |
+
return {
|
19 |
+
"inputs": inputs,
|
20 |
+
"outputs": outputs,
|
21 |
+
"metrics": self.metrics,
|
22 |
+
}
|