Skip to content
Snippets Groups Projects
repositories.py 39 KiB
Newer Older
  • Learn to ignore specific revisions
  •     def track_results(self, results_commit_message: str, debug=False):
    
    Ronald Jäpel's avatar
    Ronald Jäpel committed
            """
    
            Context manager to be used when running project code that produces output that should
    
    Ronald Jäpel's avatar
    Ronald Jäpel committed
            be tracked in the output repository.
            :param results_commit_message:
                Commit message for the commit of the output repository.
            """
    
            new_branch_name = self.enter_context()
            try:
                yield new_branch_name
            except Exception as e:
    
                self.output_repo.delete_active_branch_if_branch_is_empty()
    
                raise e
            else:
                self.exit_context(message=results_commit_message)
    
    
        def commit_nb_output(self, notebook_path: str, results_commit_message: str,
                             force_rerun=False, timeout=600, conversion_formats: list = None):
    
            if not Path(notebook_path).is_absolute():
                notebook_path = self.working_dir / notebook_path
    
    
            # if "nbconvert_call" in sys.argv:
            #     # This won't work as intended.
            #     self.enter_context(force=True)
            # else:
            #     self.enter_context(force=False)
    
    
            notebook = Notebook(notebook_path)
            notebook.check_and_rerun_notebook(force_rerun=force_rerun,
                                              timeout=timeout)
            notebook.convert_ipynb(self.output_path, formats=conversion_formats)
            notebook.export_all_figures(self.output_path)
    
            self.exit_context(results_commit_message)
    
    
    class OutputRepo(BaseRepo):