question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Opening non Notebook related scripts automatically adds metadata

See original GitHub issue

Imagine I have a non-notebook related script which contents are:

print('Hello World')

If I open in it using the jupyter interface, after installing jupytext, it opens as if it were a notebook. Then if I do some minor edits and save it, its contents become:

# ---
# jupyter:
#   jupytext:
#     text_representation:
#       extension: .py
#       format_name: light
#       format_version: '1.3'
#       jupytext_version: 0.8.2
#   kernelspec:
#     display_name: Python 3
#     language: python
#     name: python3
#   language_info:
#     codemirror_mode:
#       name: ipython
#       version: 3
#     file_extension: .py
#     mimetype: text/x-python
#     name: python
#     nbconvert_exporter: python
#     pygments_lexer: ipython3
#     version: 3.7.0
#   toc:
#     nav_menu: {}
#     number_sections: true
#     sideBar: true
#     skip_h1_title: false
#     toc_cell: false
#     toc_position: {}
#     toc_section_display: block
#     toc_window_display: false
#   varInspector:
#     cols:
#       lenName: 16
#       lenType: 16
#       lenVar: 40
#     kernels_config:
#       python:
#         delete_cmd_postfix: ''
#         delete_cmd_prefix: 'del '
#         library: var_list.py
#         varRefreshCmd: print(var_dic_list())
#       r:
#         delete_cmd_postfix: ') '
#         delete_cmd_prefix: rm(
#         library: var_list.r
#         varRefreshCmd: 'cat(var_dic_list()) '
#     types_to_exclude:
#     - module
#     - function
#     - builtin_function_or_method
#     - instance
#     - _Feature
#     window_display: false
# ---

print('Hello World!')

Is there a way to avoid jupytext interfering with native python scripts?

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:9 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
silverdnacommented, Oct 30, 2018

@mwouts I had the chance to give it a try now. So far it looks awesome! It fits perfectly the use of my team. Thank you for your support 😃

1reaction
silverdnacommented, Oct 22, 2018

Hi @mwouts,

Thanks for your support.

do you expect that Jupyter and Jupytext should behave differently? Should a notebook created with command line jupytext have the header when exported to a script again? I would think the two ways of creating an ipynb notebook from a script should give the same notebook.

As far as my understanding goes, I believe the behaviour should be the same from jupyter and jupytext.

Note that this is the default in Jupyter Lab (scripts can be opened as notebooks using a context menu, see the README). For Jupyter Notebook, we could easily have a parameter on Jupytext’s content manager to avoid classifying scripts as notebooks (classification of notebooks/non notebooks is done here).

This makes sense to me. The reasoning behind me opening this issue was seeing if it was possible to make jupytext as less intrusive (read, not changing default behaviour) as possible in functionalities (such as editing pure python scripts) that go outside of Jupytext core (notebooks).

At the same time I also see the option of editing script as notebooks with good eyes 😃

Hello @andrethrill , I have started working on this in the v0.8.4 branch.

That’s awesome. Thank you so much once again for your support!

Read more comments on GitHub >

github_iconTop Results From Across the Web

The Notebook file format — nbformat 5.7 documentation
This page contains a human-readable description of the notebook format. Note. All metadata fields are optional. While the types and values of some...
Read more >
how to programmatically add slides cell metadata in jupyter ...
which programmatically adds metadata to hide cell code. I would like to be able to do the same but adding slideshow metadata. For...
Read more >
Add metadata to your book pages - Jupyter Book
There are two straightforward ways to add metadata to cells: Use the Jupyter Notebook cell tag editor. The Jupyter Notebook ships with a...
Read more >
Build large-scale data copy pipelines with metadata-driven ...
Go throughput the copy data tool, and it will come up with a new SQL script for you. Rerun the SQL script to...
Read more >
Notebook Instance Metadata - Amazon SageMaker
For information about notebook instance lifecycle configurations, see Customize a Notebook Instance Using a Lifecycle Configuration Script. The resource- ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found