|
6 | 6 |
|
7 | 7 |
|
8 | 8 | class CheckpointManager:
|
9 |
| - _instance = None # Class variable to store the singleton instance |
| 9 | + def __init__(self, checkpoint_folder="checkpoints"): |
| 10 | + """Initialize the CheckpointManager. |
10 | 11 |
|
11 |
| - def __new__(cls, checkpoint_folder="checkpoints"): |
12 |
| - if cls._instance is None: |
13 |
| - cls._instance = super(CheckpointManager, cls).__new__(cls) |
14 |
| - # Initialize the instance only if it doesn't exist |
15 |
| - cls._instance.checkpoint_folder = checkpoint_folder |
16 |
| - cls._instance.complete_folder = os.path.join(checkpoint_folder, "complete") |
17 |
| - cls._instance.remaining_folder = os.path.join(checkpoint_folder, "remaining") |
18 |
| - |
19 |
| - os.makedirs(cls._instance.checkpoint_folder, exist_ok=True) |
20 |
| - os.makedirs(cls._instance.complete_folder, exist_ok=True) |
21 |
| - os.makedirs(cls._instance.remaining_folder, exist_ok=True) |
| 12 | + Args: |
| 13 | + checkpoint_folder (str): The directory to store checkpoints and batch information. |
| 14 | + """ |
| 15 | + self.checkpoint_folder = checkpoint_folder |
| 16 | + self.complete_folder = os.path.join(checkpoint_folder, "complete") |
| 17 | + self.remaining_folder = os.path.join(checkpoint_folder, "remaining") |
22 | 18 |
|
23 |
| - return cls._instance |
| 19 | + os.makedirs(self.checkpoint_folder, exist_ok=True) |
| 20 | + os.makedirs(self.complete_folder, exist_ok=True) |
| 21 | + os.makedirs(self.remaining_folder, exist_ok=True) |
24 | 22 |
|
25 | 23 | def save_checkpoint(self, check_point_extension: str, results_so_far: List[Sample]):
|
26 | 24 | """Save a checkpoint with partial results.
|
|
0 commit comments