@@ -351,26 +351,30 @@ def load_checkpoints(self, checkpointDirs: Optional[Sequence[str]]) -> Dict[str,
351351 else :
352352 return {}
353353
354- def checkpoint (self , tasks : Sequence [TaskRecord ]) -> None :
354+ def checkpoint (self , * , task : Optional [TaskRecord ] = None ) -> None :
355355 """Checkpoint the dfk incrementally to a checkpoint file.
356356
357- When called, every task that has been completed yet not
358- checkpointed is checkpointed to a file.
357+ When called with no argument, all tasks registered in self.checkpointable_tasks
358+ will be checkpointed. When called with a single TaskRecord argument, that task will be
359+ checkpointed.
360+
361+ By default the checkpoints are written to the RUNDIR of the current
362+ run under RUNDIR/checkpoints/tasks.pkl
359363
360364 Kwargs:
361- - tasks (List of task records) : List of task ids to checkpoint. Default=None
362- if set to None, we iterate over all tasks held by the DFK .
365+ - task (Optional task records) : A task to checkpoint. Default=None, meaning all
366+ tasks registered for checkpointing .
363367
364368 .. note::
365369 Checkpointing only works if memoization is enabled
366370
367- Returns:
368- Checkpoint dir if checkpoints were written successfully.
369- By default the checkpoints are written to the RUNDIR of the current
370- run under RUNDIR/checkpoints/tasks.pkl
371371 """
372372 with self .checkpoint_lock :
373- checkpoint_queue = tasks
373+
374+ if task :
375+ checkpoint_queue = [task ]
376+ else :
377+ checkpoint_queue = self .checkpointable_tasks
374378
375379 checkpoint_dir = '{0}/checkpoint' .format (self .run_dir )
376380 checkpoint_tasks = checkpoint_dir + '/tasks.pkl'
0 commit comments