Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable automated execution of notebooks #483

Open
jonsequitur opened this issue May 28, 2020 · 4 comments
Open

Enable automated execution of notebooks #483

jonsequitur opened this issue May 28, 2020 · 4 comments
Labels
Area-Automation Relating to non-interactive execution of notebooks and scripts enhancement New feature or request

Comments

@jonsequitur
Copy link
Contributor

jonsequitur commented May 28, 2020

Automation of notebooks (i.e., direct execution from the command line) is a common use case and is available to .NET Interactive Jupyter users through Papermill. Directly supporting automation has the potential to simplify authoring and deployment for .NET-only users.

Goals include:

  1. Make code as portable as possible between the interactive authoring and automation modes.

  2. Provide a way to accept input such that the same code works on both the command line and during interactive use, and is capable of displaying command line help, informative errors, etc.

    Example:

    #!csharp
    #!args
    
    ParseResult ParseCommandLine(string args)
    {
        var root = new RootCommand
        {
            new Option<int>("--number-of-things"),
            new Argument<FileInfo>()
        };
    
        return root.Parse(args);
    
    }
    
    #!csharp
    
    var something = DoSomethingWith(Args<int>("--number-of-things")); 

    In this example:

    • Command line automation would trigger argument parsing and store the parsed values for use by all subkernels.
    • Interactive use would trigger a user prompt for the complete command line input.
    • Identical strings, whether provided on the command line or via a user prompt, should result in identical parsed values when accessed in subsequent submissions.
  3. Output formats should be specifiable so that the automation run can control, for example, output formats (e.g. plaintext, HTML, Markdown, .ipynb)

@jonsequitur jonsequitur added enhancement New feature or request Area-Automation Relating to non-interactive execution of notebooks and scripts labels May 28, 2020
@jonsequitur jonsequitur changed the title Enable automated execution of .dib files Enable automated execution of notebooks Aug 11, 2020
@jonsequitur
Copy link
Contributor Author

Related: #890.

@Szeraax
Copy link

Szeraax commented Dec 8, 2021

this is very interesting! I was only coming at this from an powershell approach where I only ever want to get plaintext output saved, but if I have an automated run of my notebook that generates a graphic, I would like to be able to get that out and into the file system too.

Having said that, I see less use for taking output cells and converting them to mark down. Are people likely to use cells to generate markdown format data? Or other rich text? Same question for HTML, and even though VSCode probably does ultimately display all output cells as HTML and could emit that type out, it would mean that running compiled notebooks now need a LOT of rendering capabilities in place if you want that feature to have parity across vs/dotnet/compiled.

I would suggest scapping md and html output. Stick with plain text (and possibly graphics) output in a simple manner so that compiled notebooks can stay lean, but still provide all the same capabilities as a .dib run via dotnet or VSCode.

As for outputting output, seems like it could be nice to just take all output cells, concatenate them, and then spit it out to stout. Graphics being output would be a bit more complicated and I'm not sure what would likely be good there.

@Regenhardt
Copy link

Sending the whole output to stdout might be a good start as that already lets people handle it themselves, like saving it to a file (dotnet run generateGraph > graph.png) or use it as a test (dotnet run e2e-tests.dib in a CI/CD pipeline).

@jonsequitur
Copy link
Contributor Author

Relevant to this issue, dotnet-repl provides a number of notebook automation features.

https://github.com/jonsequitur/dotnet-repl

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Automation Relating to non-interactive execution of notebooks and scripts enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants