def execute_managed_notebook( cls, nb_man, kernel_name, log_output=False, stdout_file=None, stderr_file=None, start_timeout=60, execution_timeout=None, **kwargs, ): # Exclude parameters that named differently downstream safe_kwargs = remove_args( ["timeout", "startup_timeout", "input_path"], **kwargs) # Nicely handle preprocessor arguments prioritizing values set by engine final_kwargs = merge_kwargs( safe_kwargs, timeout=execution_timeout if execution_timeout else kwargs.get("timeout"), startup_timeout=start_timeout, kernel_name=kernel_name, log=logger, log_output=log_output, stdout_file=stdout_file, stderr_file=stderr_file, ) return DagstermillNotebookClient(nb_man, **final_kwargs).execute()
def execute_managed_notebook(cls, nb_man, kernel_name, log_output=False, stdout_file=None, stderr_file=None, start_timeout=60, execution_timeout=None, **kwargs): """ Performs the actual execution of the parameterized notebook. Note that kwargs may specify an alternate 'kernel_manager_class' for nbclient to use, and 'kernel_env' and 'kernel_cwd' to pass to the kernel process's environment. Args: nb (NotebookNode): Executable notebook object. kernel_name (str): Name of kernel to execute the notebook against. log_output (bool): Flag for whether or not to write notebook output to the configured logger. startup_timeout (int): Duration to wait for kernel start-up. execution_timeout (int): Duration to wait before failing execution (default: never). kernel_env (dict): Passed as the kernel 'env' parameter to the execute() method kernel_cwd (str): Passed as the kernel 'cwd' parameter to the execute() method kernel_manager_class: (str) If set, specifies the use of an alternate kernel manager. """ # Exclude parameters that named differently downstream safe_kwargs = remove_args( ['timeout', 'startup_timeout', 'kernel_env', 'kernel_cwd'], **kwargs) # Nicely handle preprocessor arguments prioritizing values set by engine final_kwargs = merge_kwargs( safe_kwargs, timeout=execution_timeout if execution_timeout else kwargs.get('timeout'), startup_timeout=start_timeout, kernel_name=kernel_name, log=logger, log_output=log_output, stdout_file=stdout_file, stderr_file=stderr_file, ) kernel_kwargs = dict() kernel_kwargs['env'] = kwargs.get('kernel_env') # Only include kernel_name and set path if GatewayKernelManager will be used kernel_manager_class = final_kwargs.get('kernel_manager_class') if kernel_manager_class == 'jupyter_server.gateway.managers.GatewayKernelManager': kernel_kwargs['kernel_name'] = kernel_name kernel_kwargs['path'] = kwargs.get('kernel_cwd') return PapermillNotebookClient(nb_man, **final_kwargs).execute(**kernel_kwargs)
def execute_managed_notebook(cls, nb_man, kernel_name, log_output=False, stdout_file=None, stderr_file=None, start_timeout=60, execution_timeout=None, **kwargs): """ Performs the actual execution of the parameterized notebook locally. Args: nb (NotebookNode): Executable notebook object. kernel_name (str): Name of kernel to execute the notebook against. log_output (bool): Flag for whether or not to write notebook output to the configured logger. start_timeout (int): Duration to wait for kernel start-up. execution_timeout (int): Duration to wait before failing execution (default: never). Note: The preprocessor concept in this method is similar to what is used by `nbconvert`, and it is somewhat misleading here. The preprocesser represents a notebook processor, not a preparation object. """ # Exclude parameters that named differently downstream safe_kwargs = remove_args(['timeout', 'startup_timeout'], **kwargs) # Nicely handle preprocessor arguments prioritizing values set by engine final_kwargs = merge_kwargs( safe_kwargs, timeout=execution_timeout if execution_timeout else kwargs.get('timeout'), startup_timeout=start_timeout, kernel_name=kernel_name, log=logger, log_output=log_output, stdout_file=stdout_file, stderr_file=stderr_file, ) return SoSPapermillNotebookClient(nb_man, **final_kwargs).execute()