(self)
| 32 | return result.json() |
| 33 | |
| 34 | def get_concurrency(self) -> int: |
| 35 | try: |
| 36 | result = requests.get( |
| 37 | self.controller_address + "/list_workers" |
| 38 | ) |
| 39 | except Exception as e: |
| 40 | print(ColorMessage.yellow(f"Warning task {self.name} cannot connect to controller {e}")) |
| 41 | return 0 |
| 42 | if result.status_code != 200: |
| 43 | raise AgentBenchException(result.text, result.status_code, self.name) |
| 44 | result = result.json() |
| 45 | if self.name not in result: |
| 46 | print(ColorMessage.yellow(f"task {self.name} not found in worker list")) |
| 47 | return 0 |
| 48 | concurrency = 0 |
| 49 | for worker in result[self.name]["workers"].values(): |
| 50 | if worker["status"] == WorkerStatus.ALIVE: |
| 51 | concurrency += worker["capacity"] - worker["current"] |
| 52 | return concurrency |
| 53 | |
| 54 | def run_sample(self, index: SampleIndex, agent: AgentClient) -> TaskClientOutput: |
| 55 | try: |
no test coverage detected