Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat: support script files #330

Conversation

maartenbreddels
Copy link
Member

Depends on #309 (alternative to #328)

Now we can do:

$ voila tests/notebooks/print.jl
$ voila tests/notebooks/print.py

It works by injecting the script code into an in-memory single-cell notebook, which means the last expression is printed out. If for some reasons one needs more output, you can use display(expression), or use jupytext (which should also be supported with this PR).

@maartenbreddels
Copy link
Member Author

Example usage:

voila --VoilaConfiguration.extension_language_mapping='{".py": "python", ".xcpp": "C++11"}' \
  --VoilaConfiguration.language_kernel_mapping='{"python": "xpython"}' tests/notebooks

Now you can access:

The tree handler and the voila handler (both the standalone and server extension) will serve and show .ipynb and all the extensions listed in this configuration option.

The final step would be to document this

We might also want an extension_kernel_mapping configuration, to go directly from .py -> <kernel_name>, but maybe that is overkill.

tests/app/tree_test.py Outdated Show resolved Hide resolved
@jtpio
Copy link
Member

jtpio commented Aug 27, 2019

We might also want an extension_kernel_mapping configuration, to go directly from .py -> <kernel_name>, but maybe that is overkill.

That would remove one level of indirection, but I guess having both extension_language_mapping and language_kernel_mapping gives enough flexibility. Also we would need to handle conflicts or precedence if the 3 options are used together (in a conf file for example).

@jtpio
Copy link
Member

jtpio commented Aug 27, 2019

We can also consider adding aliases for these options if they tend to be used often.

'name': kernel_name
}
},
cells=[nbformat.v4.new_code_cell(model['content'])],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe later after adding support for the progressive rendering (#133) there could be more than one cell created, from cell delimiters such as %% or # In[1]:.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this could again be a configurable, mapping from file extension to regex. I'd say not now right?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed let's do that later (we can open an issue to track it).

Co-Authored-By: Jeremy Tuloup <jeremy.tuloup@gmail.com>
@SylvainCorlay SylvainCorlay merged commit 344b4ff into voila-dashboards:master Aug 28, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants