Spaces:
Running
Running
feat: async run
Browse files
tasks.py
CHANGED
@@ -162,6 +162,11 @@ class Task:
|
|
162 |
|
163 |
return self.result
|
164 |
|
|
|
|
|
|
|
|
|
|
|
165 |
|
166 |
def multichoice(responses: Any, references: list[str]):
|
167 |
if isinstance(responses[0], str):
|
|
|
162 |
|
163 |
return self.result
|
164 |
|
165 |
+
async def arun(self, pipeline):
|
166 |
+
self.outputs = self.outputs or await pipeline(self.samples)
|
167 |
+
|
168 |
+
return self.result
|
169 |
+
|
170 |
|
171 |
def multichoice(responses: Any, references: list[str]):
|
172 |
if isinstance(responses[0], str):
|
tlem.py
CHANGED
@@ -103,6 +103,16 @@ class Suite(EvaluationSuite):
|
|
103 |
_ = task.run(model_or_pipeline)
|
104 |
return self.aggregate(deepcopy(self.suite))
|
105 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
106 |
def get_suite(self, name) -> dict[str, Task]:
|
107 |
chat = False
|
108 |
match name:
|
|
|
103 |
_ = task.run(model_or_pipeline)
|
104 |
return self.aggregate(deepcopy(self.suite))
|
105 |
|
106 |
+
def arun(self, model_or_pipeline):
|
107 |
+
async def sync_function():
|
108 |
+
return await tqdm.gather(
|
109 |
+
*[task.run(model_or_pipeline) for task in self.tasks], leave=False
|
110 |
+
)
|
111 |
+
|
112 |
+
asyncio.run(sync_function())
|
113 |
+
|
114 |
+
return self.aggregate(deepcopy(self.suite))
|
115 |
+
|
116 |
def get_suite(self, name) -> dict[str, Task]:
|
117 |
chat = False
|
118 |
match name:
|