Ejemplo n.º 1
0
    def __init__(self,
                 notebook_file=None,
                 output_file="fairing_output_notebook.ipynb",
                 input_files=None,
                 command=None,
                 path_prefix=constants.DEFAULT_DEST_PREFIX,
                 output_map=None):

        if notebook_file is None and notebook_util.is_in_notebook():
            notebook_file = notebook_util.get_notebook_name()

        if notebook_file is None:
            raise ValueError('A notebook_file must be provided.')

        relative_notebook_file = notebook_file
        # Convert absolute notebook path to relative path
        if os.path.isabs(notebook_file[0]):
            relative_notebook_file = os.path.relpath(notebook_file)

        if command is None:
            command = [
                "papermill", relative_notebook_file, output_file,
                "--log-output"
            ]

        input_files = input_files or []
        if relative_notebook_file not in input_files:
            input_files.append(relative_notebook_file)

        super().__init__(executable=None,
                         input_files=input_files,
                         command=command,
                         output_map=output_map,
                         path_prefix=path_prefix)
Ejemplo n.º 2
0
 def __init__(self,
              notebook_file=None,
              command=["jupyter", "nbconvert", "--stdout", "--to", "notebook", "--execute"],
              path_prefix=constants.DEFAULT_DEST_PREFIX,
              output_map=None):
     
     if notebook_file is None and notebook_util.is_in_notebook():
         notebook_file = notebook_util.get_notebook_name()
     
     super().__init__(
         executable=notebook_file,
         input_files=[notebook_file],
         command=command,
         output_map=output_map,
         path_prefix=path_prefix)
Ejemplo n.º 3
0
    def __init__(self,
                 notebook_file=None,
                 notebook_preprocessor=FilterMagicCommands,
                 executable=None,
                 command=["python"],
                 path_prefix=constants.DEFAULT_DEST_PREFIX,
                 output_map={}):

        super().__init__(executable=executable,
                         input_files=[],
                         output_map=output_map,
                         path_prefix=path_prefix)

        if notebook_file is None and notebook_util.is_in_notebook():
            notebook_file = notebook_util.get_notebook_name()

        self.notebook_file = notebook_file
        self.notebook_preprocessor = notebook_preprocessor
Ejemplo n.º 4
0
    def __init__(self, #pylint:disable=dangerous-default-value
                 notebook_file=None,
                 notebook_preprocessor=FilterMagicCommands,
                 executable=None,
                 command=["python"],
                 path_prefix=constants.DEFAULT_DEST_PREFIX,
                 output_map=None,
                 overwrite=True):

        super().__init__(
            executable=executable,
            input_files=[],
            output_map=output_map,
            path_prefix=path_prefix)

        if notebook_file is None and notebook_util.is_in_notebook():
            notebook_file = notebook_util.get_notebook_name()

        self.notebook_file = notebook_file
        self.notebook_preprocessor = notebook_preprocessor
        self.overwrite = overwrite
Ejemplo n.º 5
0
    def __init__(self,
                 notebook_file=None,
                 input_files=None,
                 command=[
                     "jupyter", "nbconvert", "--stdout", "--to", "notebook",
                     "--execute", "--allow-errors",
                     "--ExecutePreprocessor.timeout=-1"
                 ],
                 path_prefix=constants.DEFAULT_DEST_PREFIX,
                 output_map=None):

        if notebook_file is None and notebook_util.is_in_notebook():
            notebook_file = notebook_util.get_notebook_name()

        input_files = input_files or []
        if notebook_file not in input_files:
            input_files.append(notebook_file)

        super().__init__(executable=notebook_file,
                         input_files=input_files,
                         command=command,
                         output_map=output_map,
                         path_prefix=path_prefix)