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

Allow to pair notebooks in trees rather than in folders #424

Closed
mwouts opened this issue Jan 27, 2020 · 2 comments · Fixed by #511
Closed

Allow to pair notebooks in trees rather than in folders #424

mwouts opened this issue Jan 27, 2020 · 2 comments · Fixed by #511
Milestone

Comments

@mwouts
Copy link
Owner

mwouts commented Jan 27, 2020

That was suggested by @technic at #265:

I want to have to directory trees with the same structure, but one with the ipynb files, and another one with python files.

Maybe we could use, say jupytext.formats="/notebooks//ipynb,/scripts//py" (using e.g. the initial / to indicate that path is matched from the root rather than from the parent dir) to pair notebooks and scripts in trees rooted at /notebooks and /scripts. For example, /notebooks/foo/bar/qqq.ipynb would be paired with /scripts/foo/bar/qqq.py.

@mwouts mwouts added this to the 1.5.0 milestone Apr 8, 2020
@mwouts
Copy link
Owner Author

mwouts commented May 22, 2020

I have implemented something like this in Jupytext 1.5.0 (RC coming soon). You'll have to use e.g.
jupytext.formats="notebooks///ipynb,scripts///py" (triple slash), and this gives the pairing in tree. See for instance this test:

jupytext/tests/test_cli.py

Lines 1018 to 1027 in ccb736c

def test_pair_in_tree(tmpdir):
nb_file = tmpdir.mkdir("notebooks").mkdir("subfolder").join("example.ipynb")
py_file = tmpdir.mkdir("scripts").mkdir("subfolder").join("example.py")
write(new_notebook(cells=[new_markdown_cell("A markdown cell")]), str(nb_file))
jupytext(["--set-formats", "notebooks///ipynb,scripts///py:percent", str(nb_file)])
assert py_file.exists()
assert "A markdown cell" in py_file.read()

@mwouts
Copy link
Owner Author

mwouts commented May 22, 2020

The rc is available:

pip install jupytext==1.5.0rc1

Please give it a try, and let me know if it works as expected!

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 a pull request may close this issue.

1 participant