-
Notifications
You must be signed in to change notification settings - Fork 391
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
Extend Jupytext to C# and F# #427
Comments
The language in the notebook kernels is called |
Thanks, it is. Very interesting. |
So far, this is what we've got... On the PowerShell side:
@dfinke , @TylerLeonhardt, would you be interesting in giving a try to the above? Do you like the idea to store the notebooks as Markdown files? Or as On the C# / F# side:
|
I like storing it as markdown because I can use them as instructions on a repo and then the markdown can be re-purposed as an interactive notebook. Need to setup my env, I've only been running the notebooks in Azure Data Studio and the dotnet/interactive part with mybinder. This is good stuff. |
Thank you @dfinke ! Installing Jupytext on mybinder should be easy (just For the C# / F# side, who do you think I can ask advice to? Do you think @LadyNaggaga would be interested in helping here? What I need is 1) a better understanding at how to make the C# file, that represents the notebook, syntaxically correct and 2) information on whether a C# file can be executed interactively in VS Code, like the Python scripts with |
@jonsequitur is also a good contact on the .NET Interactive side for C# and F#. |
Hello! For Markdown support for C# and F#, you might take a look at what we've done in Try. NET. This experience is driven by Markdown-based code snippets: https://devblogs.microsoft.com/dotnet/creating-interactive-net-documentation/. The main difference between these approaches is that Try .NET currently runs full C#, meaning it needs namespaces, class definitions, etc. Try .NET hides that code from the user and provides context in the Markdown by annotating the code fences. It's more of a content authoring experience and not something we'd expect a notebook user to have to type, though. The scripting dialect used in As for interactive execution, the |
@mwouts perhaps some of the C# issues you're seeing here is because C# does not support top-level constructs and has various limitations with where you can place For F#, if the resulting file is emitted as |
Wow that's super interesting! Thank you @cartermp for the advice on C# / F# scripts. I think I'll default the F# script extension to Thank you @jonsequitur for pointing at the dotnet/try project. It is great to see that you are using this on https://docs.microsoft.com, with e.g. the C# tutorial! May I ask how the website itself (e.g. https://docs.microsoft.com/en-US/dotnet/csharp) is generated? Note that in the Jupyter community we tend to use Jupyter Book, , authored by @choldgraf , when we want to generate documentation sites from a collection of notebook - it may be interesting to compare both methods since I'm sure they face similar challenges. Regarding dotnet/try, and its three flavors (web/local/Jupyter), I'd be curious to see if Jupytext can help mapping the
I observe a few differences between
How is the space important to you? Which of |
All three of these are incidental in Try .NET because the command line parser isn't sensitive to whitespace, allows an arbitrary number of aliases (we support The metadata should be ignored if not needed, though I also think it will be unimportant or at least different metadata for the scripting versus standard C# dialects. |
I see! I think I can implement something that is insensitive to the space between As the next step, maybe I'll try to add Jupyter C#+Jupytext+MyBinder to dotnet/try-samples, and see how well (or not...) the dotnet/try |
I have copied the
Unfortunately that does not seem to work. There are two issues with
Does anyone know what is wrong? Or maybe I should ask: what is the minimal addition to a repo that allows to run the notebooks there on MyBinder with the .NET kernels? Thanks! |
@colombod Any ideas? |
Hello @colombod , thank you for your help!
It's because I want to see how well (or not) the try-sample examples will work in Jupyter. The example are not I did start with dotnet/interactive repo a few days ago. There, I
That went well, i.e. I could still open/run these With the dotnet/try-sample it is a bit more difficult, for me at least, because there was no DockerFile there initially (and also, because I am an absolute beginner with Docker...)
I don't think so, but maybe I'll try to use docker locally and see how it works... |
A couple of Try .NET issues that might relate to Jupytext, as food for thought: |
Locally I can run the dotnet/try-sample examples, they work fine. But opening them with Jupytext does not really work, as... there's no code in the Markdown file!! So obviously the notebook is empty 😄 It is interesting to see how dotnet/try structures the document. The cell in Markdown file points at a subset
and then an extract of using System;
using System.Collections.Generic;
using System.Linq;
namespace Try101LinqSamples
{
public class AggregateOperators
{
(...)
public int SumSyntax()
{
#region sum-syntax
int[] numbers = { 5, 4, 1, 3, 9, 8, 6, 7, 2, 0 };
double numSum = numbers.Sum();
Console.WriteLine($"The sum of the numbers is {numSum}");
#endregion
return 0;
} |
Interesting! How will dotnet/try react if we duplicate the source in both the Markdown cell, and in the source file? (a bit like the Is it correct that dotnet try only reads the source file and ignore what is in the Markdown file? Maybe we could think of a) syncing in Jupytext the cell content from/to the source file and b) duplicating this information in the |
Typically, it "replaces" the cell in the file with the cell in the editor, though it doesn't actually write the change to disk. The compilation happens in memory.
We support both directions. |
Thank you @jonsequitur . The dotnet/try Markdown files is another challenge, so I will see what we could do for that at #438 . And for now I will ship the C# and F# support in Jupytext 1.3.4 (PR #429 ). |
C#, F# and Powershell Jupyter notebooks were announced in this post from the .NET blog. A preview of Powershell notebooks was then provided by @TylerLeonhardt in this post.
In november 2019 (Jupytext 1.3) we extended Jupytext to Powershell. Now I'd be curious to extend Jupytext to C# and F#, and then experiment with
a) turning documentation repositories like e.g. PowerShell-Docs or C#-Docs into live interactive Jupyter notebooks with MyBinder
b) editing/running the
.ipynb
notebook through a paired script in Visual Studio Code.The repository dotnet/interactive seems to be a great ressource to start with. There, one can find
This thread may also be of interest to @dfinke who authored PowerShellNotebook, a collection of scripts that can convert notebooks to scripts, and text to notebooks.
The text was updated successfully, but these errors were encountered: