davos icon indicating copy to clipboard operation
davos copied to clipboard

CLI tool to "davos-enhance" a Jupyter notebook

Open paxtonfitzpatrick opened this issue 2 years ago • 1 comments

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

paxtonfitzpatrick avatar Sep 30 '23 11:09 paxtonfitzpatrick

Seems like a great idea! (But for a future release)

On Sat, Sep 30, 2023 at 7:10 AM Paxton Fitzpatrick @.***> wrote:

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. options before smuggling packages

— Reply to this email directly, view it on GitHub https://github.com/ContextLab/davos/issues/105, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACE4WXSVLZAM2CRL6UCJ5MTX47423ANCNFSM6AAAAAA5NPPESI . You are receiving this because you are subscribed to this thread.Message ID: @.***>

jeremymanning avatar Sep 30 '23 11:09 jeremymanning