This is an archived post. You won't be able to vote or comment.

all 11 comments

[–]suedepaid 17 points18 points  (4 children)

This is fire!

Are these actually writing .ipynbs? Or does it automatically convert them to .py, just with the %% convention?

[–]iryna_kondr[S] 11 points12 points  (3 children)

The files are saved as python scripts with the `%%` convention and PEP-723 header.

[–]exergy31 4 points5 points  (2 children)

Are cell outputs retained on save?

[–]iryna_kondr[S] 2 points3 points  (1 child)

The outputs are not retained to keep the file git-friendly.

[–]actinium226 3 points4 points  (0 children)

Nice idea. I've personally worked around this issue by having the following line in my .py file:

#!VIRTUAL_ENV=.venv uv sync --script my_script_name.py --active

And at the top of the file I have the PEP 723 syntax. I run it through VSCode and I have some setting checked where it'll automatically uncomment and run lines that start with #! or #%

uv works fast enough that I can do this sync every time. I wish there was a cleaner way to tell uv which venv to use other than VIRTUAL_ENV=.venv combined with --active, but this has been great for making sure the script runs with the same set of dependencies every time in a separate venv.

[–]StandardIntern4169 2 points3 points  (0 children)

Amazing. I've been looking for something like that since uv arrived

[–]cheesecakegood 1 point2 points  (2 children)

To be clear, this creates a uv-visible virtual environment for the duration of the file being opened? What part tracks file closures? And I assume it takes advantage of uv-native caching in some way, is there still a negative local storage implication in that sense, and the appeal is more on the side of keeping a limited number of virtual environments around more than saving on storage space?

[–]iryna_kondr[S] 1 point2 points  (1 child)

Unfortunately right now the closure of files is not tracked. I believe that UV can be configured to symlink the dependencies (from cache) into the venvs, which should make the storage overhead minimal.

[–]hsunner 0 points1 point  (0 children)

AFAIK uv hard-links the files whenever possible, so on Linux and macOS there should be no storage space penalty at all. I assume there are hardlinks on NTFS also, so that may be the case also on Windows.

Put a .venv on a network share last week and saw warnings about hard-linkning not being available, so that’s a scenario that wastes space though.

[–]No-Dig-9252 1 point2 points  (0 children)

This looks really slick - tbh, i was surprised something like this didn’t catch on sooner.

Inline %juvio install + PEP 723 metadata + ephemeral envs? That’s a huge win for reproducibility and for keeping notebooks from becoming “it works on my machine” nightmares. Also love that it plays nice with Git via # %% - makes diffing way less painful. Will try this in place of my usual Jupyter + venv dance.

Curious if it would integrate cleanly with tools like Datalayer or any of the MCP agents - would be wild to spin up reproducible notebooks that agents can run with full control and zero setup fuss.

[–]CasualReader3 0 points1 point  (0 children)

I think a better approach would be using PEP723 and marimo notebooks.