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

Method _save_program

data/database.py:809–838  ·  view source on GitHub ↗

Save a program to disk Args: program: Program to save base_path: Base path to save to (uses config.db_path if None) prompts: Optional prompts to save with the program, in the format {template_key: { 'system': str, 'user': str }}

(
        self,
        program: Program,
        base_path: Optional[str] = None,
        prompts: Optional[Dict[str, Dict[str, str]]] = None,
    )

Source from the content-addressed store, hash-verified

807 logger.info(f"Distributed {len(program_ids)} programs across {len(self.islands)} islands")
808
809 def _save_program(
810 self,
811 program: Program,
812 base_path: Optional[str] = None,
813 prompts: Optional[Dict[str, Dict[str, str]]] = None,
814 ) -> None:
815 """
816 Save a program to disk
817
818 Args:
819 program: Program to save
820 base_path: Base path to save to (uses config.db_path if None)
821 prompts: Optional prompts to save with the program, in the format {template_key: { 'system': str, 'user': str }}
822 """
823 save_path = base_path or self.config.db_path
824 if not save_path:
825 return
826
827 # Create programs directory if it doesn't exist
828 programs_dir = os.path.join(save_path, "programs")
829 os.makedirs(programs_dir, exist_ok=True)
830
831 # Save program
832 program_dict = program.to_dict()
833 if prompts:
834 program_dict["prompts"] = prompts
835 program_path = os.path.join(programs_dir, f"{program.id}.json")
836
837 with open(program_path, "w") as f:
838 json.dump(program_dict, f)
839
840 def _calculate_feature_coords(self, program: Program) -> List[int]:
841 """

Callers 2

addMethod · 0.95
saveMethod · 0.95

Calls 1

to_dictMethod · 0.45

Tested by

no test coverage detected