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

Add lock command and support juv run Untitled.ipynb --locked #7

Closed
manzt opened this issue Oct 21, 2024 · 9 comments
Closed

Add lock command and support juv run Untitled.ipynb --locked #7

manzt opened this issue Oct 21, 2024 · 9 comments

Comments

@manzt
Copy link
Owner

manzt commented Oct 21, 2024

Ref: https://x.com/rahuldave/status/1848072186340196391

The idea would be to put a lockfile in the notebook metadata (either cell-level or top-level) and we could update the lock file on run/add/lock.

Then we could add a flag to --locked to skip dependency resolution and just create the enviroment from the lockfile.

@manzt manzt changed the title Idea: Add lock command and support juv run Untitled.ipynb --locked Add lock command and support juv run Untitled.ipynb --locked Oct 21, 2024
@flying-sheep
Copy link

I saw this project and had the exact same thought!

In fact I don‘t think we’d need dependency specification in a code cell at all: jupyter has a perfect place for notebook-wide structured metadata already.

@manzt
Copy link
Owner Author

manzt commented Oct 29, 2024

Should be able to benefit from:

When it lands to save the export to the notebook metadata.

@manzt
Copy link
Owner Author

manzt commented Oct 29, 2024

In fact I don‘t think we’d need dependency specification in a code cell at all: jupyter has a perfect place for notebook-wide structured metadata already.

Yeah, I'm a bit torn on this. Keeping in a notebook cell as a comment aligns closer with scripts, but hiding means we could do more to control the behavior of adding/removing dependencies. We'd probably need better ways to show this metadata to users though in the notebook, if we choose to hide it. When/if we introduce locking, we could always write a new lock on any command (add, run, ...) and also offer something like juv sync to sync the lock.

@manzt
Copy link
Owner Author

manzt commented Oct 29, 2024

uv scripts now also support uv.tool.exclude-newer metadata. Even without a lock file, this could go a long way for making one-off notebooks more reproducible to add a timestamp to the notebook meta that we could have a flag to run.

e.g.,

juv init Untitled.ipynb # writes a timestamp to the notebook metadata
juv add Untitled.ipynb notebook
# juv timestamp Untitled.ipynb # explicitly update
juv run Untitled.ipynb
juv run --exclude-newer=last-timestamp Untitled.ipyng

@flying-sheep
Copy link

The purpose of putting it into the metadata isn’t supposed to hide it, but to allow us to

  1. create a jupyterlab plugin to display and modify dependencies.
    since we start the jupyterlab instance with juv run, we’ll be able to inject the plugin into that environment, making that not a problem
  2. move the feature from the plugin into jupyterlab upstream (possibly with some changes after feedback)
  3. this makes it likely that alternative frontends like VS Code will also be able to support it

@tlambert03
Copy link

def, love the lock idea :)

@manzt
Copy link
Owner Author

manzt commented Nov 13, 2024

In lieu of locking, for the time being I've added juv stamp to pin various timestamps for uv's time-contrained resolution. #50 (comment)

@manzt
Copy link
Owner Author

manzt commented Jan 14, 2025

See #64, uv now supports locking standalone scripts.

uv lock --script foo.py # generates foo.py.lock

Right now I'm writing this metadata to the notebook-level metadata under a "uv.lock" key. It will require a little refactoring, but I will update other commands (e.g., run & add) to respect and update this metadata if it exists accordingly.

@manzt
Copy link
Owner Author

manzt commented Jan 15, 2025

Released in v0.3.0!

@manzt manzt closed this as completed Jan 15, 2025
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

3 participants