Esempio n. 1
0
    def save_report(self, records):
        """Save report to `reports.json`."""
        try:
            _file = FileOps.join_path(TaskOps().local_output_path,
                                      "reports.json")
            FileOps.make_base_dir(_file)
            data = {"_steps_": []}

            for step in self.step_names:
                if step in self.steps:
                    data["_steps_"].append(self.steps[step])
                else:
                    data["_steps_"].append({
                        "step_name": step,
                        "status": Status.unstarted
                    })

            for record in records:
                if record.step_name in data:
                    data[record.step_name].append(record.to_dict())
                else:
                    data[record.step_name] = [record.to_dict()]
            with open(_file, "w") as f:
                json.dump(data, f, indent=4, cls=JsonEncoder)
        except Exception:
            logging.warning(traceback.format_exc())
Esempio n. 2
0
 def _copy_needed_file(self):
     if self.config.pareto_front_file is None:
         raise FileNotFoundError(
             "Config item paretor_front_file not found in config file.")
     init_pareto_front_file = self.config.pareto_front_file.replace(
         "{local_base_path}", self.local_base_path)
     self.pareto_front_file = FileOps.join_path(self.local_output_path,
                                                self.step_name,
                                                "pareto_front.csv")
     FileOps.make_base_dir(self.pareto_front_file)
     FileOps.copy_file(init_pareto_front_file, self.pareto_front_file)
     if self.config.random_file is None:
         raise FileNotFoundError(
             "Config item random_file not found in config file.")
     init_random_file = self.config.random_file.replace(
         "{local_base_path}", self.local_base_path)
     self.random_file = FileOps.join_path(self.local_output_path,
                                          self.step_name, "random.csv")
     FileOps.copy_file(init_random_file, self.random_file)