Exemple #1
0
    def save_result(self):
        """Save the Experiment description as a .json file, named after :attr:`experiment_id`. If :attr:`do_full_save` is a
        callable and returns False when given the description object, the result recording loop will be broken, and the remaining
        result files will not be saved

        Returns
        -------
        'break'
            This string will be returned if :attr:`do_full_save` is a callable and returns False when given the description
            object. This is the signal for :class:`recorders.RecorderList` to stop recording result files"""
        try:
            write_json(F'{self.result_path}/{self.experiment_id}.json',
                       self.result,
                       do_clear=False)
        except FileNotFoundError:
            os.makedirs(self.result_path, exist_ok=False)
            write_json(F'{self.result_path}/{self.experiment_id}.json',
                       self.result,
                       do_clear=False)

        if (self.do_full_save
                is not None) and (not self.do_full_save(self.result)):
            G.warn(
                'Breaking out of result-saving loop early! Remaining result files will not be saved'
            )
            return 'break'
Exemple #2
0
 def save_key(self):
     """Create a new file for this cross_experiment_key if :attr:`exists` is False"""
     if not self.exists:
         write_json(F'{self.tested_keys_dir}/{self.key}.json', {})
         self.exists = True
         G.log(F'Saved {self.key_type}_key: "{self.key}"')
     else:
         G.log(F'{self.key_type}_key "{self.key}" already exists - Skipped saving')