File size: 575 Bytes
46b3240
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
from typing import Dict, Any, List
from server.inputs.base import InputProvider
from models import Task


class SimulatedDataLoader(InputProvider):
    def __init__(self, task_list: Dict):
        self.tasks: List[Task] = task_list["tasks"]
        self.idx = 0

    def get_input(self) -> Task:
        if self.is_done():
            raise StopIteration

        task = self.tasks[self.idx]
        self.idx += 1

        return task

    def is_done(self) -> bool:
        return self.idx >= len(self.tasks)

    def reset(self):
        self.idx = 0