(self, results: List[TaskOutput])
| 125 | return TaskClientOutput(output=result["output"]) |
| 126 | |
| 127 | def calculate_overall(self, results: List[TaskOutput]) -> JSONSerializable: |
| 128 | statistics = {s: 0 for s in SampleStatus} |
| 129 | for result in results: |
| 130 | statistics[SampleStatus(result.status)] += 1 |
| 131 | for s in SampleStatus: |
| 132 | statistics[s] /= len(results) |
| 133 | statistics["average_history_length"] = sum( |
| 134 | [len(result.history) for result in results] |
| 135 | ) / len(results) |
| 136 | statistics["max_history_length"] = max( |
| 137 | [len(result.history) for result in results] |
| 138 | ) |
| 139 | statistics["min_history_length"] = min( |
| 140 | [len(result.history) for result in results] |
| 141 | ) |
| 142 | ret = { |
| 143 | "total": len(results), |
| 144 | "validation": statistics, |
| 145 | } |
| 146 | res = requests.post( |
| 147 | self.controller_address + "/calculate_overall", |
| 148 | json=CalculateOverallRequest(name=self.name, results=results).dict(), |
| 149 | ) |
| 150 | if res.status_code != 200: |
| 151 | raise TaskNetworkException(res.text) |
| 152 | ret["custom"] = res.json() |
| 153 | return ret |
no test coverage detected