Git Product home page Git Product logo

vscode-jupytext's Introduction

A Visual Studio Code extension that provides ability to open and execute script files as Jupyter Notebooks.

Like the UI of Jupyter Notebooks, but prefer to use plain text files, this is the extension for you.

Features

  • Open and execute script files as Jupyter Notebooks
  • Editing/Updating notebooks will result in the corresponding source script file getting updated
  • Notebook file doesn't exist on disc (hence no need to manage two files and manage syncing the two).

Requirements

  • Jupyter Extension
  • VS Code Insiders (VS Code Stable is not yet supported)
  • Python (temporary, see Roadmap)

Getting Started

  • Please install VS Code Insiders (stable is not yet supported)
  • Install this extension
  • Launch VS Code with the following command line code-insiders --enable-proposed-api=donjayamanne.vscode-jupytext
  • Right click a file and select Open as a Jupyter Notebook
  • Start executing code against Jupyter Kernels, save changes to notebook will result in the corresponding script file getting updated.

Based on the Jupytext

  • This extension merely atttempts to provide the same functionality as Jupytext, but in VSCode.
  • The Jupytext package is bundled with the extension and used where Python is avaialble.
  • Opening Python and some files such as rmd or markdown will require Python runtime for now

Roadmap

  • Remove dependency on Python runtime for script files such as TypeScript, JavaScript, Rust, C#, F#, etc
  • Seemless editing of both script file and notebook together
  • Support metadata in script files (currently metadata might not be saved)
  • Configuration of formats (metdata)

vscode-jupytext's People

Contributors

hectormz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

vscode-jupytext's Issues

use installed python libs ?

question:

what is the purpose of the python-libs folder ? is it always used, or it is used only if these libraries are not installed in the current python environment ?

I am only beginning with vscode extensions, so I don't know what's the common practice, but if it is the former,
shipping pinned libraries like it is done now seems wrong

at the very least we might want to upgrade to jupytext-1.14 - as opposed to 1.11 as it is now

Contribution Guide

I'd like to help with extending this extension sometime. I've started customizing it for my purposes, but I haven't been able to figure out how to get the development workflow documented in this tutorial working for this project https://code.visualstudio.com/api/get-started/your-first-extension . Maybe it's because the extension uses a different test or compilation framework; I'm not experienced enough with typescript to say. If you have the time to write up a concise guide to the structure of your extension and how to get a good developer workflow going, I expect your project would attract further contributions that help it match jupytext's feature set in juputer lab.

bulky "Open as jupyter notebook" button

I understand the value for beginners to have this feature made very visible

however on the longer run, I tend to find this button quite in the middle of things; for example below with a reasonable width for my vscode window, I can see only 3 file tabs in the header area

image

is there currently a means to turn this button into a single icon - like the other ones here
image

if not, would it make sense to consider that feature ?

Traceback error on VS code

Traceback (most recent call last): File "/usr/lib/python2.7/runpy.py", line 163, in _run_module_as_main mod_name, _Error) File "/usr/lib/python2.7/runpy.py", line 111, in _get_module_details import(mod_name) # Do not catch exceptions initializing package File "jupytext/init.py", line 3, in from .formats import NOTEBOOK_EXTENSIONS, get_format_implementation, guess_format File "jupytext/formats.py", line 10, in import nbformat File "nbformat/init.py", line 10, in from traitlets.log import get_logger File "traitlets/init.py", line 3, in from . import traitlets File "traitlets/traitlets.py", line 1014 class HasDescriptors(metaclass=MetaHasDescriptors): ^ SyntaxError: invalid syntax

  1. Installed via ext install
  2. code-insiders --enable-proposed-api=donjayamanne.vscode-jupytext
  3. couldn't see option to convert, after right clicking on py/ipynb file
  4. tried to install both jupytext libraries via marketplace.
  5. getting the above error.

FYR:
Ubuntu 18
Python version 3.6.9

Thanks for developing the library, TIA

Nothing happens when clicking "Open as Jupyter Notebook"

I have been using this extension successfully on an ubuntu environment before, but now on my windows environment the extension doesn't work.
The option "Open as Jupyter Notebook" is available, but doesnt respond at all. No error message, just nothing.
I am currently working on insider-1.64.0

Impossible to open more than one notebook

Opening more than one .py file as Notebook, seems like all but the last aren't handled anymore by vscode-jupytext and become normal notebooks that are saved as .ipynb instead of saving back to the .py file used to create them

ipynb doesn't reopen after close

Jupytext works well on Visual Studio Code Insiders.

However: Once I close the .ipynb I cannot reopen the notebook file again. I press "Open as Jupyter Notebook" and nothing happens (not even an error code). This happens even if I restart Insiders.

I am on: Windows 10 Enterpise, Insider Version 1.63
Jupytext version: v0.1.0 ( started via code-insiders --enable-proposed-api=donjayamanne.vscode-jupytext )

I am happy to provide more information if you could let me know what information you need from me.

Incompatible with version 1.47.3

I want to know the maximum version of VS Code Jupytext is compatible with. Can anyone please find out the information for me?

.ipynb does not exist on disc

When I work on notebooks, there is often useful (slow to recompute) information in the outputs, so I prefer to have the .ipynb file around. But when I want to check things in to version control, I want to check the .py file. With this extension, the .ipynb file does not exist at all, so there is nowhere to store the output other than the editor's memory. If I close the editor (window) and then resume work later, all my outputs are gone.

In contrast, using JupyterLab plus jupytext, I can arrange to have both a .ipynb and .py file around; when either is modified, the other is updated to match (effectively by running jupytext --sync). Thus one can comfortably modify either file and be sure that one's changes won't be lost, and the output persists locally but version control can restrict itself to the .py file.

Status?

Will this feature be added to the main VS Code extensions?

Often I save python jupyter notebooks as py:percent scripts via jupytext, since they are handier for version control with Git.

However, it's useful to open them directly as Jupyter notebooks without having to convert them first (Jupyterlab allows this).

Working directory does not follow the 'Notebook file root' setting

Choosing "Open as Jupyter notebook", the resulting notebook sets working directory to ${workspaceFolder} even though my Notebook file root-setting is ${fileDirname}.

It would make sense to set working directory for the notebook the same way it is set if I run code cells from the plain python file.

Supporting non-py:percent File Formats

The extension in its current state only really works for python scripts in the percent format. But jupytext doesn't have this limitation.

Currently, the extension supports opening markdown files as jupyter notebooks. But when a save attempts, this error is returned:

Failed to save 'test.ipynb': Unable to write file 'jupytext:/c:/Users/gunnj/workspace/test.ipynb' (Traceback (most recent call last):
  File "C:\Users\gunnj\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\Users\gunnj\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "c:\Users\gunnj\.vscode-insiders\extensions\donjayamanne.vscode-jupytext-0.1.0\python-libs\jupytext\__main__.py", line 13, in <module>
    sys.exit(jupytext())
  File "c:\Users\gunnj\.vscode-insiders\extensions\donjayamanne.vscode-jupytext-0.1.0\python-libs\jupytext\cli.py", line 427, in jupytext
    exit_code += jupytext_single_file(nb_file, args, log)
  File "c:\Users\gunnj\.vscode-insiders\extensions\donjayamanne.vscode-jupytext-0.1.0\python-libs\jupytext\cli.py", line 811, in jupytext_single_file
    lazy_write(nb_dest, fmt=dest_fmt, action=action)
  File "c:\Users\gunnj\.vscode-insiders\extensions\donjayamanne.vscode-jupytext-0.1.0\python-libs\jupytext\cli.py", line 722, in lazy_write
    write(notebook, "-", fmt=fmt)
  File "c:\Users\gunnj\.vscode-insiders\extensions\donjayamanne.vscode-jupytext-0.1.0\python-libs\jupytext\jupytext.py", line 524, in write
    content = writes(nb, version=version, fmt=fmt, config=config, **kwargs)
  File "c:\Users\gunnj\.vscode-insiders\extensions\donjayamanne.vscode-jupytext-0.1.0\python-libs\jupytext\jupytext.py", line 508, in writes
    writer = TextNotebookConverter(fmt, config)
  File "c:\Users\gunnj\.vscode-insiders\extensions\donjayamanne.vscode-jupytext-0.1.0\python-libs\jupytext\jupytext.py", line 55, in __init__
    self.implementation = get_format_implementation(
  File "c:\Users\gunnj\.vscode-insiders\extensions\donjayamanne.vscode-jupytext-0.1.0\python-libs\jupytext\formats.py", line 240, in get_format_implementation
    raise JupytextFormatError(
jupytext.formats.JupytextFormatError: Format 'percent' is not associated to extension '.md'. Please choose one of: markdown, pandoc, myst.

I found that the root of this bug is line 92 of src/conversion.ts:

const convertedFile = await runJupytext([
        '-m',
        'jupytext',
        '--to',
        `${extension.substring(1)}:percent`,
        uri.fsPath,
        '--output',
        '-',
    ]);

There is no percent format for the markdown file, so this operation raises the described error. Since I mostly work with markdown source files, I've changed this line to

`${extension.substring(1)}`,

And that works well for me. But then this drop supports for the py:percent format, so it's not the ideal solution. Just wanted to raise this point.

quarto format support

Quarto is a scientific and technical publishing system built on Pandoc. It's been growing in popularity lately, now has its own vscode extension, and has received support in recent updates to jupytext. If you have quarto installed, Jupytext lets you edit .qmd documents as notebooks in Jupyter, and pair .ipynb notebooks with .qmd notebooks.

The current version of vscode-jupytext doesn't support the quarto format, but a small change to packages.json's `"contributes" / "menus" / "explorer/context" list adds support for the format. We just add:

                {
                    "command": "jupyter.openAsPairedNotebook",
                    "when": "resourceLangId == quarto"
                }

We also have to update the extension's jupytext version to one with quarto file format. I confirmed 1.14.1 works.

And finally, to allow notebooks instantiated by vscode-jupytext by this command to update the source qmd file, we probably still need to address #15 with a change like the one I suggested.

Interoperation with the quarto extension doesn't seem perfect though.

Expected module name

Capture
hloo
when i write a code in vs code i facing some problem plz tell me any solution
i upload screenshot plzz check this problem

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.