How to use the voila.execute.VoilaExecutePreprocessor function in voila

To help you get started, we’ve selected a few voila examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github voila-dashboards / voila / voila / app.py View on Github external
)
    )
    aliases = {
        'port': 'Voila.port',
        'static': 'Voila.static_root',
        'strip_sources': 'VoilaConfiguration.strip_sources',
        'autoreload': 'Voila.autoreload',
        'template': 'VoilaConfiguration.template',
        'theme': 'VoilaConfiguration.theme',
        'base_url': 'Voila.base_url',
        'server_url': 'Voila.server_url',
        'enable_nbextensions': 'VoilaConfiguration.enable_nbextensions'
    }
    classes = [
        VoilaConfiguration,
        VoilaExecutePreprocessor,
        VoilaExporter,
        VoilaCSSPreprocessor
    ]
    connection_dir_root = Unicode(
        config=True,
        help=_(
            'Location of temporry connection files. Defaults '
            'to system `tempfile.gettempdir()` value.'
        )
    )
    connection_dir = Unicode()

    base_url = Unicode(
        '/',
        config=True,
        help=_(
github voila-dashboards / voila / voila / handler.py View on Github external
def _jinja_cell_generator(self, nb, kernel_id):
        """Generator that will execute a single notebook cell at a time"""
        km = self.kernel_manager.get_kernel(kernel_id)

        nb, resources = ClearOutputPreprocessor().preprocess(nb, {'metadata': {'path': self.cwd}})
        ep = VoilaExecutePreprocessor(config=self.traitlet_config)

        with ep.setup_preprocessor(nb, resources, km=km):
            for cell_idx, cell in enumerate(nb.cells):
                res = ep.preprocess_cell(cell, resources, cell_idx, store_history=False)

                yield res[0]
github voila-dashboards / voila / voila / execute.py View on Github external
def executenb(nb, cwd=None, km=None, **kwargs):
    resources = {}
    if cwd is not None:
        resources['metadata'] = {'path': cwd}  # pragma: no cover
    # Clear any stale output, in case of exception
    nb, resources = ClearOutputPreprocessor().preprocess(nb, resources)
    ep = VoilaExecutePreprocessor(**kwargs)
    return ep.preprocess(nb, resources, km=km)[0]
github voila-dashboards / voila / voila / execute.py View on Github external
def __init__(self, **kwargs):
        super(VoilaExecutePreprocessor, self).__init__(**kwargs)
        self.output_hook_stack = collections.defaultdict(list)  # maps to list of hooks, where the last is used
        self.output_objects = {}