jonsequitur / dotnet-repl

A polyglot REPL built on .NET Interactive
MIT License
713 stars 35 forks source link

Feature proposal: cell output export #83

Open marckruzik opened 1 year ago

marckruzik commented 1 year ago

Hello, I am glad to see the work which has been done here!

I am using a lot of notebooks, and I would like to automate them, and get specific cells output. I think the easier way to do so would be to run a notebook using dotnet-repl, identify a cell, and get its raw output as a file. I have a crude pipeline, and I am looking for a way to improve it, either with existing nugets, or by suggesting a feature.

The problems

1: a way to give a name or id to a cell I am talking about a user defined name, not an automatic one like the cell number.

2: a way to get a raw output of the cell

Proposal for one output

The notebook

#!cellid myFinalOutput
Console.WriteLine("Hello World");

The command line dotnet repl --run /path/to/notebook.ipynb --output-path /path/to/output.txt --cellid myFinalOutput

The output (output.txt) Hello World

As the output is raw, it could also be some html.

Proposal for several outputs

Managing several outputs for several cells.

The notebook

#!cellid myIntermediaryOutput
2 + 2

#!cellid myFinalOutput
Console.WriteLine("Hello World");

The command line dotnet repl --run /path/to/notebook.ipynb --output-path /path/to/folder --cellid myIntermediaryOutput,myFinalOutput

jonsequitur commented 1 year ago

VS Code Insiders has added support for cell tags, which can be parsed from the .ipynb. Microsoft.DotNet.Interactive.Documents](https://www.nuget.org/packages/Microsoft.DotNet.Interactive.Documents/) might need to add support for it but it should be very minor change.

image image