Skip to content

CLI tool to "davos-enhance" a Jupyter notebook #105

@paxtonfitzpatrick

Description

@paxtonfitzpatrick

I'd love to write a script that could be integrated into Davos as a CLI entrypoint, and provide a tool that people could use to "davos-enhance" a notebook automatically.

The use case I'm imagining is you have a Jupyter notebook you want to share with someone, and you want to turn it into a "davos-enhanced notebook" to more easily share it in a reproducible way. So you open a terminal and run davos enhance path/to/notebook.ipynb. The script then:

  • adds a new cell at the top of the notebook that %pip installs and imports davos
  • parses the code in the notebook and replaces all import statements with equivalent smuggle statements
  • adds onion comments next to each smuggle statement that specify the package versions installed in your environment

The davos enhance command could support various options to do things like:

  • add a davos.require_python() call before the first smuggle statement
  • not add onion comments for certain (or any) packages
  • create a copy of the notebook rather than modifying the original
  • enable or set various davos.<foo> options before smuggling packages

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions