I have a jupyter notebook question :slightly_smili...
# general
a
I have a jupyter notebook question šŸ™‚ Searching through the slack a lot of people have used or written plugins to be able to run them with the right venv/files.. but I don't find a lot of people trying to make them first class citizens. In my company we have a lot of notebooks that are used in scripts or tests, and running them through pants hits a lot of problems from the lack of automatic dependency inference (you don't know which packages or code the notebook relies on, so the sandbox is lacking). I'm considering writing a plugin that would expose a
jupyter_notebook
target that would allow them to be treated similarly as
python_source
for purposes of dependency inference or even linters/checkers/formatters. There already exists a tool (nbconvert) that can output a python equivalent file to a notebook, so it sounds like a viable option to run that in the pants backend and redirect everything to the resulting python file.. but it's hard for me to estimate how viable this is as a plugin and what issues I might hit. Any one tried something like this or any advice from pants maintainers on feasibility of such an approach (redirecting linters/dependency inference to an ephemerally generated file as part of the run)?
s
We're using marimo, it solves all problems you mentioned: • marimo notebooks are python files, so no need to convert them • sandboxing works automatically with uv locking But if you really want to use Jupiter, it shouldn't be a problem to generate python source from a Jupiter notebook via pants. You could use any python codegen target as an example
a
These are helpful points, I will have to look into codegen targets, it does sounds like it could be a good solution!
s
šŸ‘ 1