Closed MaxTuecke closed 2 weeks ago
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
).
:exclamation: Your organization needs to install the Codecov GitHub app to enable full functionality.
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
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:
NotebookMetadata
and RequirementsData
to pydantic BaseModel
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 usednbformat
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:
build_notebook_session_image
now copies incustom_jupyter_config.py
to the container so jupyter can be launched with the custom config. The last line of this filec.FileContentsManager.post_save_hook = post_save_hook
is appended to the file during runtime, since jupyter's magic variablec
causes an error when trying to import the script.start_container_with_notebook
has a new argument,custom_config
, which is default True. This adds--config=/garden/custom_jupyter_config.py
to the entrypoint command for the container. The only time this would be turned off is when usingnotebook debug
. Otherwise, the post save hooks should always be turned on.start_container_with_notebook
now launches the container with a new env varsNOTEBOOK_PATH
andREQUIREMENTS_PATH
which is the notebook's and requirements (if one was provided) path inside the container. It's a pain to get the either while it is running, so this just makes life easier.start_container_with_notebook
is binding the users requirements file (if one was provided) to the one in the container.build_notebook_session_image
will exclude the tagged widget cell from the script.NotebookMetadata
andRequirementsData
from namedtuple to pydantic BaseModel.notebook start
will now always try to add the widget cell and empty garden_metadata dict to the notebook if either is missing. The widget cell is tagged withgarden_display_metadata_cell
Testing
Updated the old test_metadata tests to test for the new format.
📚 Documentation preview 📚: https://garden-ai--482.org.readthedocs.build/en/482/