예제 #1
0
 def _build_new_files(self):
     for dest, content, permissions in self.new_files:
         filename = self._get_abs_path(dest)
         tools.makedirs(os.path.dirname(filename))
         logging.debug(f'Writing file "{filename}"')
         tools.write_file(filename, content)
         os.chmod(filename, permissions)
예제 #2
0
 def write(cls, report, filename):
     lines = ([
         r'\documentclass[tikz]{standalone}', r'\usepackage{pgfplots}',
         r'\begin{document}', r'\begin{tikzpicture}'
     ] + cls._get_plot(report) + [r'\end{tikzpicture}', r'\end{document}'])
     tools.makedirs(os.path.dirname(filename))
     tools.write_file(filename, '\n'.join(lines))
     logging.info('Wrote file://%s' % filename)
예제 #3
0
 def _compile(self):
     if not os.path.exists(os.path.join(self.path, 'build.py')):
         logging.critical('build.py not found. Please merge with master.')
     retcode = tools.run_command(['./build.py'] + self.build_options,
                                 cwd=self.path)
     if retcode == 0:
         tools.write_file(self._get_sentinel_file(), '')
     else:
         logging.critical('Build failed in {}'.format(self.path))
예제 #4
0
 def write(cls, report, filename):
     lines = ([
         r"\documentclass[tikz]{standalone}",
         r"\usepackage{pgfplots}",
         r"\begin{document}",
         r"\begin{tikzpicture}",
     ] + cls._get_plot(report) + [r"\end{tikzpicture}", r"\end{document}"])
     tools.makedirs(os.path.dirname(filename))
     tools.write_file(filename, "\n".join(lines))
     logging.info(f"Wrote file://{filename}")
예제 #5
0
    def write(self):
        """
        Write the report files.

        By default this method calls :meth:`.get_text` and writes the
        obtained text to *outfile*.

        Overwrite this method if you want to write the report file(s)
        directly. You should write them to *self.outfile*.

        """
        content = self.get_text()
        tools.makedirs(os.path.dirname(self.outfile))
        tools.write_file(self.outfile, content)
        logging.info(f"Wrote file://{self.outfile}")
예제 #6
0
    def run_steps(self, steps):
        """
        We can't submit jobs from within the grid, so we submit them
        all at once with dependencies. We also can't rewrite the job
        files after they have been submitted.
        """
        self.exp.build(write_to_disk=False)

        # Prepare job dir.
        job_dir = self.exp.path + "-grid-steps"
        if os.path.exists(job_dir):
            tools.confirm_or_abort(
                f'The path "{job_dir}" already exists, so the experiment has '
                f"already been submitted. Are you sure you want to "
                f"delete the grid-steps and submit it again?"
            )
            tools.remove_path(job_dir)

        # Overwrite exp dir if it exists.
        if any(is_build_step(step) for step in steps):
            self.exp._remove_experiment_dir()

        # Remove eval dir if it exists.
        if os.path.exists(self.exp.eval_dir):
            tools.confirm_or_abort(
                f'The evaluation directory "{self.exp.eval_dir}" already exists. '
                f"Do you want to remove it?"
            )
            tools.remove_path(self.exp.eval_dir)

        # Create job dir only when we need it.
        tools.makedirs(job_dir)

        prev_job_id = None
        for step in steps:
            job_name = self._get_job_name(step)
            job_file = os.path.join(job_dir, job_name)
            job_content = self._get_job(step, is_last=(step == steps[-1]))
            tools.write_file(job_file, job_content)
            prev_job_id = self._submit_job(
                job_name, job_file, job_dir, dependency=prev_job_id
            )
예제 #7
0
 def _compile(self):
     retcode = tools.run_command(self.build_cmd, cwd=self.path)
     if retcode == 0:
         tools.write_file(self._get_sentinel_file(), "")
     else:
         logging.critical(f"Build failed in {self.path}")