| 4 | |
| 5 | |
| 6 | class ToolDataset: |
| 7 | def __init__(self, dataset_name, tool_task, filepath): |
| 8 | self.dataset_name = dataset_name |
| 9 | self.tool_task = tool_task |
| 10 | self.filepath = filepath |
| 11 | self.datas = self.load_data() |
| 12 | |
| 13 | def load_data(self, ) -> list: |
| 14 | if self.filepath: |
| 15 | return self.load_data_from_local(self.filepath) |
| 16 | elif self.dataset_name and self.tool_task: |
| 17 | return self.load_data_from_hf(self.tool_task) |
| 18 | return [] |
| 19 | |
| 20 | def load_data_from_local(self, filepath): |
| 21 | '''''' |
| 22 | pass |
| 23 | |
| 24 | def load_data_from_hf(self, tool_task): |
| 25 | pass |
| 26 | |
| 27 | def __iter__(self): |
| 28 | self.current_index = 0 |
| 29 | return self |
| 30 | |
| 31 | def __next__(self): |
| 32 | if self.current_index < len(self.datas): |
| 33 | current_item = self.datas[self.current_index] |
| 34 | self.current_index += 1 |
| 35 | return current_item |
| 36 | else: |
| 37 | raise StopIteration |
| 38 | |
| 39 | def __len__(self): |
| 40 | return len(self.datas) |
nothing calls this directly
no outgoing calls
no test coverage detected