MCPcopy Create free account
hub / github.com/FareedKhan-dev/ai-long-task / save

Method save

data/database.py:596–643  ·  view source on GitHub ↗

Save the database to disk Args: path: Path to save to (uses config.db_path if None) iteration: Current iteration number

(self, path: Optional[str] = None, iteration: int = 0)

Source from the content-addressed store, hash-verified

594 return sorted_programs[:n]
595
596 def save(self, path: Optional[str] = None, iteration: int = 0) -> None:
597 """
598 Save the database to disk
599
600 Args:
601 path: Path to save to (uses config.db_path if None)
602 iteration: Current iteration number
603 """
604 save_path = path or self.config.db_path
605 if not save_path:
606 logger.warning("No database path specified, skipping save")
607 return
608
609 # Perform artifact cleanup before saving
610 self._cleanup_old_artifacts(save_path)
611
612 # create directory if it doesn't exist
613 os.makedirs(save_path, exist_ok=True)
614
615 # Save each program
616 for program in self.programs.values():
617 prompts = None
618 if (
619 self.config.log_prompts
620 and self.prompts_by_program
621 and program.id in self.prompts_by_program
622 ):
623 prompts = self.prompts_by_program[program.id]
624 self._save_program(program, save_path, prompts=prompts)
625
626 # Save metadata including island info, archive, and tracking stats
627 metadata = {
628 "island_feature_maps": self.island_feature_maps,
629 "islands": [list(island) for island in self.islands],
630 "archive": list(self.archive),
631 "best_program_id": self.best_program_id,
632 "island_best_programs": self.island_best_programs,
633 "last_iteration": iteration or self.last_iteration,
634 "current_island": self.current_island,
635 "island_generations": self.island_generations,
636 "last_migration_generation": self.last_migration_generation,
637 "feature_stats": self._serialize_feature_stats(),
638 }
639
640 with open(os.path.join(save_path, "metadata.json"), "w") as f:
641 json.dump(metadata, f)
642
643 logger.info(f"Saved database with {len(self.programs)} programs to {save_path}")
644
645 def load(self, path: str) -> None:
646 """

Callers 2

_save_checkpointMethod · 0.80
_take_screenshotMethod · 0.80

Calls 3

_save_programMethod · 0.95

Tested by

no test coverage detected