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

Supporting non-py:percent File Formats #15

Open
githubpsyche opened this issue Oct 30, 2022 · 0 comments
Open

Supporting non-py:percent File Formats #15

githubpsyche opened this issue Oct 30, 2022 · 0 comments

Comments

@githubpsyche
Copy link

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.

@githubpsyche githubpsyche changed the title Supporting Other File Formats Supporting non-py:percent File Formats Oct 30, 2022
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

No branches or pull requests

1 participant