Garden-AI / garden

https://garden-ai.readthedocs.io
MIT License
16 stars 4 forks source link

Notebook metadata editor widget #482

Closed MaxTuecke closed 2 weeks ago

MaxTuecke commented 4 weeks ago

Adds #475

Overview

Adds display_metadata_widget(), which displays an ipywidget form that lets users easily edit a notebook's metadata.

Discussion

In place of the old top cell containing the commented out metadata json, the new top cell of a notebook will import and run display_metadata_widget().

If the user makes any changes to their notebooks requirements, the widget will show a 'Install new requirements' button that installs the new requirements to the container and updates your local requirements file if one was provided.

When a user updates their notebook's metadata with the widget, it will immediately json save the new NotebookMetadata object to /garden/notebook_metadata.json

In order to then save the metadata to the notebook, jupyter is now being launched with a custom config that adds a post save hook. When the user saves their notebook, the hook goes and looks for the json NotebookMetadata file and saves the garden metadata with the rest of the notebook's metadata. Jupyter can get upset about file versions if we just used nbformat to add the metadata, so the post save hook is the best way to edit the notebook's file while the notebook is running.

Other changes:

Testing

Updated the old test_metadata tests to test for the new format.


📚 Documentation preview 📚: https://garden-ai--482.org.readthedocs.build/en/482/

codecov-commenter commented 4 weeks ago

Codecov Report

Attention: Patch coverage is 36.84211% with 108 lines in your changes missing coverage. Please review.

Project coverage is 75.50%. Comparing base (9ccdbd0) to head (4c2cb03).

Files Patch % Lines
garden_ai/notebook_metadata.py 27.73% 86 Missing :warning:
garden_ai/scripts/custom_jupyter_config.py 31.25% 11 Missing :warning:
garden_ai/app/notebook.py 0.00% 9 Missing :warning:
garden_ai/containers.py 88.23% 2 Missing :warning:

:exclamation: Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #482 +/- ## ========================================== - Coverage 77.42% 75.50% -1.92% ========================================== Files 54 55 +1 Lines 3592 3695 +103 ========================================== + Hits 2781 2790 +9 - Misses 811 905 +94 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

MaxTuecke commented 2 weeks ago

As we talked about in person, I added in a 'Install new requirements' button that pops up when any changes are made to the requirements w/ the widget. It will install new reqs, update the users local reqs file (if one was provided) and then restart the jupyter kernel.

I also added info popup messages to help the user understand how to use the widget.

As Owen / Hayden suggested I also: