Git Product home page Git Product logo

dotnet / interactive Goto Github PK

View Code? Open in Web Editor NEW
2.7K 65.0 365.0 109.25 MB

.NET Interactive combines the power of .NET with many other languages to create notebooks, REPLs, and embedded coding experiences. Share code, explore data, write, and learn across your apps in ways you couldn't before.

License: MIT License

Dockerfile 0.02% F# 4.64% C# 71.74% PowerShell 3.90% Batchfile 0.06% Shell 2.43% CMake 0.28% JavaScript 0.31% TypeScript 14.51% Smalltalk 0.88% CSS 0.04% HTML 0.01% Python 0.39% R 0.35% Jupyter Notebook 0.45%
csharp fsharp powershell jupyter interactive-programming data-science dotnet-interactive notebooks polyglot polyglot-dev

interactive's Introduction

.NET Interactive

What is .NET Interactive?

.NET Interactive is an engine and API for running and editing code interactively, including:

  • Running code and getting its results.
  • Evaluating code to provide language services such as completions and diagnostics.
  • Sharing data and variables between multiple languages and across remote machines.

While typically associated with notebook technologies such as Jupyter and the Polyglot Notebooks extension for Visual Studio Code, .NET Interactive has other uses as well, such as building REPLs and embedded script engines.

The following languages are supported by Polyglot Notebooks and .NET Interactive:

Language Variable sharing
C#
F#
PowerShell
JavaScript
SQL
KQL (Kusto Query Language)
Python
R
HTML
Mermaid

Polyglot Notebooks

Since .NET Interactive is capable of running as a kernel for notebooks, it enables a polyglot (multi-language) notebook experience. When using the .NET Interactive kernel, you can use different languages from one cell to the next, share variables between languages, and dynamically connect new languages and remote kernels within a notebook. There's no need to install different Jupyter kernels, use wrapper libraries, or install different tools to get the best experience for the language of your choice. You can always use the best language for the job and seamlessly transition between different stages of your workflow, all within one notebook.

For the best experience when working with multi-language notebooks, we recommend installing the Polyglot Notebooks extension for Visual Studio Code. While the full .NET Interactive feature set is available in Jupyter, many features are only usable via code, whereas the Polyglot Notebooks extension provides additional features including a language/kernel picker for each cell, enhanced language services, a multi-kernel variable viewer, and more.

Jupyter

The most popular notebook platform is Jupyter, and .NET Interactive is a fully supported Jupyter kernel that you can use with Jupyter Notebook, JupyterLab, nteract, and other Jupyter frontends. You can read more about using .NET Interactive as a Jupyter kernel here.

REPLs

.NET Interactive can be used as the execution engine for REPLs as well. The experimental .NET REPL is one example of a command line REPL built on .NET Interactive. In addition, .NET REPL can be used for automated command line execution of notebooks.

Small factor devices

We support running on devices like Raspberry Pi and pi-top [4]. You can find instructions here.

FAQ

For more information, please refer to our FAQ.

Acknowledgements

The multi-language experience of .NET Interactive is truly a collaborative effort among different teams at Microsoft and in the community. We'd like to thank the following teams for contributing their time and expertise to helping bring support for other languages:

  • PowerShell Team: PowerShell support
  • Azure Data Team: SQL and KQL support
  • Azure Notebooks Team: Python, R, and Jupyter subkernel support

Telemetry

Telemetry is collected when the dotnet-interactive tool is started. (If you are using the .NET Interactive libraries directly, they do not emit telemetry.) Once dotnet-interactive is running, it emits the names of packages imported into the notebook and the languages used to run individual cells. This data is hashed, allowing us to count unique values, but the pre-hashed values cannot be obtained from the telemetry. We do not collect any additional code or clear text from cells. All telemetry is anonymous. In addition, dotnet-interactive reports the usage for a specific subset of the verbs in the .NET Interactive CLI. Those verbs are:

  • dotnet interactive jupyter
  • dotnet interactive jupyter install
  • dotnet interactive stdio

How to opt out

The .NET Interactive telemetry feature is enabled by default. To opt out of the telemetry feature, set the DOTNET_INTERACTIVE_CLI_TELEMETRY_OPTOUT environment variable to 1 or true.

Disclosure

The .NET Interactive tool displays text similar to the following when you first run one of the .NET Interactive CLI commands (for example, dotnet interactive jupyter install). Text may vary slightly depending on the version of the tool you're running. This "first run" experience is how Microsoft notifies you about data collection.

Telemetry
---------
The .NET Core tools collect usage data in order to help us improve your experience.The data is anonymous and doesn't include command-line arguments. The data is collected by Microsoft and shared with the community. You can opt-out of telemetry by setting the DOTNET_INTERACTIVE_CLI_TELEMETRY_OPTOUT environment variable to '1' or 'true' using your favorite shell.

To disable this message and the .NET Core welcome message, set the DOTNET_INTERACTIVE_SKIP_FIRST_TIME_EXPERIENCE environment variable to true. Note that this variable has no effect on telemetry opt out.

Contribution Guidelines

You can contribute to .NET Interactive with issues and pull requests. Simply filing issues for problems you encounter is a great way to contribute. Contributing code improvements is greatly appreciated. You can read more about our contribution guidelines here.

interactive's People

Contributors

abhitejjohn avatar akshita31 avatar bleaphar avatar brettfo avatar cartercanedy avatar cartermp avatar charles-gagnon avatar claudiaregio avatar colombod avatar corivera avatar daxian-dbw avatar dependabot[bot] avatar dotnet-bot avatar dotnet-maestro[bot] avatar dsyme avatar eerhardt avatar idg10 avatar jonsequitur avatar justinmdotnet avatar justinytchen avatar kevinransom avatar ladynaggaga avatar msynk avatar ocalles avatar ocallesp avatar shibbas avatar shyamnamboodiripad avatar tihan avatar tylerleonhardt avatar whiteblackgoose avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

interactive's Issues

Support wildcards in NuGet Versions

Describe the bug

Please provide as much information as you can.

Try the following in a notebook:

#r "nuget:Microsoft.ML,1.*"

Expected result

I expect to get the latest stable ML.NET package.

Actual result

Attempting to install package Microsoft.ML, version 1....done!
Failed to add reference to package Microsoft.ML

index | value
-- | --
0 | error: '1.' is not a valid version string.

Note

If I do the following in a .csproj, it works correctly:

    <PackageReference Include="Microsoft.ML" Version="1.*" />

I expect it to work the same in a notebook.

Did this error occur while using dotnet try or online?

  • dotnet-try
  • online

What kind of error was it?

  • User Interface (UI): For example the output never displayed
  • Service Error: For example "The service is temporarily unavailable. We are working on it"
  • Other:

Screenshots

If applicable, add screenshots to help explain your problem.

Please complete the following:

  • OS
    • Windows 10
    • macOS
    • Linux (Please specify distro)
    • iOS
    • Android
  • Browser
    • Chrome
    • Edge
    • Safari

/cc @rchande

Adding extensions to the .NET kernel using nuget packages for F#

What is an extension ?
An extension is anything that can be used to modify the behavior of the kernel without necessarily being checked into the kernel code. For example, if we would like the kernel to print "Hello World" after every successful code submission, it can be performed via adding an extension to the kernel.

Possible applications of an extension

  1. Adding custom formatters for various types. For example, we can register a formatter for a dictionary which will display the keys and values in the dictionary in a table format with the keys in red color.
  2. Support for various visualisation libraries. The Xplot Support that is present right now is done via the kernel extension. The kernel extension when loaded registers a formatter for the XplotChart type.
  3. Support for magic commands like %%javascript. Such an extension would possible add a middleware that will read the code submitted and check if the magic command is present and do the evaluation accordingly.

Existing implementation
Right now an extension can be added to the kernel using the #extend path_to_dll directive. The problem with this approach is the acquisition story. Once extension author create extensions, how do they make their extension easily available to the notebook users.

Proposed Implementation
The extension can be a part of a nuget package. When a user does
#r "nuget:MyNugetPackage" we look for a specific path inside the Nuget Package, say /Extensions and try to find all the implementations of IKernelExtension and load them into the kernel.

This approach can also be used to load scripts into the notebook context. Similar to the "Extensions", there can also be a /Scripts folder inside the nuget package containing the script files. We look for all those script files and pass #load MyScript.csx into the underlying script engine.

Additional questions to be answered
The .NET kernel has a CompositeKernel which has subkernels under it.
Let's take the case that the CompositeKernel has two subkernels - C# kernel and F# kernel. How does an extension specify if it is meant for C# kernel, F# kernel or if it is language agnostic and needs to be added to the composite kernel itself?

Also is there a way for the extension to get some piece of information from the kernel, like getting the compilation for the current cell and use that to emit a dll ?

#r nuget doesn't understand wildcard package versions in C# kernel

Input:
#r "nuget:System.CommandLine.Experimental,0.3.0-*"

Output:
Installing package System.CommandLine.Experimental, version 0.3.0-.done!
Failed to add reference to package System.CommandLine.Experimental

index value
0 error: '0.3.0-' is not a valid version string.

Unable to use System.Data.SqlClient in Jupyter C# Kernel

Describe the bug

I'm attempting to use the System.Data.SqlClient NuGet package in a C# Jupyter Notebook.
The package will be used together with the DatabaseLoader in ML.NET.

I'm successful in installing the NuGet package, but when I call SqlClientFactory.Instance, I'm getting a likely re-direct error. I want to mention that this work okay in Visual Studio 2019, so it seems to be related to Jupyter and the C# Kernel.

Did this error occur while using dotnet try or online?

  • dotnet-try
  • online

What kind of error was it?

  • User Interface (UI): For example the output never displayed
  • Service Error: For example "The service is temporarily unavailable. We are working on it"
  • Other:

Screenshots

image

Please complete the following:

  • OS
    • Windows 10
    • macOS
    • Linux (Please specify distro)
    • iOS
    • Android
  • Browser
    • Chrome
    • Edge
    • Safari

#r loads the oldest NuGet from the feed

Describe the bug

Jupyter Lab / C# kernel, preview build of dotnet-try 1.0.19558.8 loads the newest (below v5.0.0) NuGet from the feed when the version is not defined in the #r command:
image

After upgrading to preview dotnet-try build 1.0.19558.9 the same #r command loads the oldest (below v1.0.0) NuGet package from the feed:
image

Did this error occur while using dotnet try or online?

  • dotnet-try
  • online

What kind of error was it?

  • User Interface (UI): For example the output never displayed
  • Service Error: For example "The service is temporarily unavailable. We are working on it"
  • Other: The default NuGet package should be the newest one when version is not given in the #r command.

Screenshots

If applicable, add screenshots to help explain your problem.

Please complete the following:

  • OS
    • Windows 10
    • macOS
    • Linux (Please specify distro)
    • iOS
    • Android
  • Browser
    • Chrome
    • Edge
    • Safari

Defining a function in one cell and calling it in another results in compilation error

Describe the bug

See the screen shot below.

I created a notebook, imported an assembly, defined a function that took a parameter of a type from that assembly in a cell. When I tried invoking the function in another cell I got a compilation error:

(2,6): error CS1503: Argument 1: cannot convert from 'Microsoft.ML.IDataView [/Users/eerhardt/.nuget/packages/microsoft.ml.dataview/1.2.0/lib/netstandard2.0/Microsoft.ML.DataView.dll]' to 'Microsoft.ML.IDataView [Microsoft.ML.DataView, Version=1.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51]'

Did this error occur while using dotnet try or online?

  • dotnet-try
  • online

What kind of error was it?

  • User Interface (UI): For example the output never displayed
  • Service Error: For example "The service is temporarily unavailable. We are working on it"
  • Other:

Screenshots

If applicable, add screenshots to help explain your problem.
Screen Shot 2019-07-25 at 2 10 52 PM

Please complete the following:

  • OS
    • Windows 10
    • macOS
    • Linux (Please specify distro)
    • iOS
    • Android
  • Browser
    • Chrome
    • Edge
    • Safari

How do I set the platform to x64 for the C# kernel in Jupyter notebook?

Describe the bug

I am using dotnet try as C# kernel in a Jupyter notebook. I'm trying to install the CNTK.CPUOnly NuGet package, but it only supports the x64 platform. I get an error that the package is incompatible with the 'all' platform.

Is it possible to change the platform to x64?

Did this error occur while using dotnet try or online?

  • dotnet-try
  • online (C# kernel in Jupyter notebook)

What kind of error was it?

  • User Interface (UI): For example the output never displayed
  • Service Error: For example "The service is temporarily unavailable. We are working on it"
  • Other: required feature missing

Environment

My code is running locally in a Jupyter Notebook on Anaconda3. I've installed the dotnet try support in Jupyer to get the C# kernel.

Screenshots

Here's the first cell in my notebook. The autogenerated csproj file uses the 'all' platform, but this package requires x64. Is there any way to override the default?

image

Please complete the following:

  • OS
    • Windows 10
    • macOS
    • Linux (Please specify distro)
    • iOS
    • Android
  • Browser
    • Chrome
    • Edge (beta version based on Chrome)
    • Safari

Add a limit of output in jupyter c# kernel

Is your feature request related to a problem? Please describe.
Sometimes I will print out a lot of data by mistake, and since the notebook does not have any limits the output of a single cell can become 100s of MB big rendering the notebook unusable. This can easily happen if you have a BsonDocument object retrieved from MongoDB, since it seems like there's some bug when printing those creating huge outputs.

Describe the solution you'd like
I would like to have a limit on how much can be printed. Preferably configurable, and different limits for basic prints and prints of tables (limit of number of rows and number of columns and length of each column). These limits exists when using notebook with python kernels.

Describe alternatives you've considered
Fixing display of BsonDocuments would fix this for my specific case, but a general limit of output would be much better since it protects against all cases.

Read More
I could not find a mention of this feature anywhere.

JSON escaping of kernel events is inconsistent with kernel commands

When using the stream kernel, serialized commands don't escape the nested JSON object:

{"Id":3,"CommandType":"SubmitCode","Command":{"Code": "var x = 1 + 12", "TargetKernelName":null}}

but events do:

{"Id":3,"EventType":"CodeSubmissionReceived","Event":"{\"Code\":\"var x = 1 + 12\",\"Value\":\"var x = 1 + 12\",\"Command\":{\"Code\":\"var x = 1 + 12\",\"TargetKernelName\":null,\"SubmissionType\":0}}"}

Serialized events should not have escaping of the nested objects.

stdio stream does not publish KernelIdle and KernelBusy events

Kernel-level events (e.g. KernelBusy and KernelIdle) are not being published into the event stream. Only command-level events are being published.

This should be a simple fix that simplifes KernelStreamClient so that it does one subscription to IKernel.KernelEvents rather than to each specific command's KernelEvents stream.

Formatter does not work on generic type

Describe the bug

I tried to format a record with generic type 'T. See below the type definition and register function.

type TestType<'T> =
  {
    Name: string
    Value: 'T
  }

let v1:TestType<float> = { Name = "Test"; Value = 1.0 }
let v2:TestType<string> = { Name = "Test"; Value = "String" }

let registerTestType (s:TestType<_>) (writer:TextWriter) =
    let headers = new ResizeArray<IHtmlContent> ()
    headers.Add(th.innerHTML(i.innerHTML("TestType")))
    let rows = ResizeArray<ResizeArray<IHtmlContent>>()
    let cells = ResizeArray<IHtmlContent>()
    cells.Add(td.innerHTML(s.Name + ": " + (s.Value.ToString())))
    rows.Add(cells)
    let t =
        table.innerHTML(
            [|
              thead.innerHTML(headers)
              tbody.innerHTML(rows.Select(fun r -> tr.innerHTML(r)))
            |])    
    writer.Write(t)

See the screenshot below for the Jupyter output.
The following code does not register the format of the generic type

Formatter<TestType<_>>.Register( (fun x writer -> registerTestType x writer), mimeType = "text/html")

I had to register types explicitly to get it working

Formatter<TestType<float>>.Register( (fun x writer -> registerTestType x writer), mimeType = "text/html")
Formatter<TestType<string>>.Register( (fun x writer -> registerTestType x writer), mimeType = "text/html")

Did this error occur while using dotnet try or online?

  • dotnet-try
  • online

What kind of error was it?

  • User Interface (UI): For example the output never displayed
  • Service Error: For example "The service is temporarily unavailable. We are working on it"
  • Other:

Screenshots

image

Please complete the following:

  • OS
    • Windows 10
    • macOS
    • Linux (Please specify distro)
    • iOS
    • Android
  • Browser
    • Chrome
    • Edge
    • Safari

#r nuget is really slow

Describe the bug

Every time I execute #r "nuget:XXX" in a cell, it takes a long time, even though I already have the nuget package cached.

We should do some cache checking or otherwise to improve the speed, as right now it hurts the experience.

Did this error occur while using dotnet try or online?

  • dotnet-try
  • online

What kind of error was it?

  • User Interface (UI): For example the output never displayed
  • Service Error: For example "The service is temporarily unavailable. We are working on it"
  • Other: Perf

Screenshots

If applicable, add screenshots to help explain your problem.

Please complete the following:

  • OS
    • Windows 10
    • macOS
    • Linux (Please specify distro)
    • iOS
    • Android
  • Browser
    • Chrome
    • Edge
    • Safari

SqlClientFactory.Instance is null when using Microsoft.Data.SqlClient in Jupyter C# Kernel

Describe the bug

I attempted to load data from a SQL Server DB using the DatabaseLoader from a Jupyter Notebook.
I was first using System.Data.SqlClient as the ProviderFactory, but I got multiple re-direct issues in Jupyter. I moved to Microsoft.Data.SqlClient, which is supposed to work better with .NET Core and continued passed that issue. However, I instead run in to an issue where it says the provider factory is null.

Did this error occur while using dotnet try or online?

  • dotnet-try
  • online

What kind of error was it?

  • User Interface (UI): For example the output never displayed
  • Service Error: For example "The service is temporarily unavailable. We are working on it"
  • Other:

Screenshots

image

Please complete the following:

  • OS
    • Windows 10
    • macOS
    • Linux (Please specify distro)
    • iOS
    • Android
  • Browser
    • Chrome
    • Edge
    • Safari

Improve package load error formatting

Most notebook errors look like this:
image

Package load errors look like this:
image

The wrong event type is likely being emitted, and the table formatting is not helpful.

notebook kernel stop the process when it calls "console.writeline" method.

Describe the bug

notebook kernel stops the process when it calls "console.writeline" method. This issue happens when I use ML.NET with Jupyter Notebook.

Did this error occur while using dotnet try or online?

  • dotnet-try
  • online

What kind of error was it?

  • User Interface (UI): For example the output never displayed
  • Service Error: For example "The service is temporarily unavailable. We are working on it"
  • Other: (backend) code execution in notebook kernel is stop

Screenshots

if I run this cell, the code below the red line will not be executed, the process is just stop, but, If I remove the "Console.WriteLine" it will run smooth till the end of code
image

Please complete the following:

  • OS
    • Windows 10
    • macOS
    • Linux (Please specify distro)
    • iOS
    • Android
  • Browser
    • Chrome
    • Edge
    • Safari

Custom formatter for F# discriminated unions

Currently, DUs format by reflecting over the whole object:

image

The relevant information for prism is width, height, and faces. The TagandIs*` members aren't relevant info.

F# Interactive formats it like this:

image

Neither is ideal. I propose that we keep the table formatting we have today, but without Tag and the Is* members. We might be able to indicate that this is a Shape of case Prism somehow, too.

We need to have display/preview function to show unstructured data like images, videos, sound

Is your feature request related to a problem? Please describe.
I want to preview my unstructured dataset like images, sounds, videos in jupyter notebook with .NET, how to achieve that ? I saw sample code in notebookexamples folder that use some code like this:
Formatter<DataFrame>.Register((df, writer) => { /* implementation */ }
Can I use the same way to render image (Bitmap, or Bytes of Audio File) ?

Describe the solution you'd like
Built-in function to preview my unstructured dataset like:

Bitmap bmp= (Bitmap) Bitmap.FromFile("C:\\test.bmp");
Display(bmp);

I think it should support collection of object too.

Describe alternatives you've considered
Maybe some interface to implement custom renderer/formatter for custom class ?

NuGet packages with native assets in a notebook

Describe the bug

When using the Microsoft.ML NuGet package in a notebook, you get an exception when ML.NET calls into a native assembly.

Repro

Run the following notebook:

#r "nuget:Microsoft.ML"
    
using Microsoft.ML;
using Microsoft.ML.Data;

class IrisData
{
    public IrisData(float sepalLength, float sepalWidth, float petalLength, float petalWidth)
    {
        SepalLength = sepalLength;
        SepalWidth = sepalWidth;
        PetalLength = petalLength;
        PetalWidth = petalWidth;
    }
    public float SepalLength;
    public float SepalWidth;
    public float PetalLength;
    public float PetalWidth;
}

var data = new []
{
    new IrisData(1.4f, 1.3f, 2.5f, 4.5f), 
    new IrisData(2.4f, 0.3f, 9.5f, 3.4f), 
    new IrisData(3.4f, 4.3f, 1.6f, 7.5f), 
    new IrisData(3.9f, 5.3f, 1.5f, 6.5f), 
};

MLContext mlContext = new MLContext();
var pipeline = mlContext.Transforms
    .Concatenate("Features", "SepalLength", "SepalWidth", "PetalLength", "PetalWidth")
    .Append(mlContext.Clustering.Trainers.KMeans("Features", numberOfClusters: 2));

try
{
    pipeline.Fit(mlContext.Data.LoadFromEnumerable(data));
}
catch (Exception e)
{
    Console.WriteLine(e);
}

This shouldn't throw an exception, but it does:

System.DllNotFoundException: Unable to load shared library 'CpuMathNative' or one of its dependencies. In order to help diagnose loading problems, consider setting the DYLD_PRINT_LIBRARIES environment variable: dlopen(libCpuMathNative, 1): image not found
   at Microsoft.ML.Internal.CpuMath.Thunk.SumSqU(Single* ps, Int32 c)
   at Microsoft.ML.Internal.CpuMath.CpuMathUtils.SumSq(ReadOnlySpan`1 src)
   at Microsoft.ML.Numeric.VectorUtils.NormSquared(VBuffer`1& a)
   at Microsoft.ML.Trainers.KMeansBarBarInitialization.Initialize(IHost host, Int32 numThreads, IChannel ch, Factory cursorFactory, Int32 k, Int32 dimensionality, VBuffer`1[] centroids, Int64 accelMemBudgetMb, Int64& missingFeatureCount, Int64& totalTrainingInstances)
   at Microsoft.ML.Trainers.KMeansTrainer.TrainCore(IChannel ch, RoleMappedData data, Int32 dimensionality)
   at Microsoft.ML.Trainers.KMeansTrainer.TrainModelCore(TrainContext context)
   at Microsoft.ML.Trainers.TrainerEstimatorBase`2.TrainTransformer(IDataView trainSet, IDataView validationSet, IPredictor initPredictor)
   at Microsoft.ML.Trainers.TrainerEstimatorBase`2.Fit(IDataView input)
   at Microsoft.ML.Data.EstimatorChain`1.Fit(IDataView input)
   at Submission#6.<<Initialize>>d__0.MoveNext()

Did this error occur while using dotnet try or online?

  • dotnet-try
  • online

What kind of error was it?

  • User Interface (UI): For example the output never displayed
  • Service Error: For example "The service is temporarily unavailable. We are working on it"
  • Other:

Screenshots

Screen Shot 2019-07-27 at 12 31 07 PM

Please complete the following:

  • OS
    • Windows 10
    • macOS
    • Linux (Please specify distro)
    • iOS
    • Android
  • Browser
    • Chrome
    • Edge
    • Safari

Consider adapting Fable.React for F# formatting of HTML

The SAFE bookstore uses this DSL to great effect:

https://github.com/SAFE-Stack/SAFE-BookStore/blob/2bf0e7c1e76286bed3e3c574dfaac928e0e18149/src/Client/pages/Login.fs#L91-L134

It's quite powerful, since you can give it arbitrary F# functions to act as event handlers, though I don't know how much that would be used. The real nice thing is that the DSL ends up looking very much like an F# version of HTML.

The biggest problem is it's built atop React and React abstractions: https://github.com/fable-compiler/fable-react/blob/master/src/Fable.React.fs

I don't have a good understanding of how you incorporate more advanced JS libraries/frameworks for UIs into a notebook though.

Parametrized display

Custom formatting could require to provide additional options to the formatter.
in this comment the user wanted to pass parameter to the formatter

The proposal is about having api like Formatter.Register<T,TA> to regiser a formatter to that display() could be invoked with additional parameters matching type TA.

Change default dictionary formatter to be IDictionary<TKey, TValue>

The following code is required to get the nice formatting in F#:

System.Collections.Generic.Dictionary<string, int>([("zero", 0); ("one", 1); ("two", 2)])

image

If the formatter works with IDictionary<TKey, TValue>, then the code can merely be this:

dict [("zero", 0); ("one", 1); ("two", 2)]

Currently it falls back to the IEnumerablt<T> formatter.
image

This should allow the same formatting to apply to any code that has a result which implements that interface, such as those using immutable collections.

Change magic command parsing and syntax to not use `%` prefix

The % and %% prefixes for magic commands, adopted from the IPython convention, presents a few problems in C# needs to be changed.

These problems are:

  1. For some submissions, it's ambiguous as to whether a portion of the code is a magic command or C#. In this example, the mod operator (%) and C#'s allowance of line breaks within statements means that this is valid C#, while also being a positive match for the current magic command parsing:
var whos = 10;
var x = 100
%whos
;
  1. Because the magic command parsing is implemented before the compiler is invoked, it requires splitting up the submission into multiple code fragments and sending them independently to the scripting engine, which can result in changes to the semantics of the submission. In this example, the code compiles if the magic command is omitted, and fails to compile if the magic command is included:
int a() => b();
%whos
int b() => a();

These problems are both resolved if the magic command is understood by the compiler, while also being insignificant, e.g. a comment or directive. This approach is in line with the IPython guidance:

To Jupyter users: Magics are specific to and provided by the IPython kernel. Whether Magics are available on a kernel is a decision that is made by the kernel developer on a per-kernel basis. To work properly, Magics must use a syntax element which is not valid in the underlying language. For example, the IPython kernel uses the % syntax element for Magics as % is not a valid unary operator in Python. However, % might have meaning in other languages.

The current proposal is to use #! for both line and cell magics. This requires changes to both C# scripting and F# to relax their current limitation by which #! is allowed only on the first line of a script.

Add a command line switch to set default kernel language

Currently, the default language for the kernel is C#, but F# is also supported by using the %%fsharp cell magic.

We should add a command line switch, --default-kernel, to set the default so that code submissions whose language is not specified will use this default.

The dotnet try jupyter install command should be updated to install both C#- and F#-defaulted kernel specs.

Unable to use extension methods in .NET Jupyter Kernel

Describe the bug

Testing out ML.NET with the .NET Jupyter Kernel and when trying to use the context.Data.LoadFromTextFile it gives the below error:

Unhandled Exception: (1,12): error CS1929: 'DataOperationsCatalog' does not contain a definition for 'LoadFromTextFile' and the best extension method overload 'TextLoaderSaverCatalog.LoadFromTextFile<HousingData>(DataOperationsCatalog, string, char, bool, bool, bool, bool)' requires a receiver of type 'DataOperationsCatalog'

I tried to add the context.Data as the first parameter to see if that works, but that results in a different error, which I'm thinking is because the LoadFromTextFile is an extension method.

Unhandled Exception: (1,25): error CS1501: No overload for method 'LoadFromTextFile' takes 7 arguments

Is there any way to use methods like these in the .NET Kernel?

Full notebook can be found here, if needed.

Did this error occur while using dotnet try or online?

  • dotnet-try
  • online

What kind of error was it?

  • User Interface (UI): For example the output never displayed
  • Service Error: For example "The service is temporarily unavailable. We are working on it"
  • Other:

Screenshots

If applicable, add screenshots to help explain your problem.

Please complete the following:

  • OS
    • Windows 10
    • macOS
    • Linux (Please specify distro)
    • iOS
    • Android
  • Browser
    • Chrome
    • Edge
    • Safari

#r is unable to load an assembly that's already on disk

Describe the bug

Please provide as much information as you can.

Did this error occur while using dotnet try or online?

  • dotnet-try
  • online

What kind of error was it?

  • User Interface (UI): For example the output never displayed
  • Service Error: For example "The service is temporarily unavailable. We are working on it"
  • Other:

I'm using dotnet-try via Jupyter Lab and the assembly loading from the disk fails, below is the load command:

#r "C:\Users\tomip\.nuget\packages\newtonsoft.json\12.0.2\lib\netstandard2.0\Newtonsoft.Json.dll"

and the response:

Invalid: Command: #r C:\Users\tomip\.nuget\packages\newtonsoft.json\12.0.2\lib\netstandard2.0\Newtonsoft.Json.dll

The version of the dotnet-try is preview build 1.0.19530.1.

If I execute the same command in Visual Studio's C# Interactive (64-bit) window it works properly.

Screenshots

If applicable, add screenshots to help explain your problem.

Please complete the following:

  • OS
    • Windows 10
    • macOS
    • Linux (Please specify distro)
    • iOS
    • Android
  • Browser
    • Chrome
    • Edge
    • Safari

FSharp Notebook sample is broken

Describe the bug

Please provide as much information as you can.

Did this error occur while using dotnet try or online?

  • dotnet-try
  • online

What kind of error was it?

  • User Interface (UI): For example the output never displayed
  • Service Error: For example "The service is temporarily unavailable. We are working on it"
  • Other: Sample code is not working

Screenshots

If applicable, add screenshots to help explain your problem.

When running this file, I got some errors.
https://github.com/dotnet/try/blob/001b36724d769e844a53b22e3833a23caed3dc68/NotebookExamples/fsharp/Samples/Repo%20Statistics.ipynb

NET Core 向け Microsoft (R) Build Engine バージョン 16.3.0+0f4c62fea
Copyright (C) Microsoft Corporation.All rights reserved.

/var/folders/d1/gw65qzfn4q1gt2h22xz7hb440000gn/T/nuget/79462/Project.fsproj : error NU1101: パッケージ 2.4.6 が見つかりません。ソース local, nuget.org には、この ID のパッケージが存在しません。
/var/folders/d1/gw65qzfn4q1gt2h22xz7hb440000gn/T/nuget/79462/Project.fsproj : error NU1101: パッケージ 0.32.0 が見つかりません。ソース local, nuget.org には、この ID のパッケージが存在しません。
  /var/folders/d1/gw65qzfn4q1gt2h22xz7hb440000gn/T/nuget/79462/Project.fsproj の復元が 1.27 sec で失敗しました。

/var/folders/d1/gw65qzfn4q1gt2h22xz7hb440000gn/T/nuget/79462/Project.fsproj shows that

  <ItemGroup><PackageReference Include = 'Octokit' Version = '0.32.0'><GeneratePathProperty>true</GeneratePathProperty></PackageReference></ItemGroup>
  <ItemGroup><PackageReference Include = 'NodaTime' Version = '2.4.6'><GeneratePathProperty>true</GeneratePathProperty></PackageReference></ItemGroup>
  <ItemGroup><PackageReference Include = '0.32.0' Version = '*'><GeneratePathProperty>true</GeneratePathProperty></PackageReference></ItemGroup>
  <ItemGroup><PackageReference Include = '2.4.6' Version = '*'><GeneratePathProperty>true</GeneratePathProperty></PackageReference></ItemGroup>

It seems to be wrong that way to specify package version.
Actually in this PR (https://github.com/dotnet/fsharp/pull/7796/files#diff-e68c01be7bd8c62e32c0355823a810daR91) shows

#r "nuget:System.Collections.Immutable.DoesNotExist, version=1.5.0"

I'm already ready to submit Pull Requests that fix this issue
dotnet/try@master...yamachu:fix-fsharp-sample

But README shows...
https://github.com/dotnet/try#contribution-guidelines

It would be better that I wait for a fix it?
Thanks.

Please complete the following:

  • OS
    • Windows 10
    • macOS
    • Linux (Please specify distro)
    • iOS
    • Android
  • Browser
    • Chrome
    • Edge
    • Safari

Creating kernel extensions that are not part of other nuget packages

This is related to dotnet/try#395

Adding extensions to nuget packages like XPlot in the interactive-extensions/dotnet/cs has been implemented and the use case for that is when you want to extend the kernel with respect to a particlay nuget package. This scenario makes perfect sense.

However, there is another set of scenarios where a user might just want to extend the kernel and not be specific to any library, for example, adding a magic command for %%time. (I think this is similar to the tools in F# cc @KevinRansom ).If I write such an extension, how do I distribute it? The most obvious answer is via a nuget package. But what would be the structure of that nuget package?

MyKernelExtension
    2.0.0
          lib/netstandard2.0/MyKernelExtension.dll

OR

MyKernelExtension
   2.0.0
          interactive-extensions/dotnet/cs/MyKernelExtension.dll

For the first case, we will have to add a functionality to #r nuget to look for IKernelExtension types in each metadata reference that it is adding and load them. While this approach looks appealing it will potentially make #r nuget slower.

In the second case, since there is no "lib" folder, how will we find the path to the nuget package on disk ?(Currently we use the metadata reference to find the base path to the nuget package C:\Users\.nuget\packages\Xplot\2.0.0\lib\standard2.0\Xplot.dll is used to find the path C:\Users\.nuget\packages\Xplot\2.0.0\ and search for extensions in it)


A third approach that I can think of is that for loading "stand-alone" extensions(ones that are not related to any specific library, like the magic commands), we use the #extend directive or potentially a %%load_ext magic command so the user would do

%%load_ext MyKernelExtension

This would download the extension nuget package and then look for the IKernelExtension types in the metadata references and add them. This would make it a cleaner way to write such extensions and users know explicitly that this nuget package is for the purpose of a KernelExtension.
This will also help us clearly specify that :

  1. If the extension is part of some other nuget package, then you should follow this convention(interactive-extensions\dotnet\cs) and just do #r to consume it.
  2. Else if the extension is not related to any other library, use %%load_ext to use it.

display() renders array values unreadable

Describe the bug

Please provide as much information as you can.

Did this error occur while using dotnet try or online?

  • dotnet-try
  • online

What kind of error was it?

  • User Interface (UI): For example the output never displayed
  • Service Error: For example "The service is temporarily unavailable. We are working on it"
  • Other:

I'm using dotnet-try via Jupyter Lab / C# kernel. Next is the example source code entered in Jupyter Lab cell.

class Example
{
    public float[] values;
    public float distance;
}

var example = new Example
{
    values = new [] { 1.11111f, 2.22222f, 3.33333f },
    distance = 4.44444f
};

var examples = new List<Example>
{
    example,
    example
};

When using the display(examples[0])-command to display individual element of the examples-list the output is ok:

image

However when using display(examples)-command to display the whole list the array of float values are concatenated and it is not clear how many individual values there are:

image

Screenshots

If applicable, add screenshots to help explain your problem.

Please complete the following:

  • OS
    • Windows 10
    • macOS
    • Linux (Please specify distro)
    • iOS
    • Android
  • Browser
    • Chrome
    • Edge
    • Safari

Suggest anaconda or miniconda?

Full anaconda is quite large, and although it's useful for python development, it's not that useful for .NET jupyter work.

Miniconda is far smaller and gets the job done, but if you venture into Python you have to install packages yourself. I think I'd prefer recommending it for .NET jupyter work.

Native library loading doesn't work on 2nd NuGet reference

Describe the bug

The current NativeAssemblyLoadHelper only works on the first NuGet package that is loaded. After that it caches the AssemblyDependencyResolver and doesn't update it.

Did this error occur while using dotnet try or online?

  • dotnet-try
  • online

What kind of error was it?

  • User Interface (UI): For example the output never displayed
  • Service Error: For example "The service is temporarily unavailable. We are working on it"
  • Other:

Screenshots

image

using Microsoft.ML;
using Microsoft.ML.Data;

class IrisData
{
    public IrisData(float sepalLength, float sepalWidth, float petalLength, float petalWidth)
    {
        SepalLength = sepalLength;
        SepalWidth = sepalWidth;
        PetalLength = petalLength;
        PetalWidth = petalWidth;
    }
    public float SepalLength;
    public float SepalWidth;
    public float PetalLength;
    public float PetalWidth;
}

var data = new []
{
    new IrisData(1.4f, 1.3f, 2.5f, 4.5f), 
    new IrisData(2.4f, 0.3f, 9.5f, 3.4f), 
    new IrisData(3.4f, 4.3f, 1.6f, 7.5f), 
    new IrisData(3.9f, 5.3f, 1.5f, 6.5f), 
};

MLContext mlContext = new MLContext();
var pipeline = mlContext.Transforms
    .Concatenate("Features", "SepalLength", "SepalWidth", "PetalLength", "PetalWidth")
    .Append(mlContext.Clustering.Trainers.KMeans("Features", numberOfClusters: 2));

try
{
    pipeline.Fit(mlContext.Data.LoadFromEnumerable(data));
}
catch (Exception e)
{
    Console.WriteLine(e);
}
System.ArgumentNullException: Value cannot be null. (Parameter 'libraryPath')
   at System.Runtime.InteropServices.NativeLibrary.Load(String libraryPath)
   at MLS.Agent.NativeAssemblyLoadHelper.Resolve(String libraryName, Assembly assembly, Nullable`1 searchPath) in F:\git\try\MLS.Agent\NativeAssemblyLoadHelper.cs:line 47
   at System.Runtime.InteropServices.NativeLibrary.LoadLibraryCallbackStub(String libraryName, Assembly assembly, Boolean hasDllImportSearchPathFlags, UInt32 dllImportSearchPathFlags)
   at Microsoft.ML.Internal.CpuMath.Thunk.SumSqU(Single* ps, Int32 c)
   at Microsoft.ML.Internal.CpuMath.CpuMathUtils.SumSq(ReadOnlySpan`1 src)
   at Microsoft.ML.Numeric.VectorUtils.NormSquared(VBuffer`1& a)
   at Microsoft.ML.Trainers.KMeansBarBarInitialization.Initialize(IHost host, Int32 numThreads, IChannel ch, Factory cursorFactory, Int32 k, Int32 dimensionality, VBuffer`1[] centroids, Int64 accelMemBudgetMb, Int64& missingFeatureCount, Int64& totalTrainingInstances)
   at Microsoft.ML.Trainers.KMeansTrainer.TrainCore(IChannel ch, RoleMappedData data, Int32 dimensionality)
   at Microsoft.ML.Trainers.KMeansTrainer.TrainModelCore(TrainContext context)
   at Microsoft.ML.Trainers.TrainerEstimatorBase`2.TrainTransformer(IDataView trainSet, IDataView validationSet, IPredictor initPredictor)
   at Microsoft.ML.Trainers.TrainerEstimatorBase`2.Fit(IDataView input)
   at Microsoft.ML.Data.EstimatorChain`1.Fit(IDataView input)
   at Submission#2.<<Initialize>>d__0.MoveNext()

Please complete the following:

  • OS
    • Windows 10
    • macOS
    • Linux (Please specify distro)
    • iOS
    • Android
  • Browser
    • Chrome
    • Edge
    • Safari

Notes

To fix this, I think we should create a new AssemblyDependencyResolver every time NativeAssemblyLoadHelper.Configure(string path) is invoked. When this object is created, it reads the .deps.json file and uses the information inside to figure out where native assemblies should be loaded from. If subsequent NuGet packages add more locations to probe, the NativeAssemblyLoadHelper is not getting updated.

Use LaTeX formatter when string has the LaTeX pattern

$$ \begin{equation} \int_0^\infty \frac{x^3}{e^x-1}\,dx = \frac{\pi^4}{15} \label{eq:sample} \end{equation} $$ renders as this when executed as a markdown cell:

image

However, if I produce that same string as a string in an F# (or C#) cell, it renders the raw string.

I propose that when we see the $$ at the beginning and end, we render the string as LaTeX instead.

This behavior could be perhaps opted out of with a magic command, %%nolatex.

Tool install hangs

When I run the following command, it just hangs and never completes.

dotnet tool install -g dotnet-try

The output of dotnet --info command is as follows:

.NET Core SDK (reflecting any global.json):
Version:   3.0.100
Commit:    04339c3a26

Runtime Environment:
OS Name:     Windows
OS Version:  10.0.18363
OS Platform: Windows
RID:         win10-x64
Base Path:   C:\Program Files\dotnet\sdk\3.0.100\

Host (useful for support):
  Version: 3.0.0
  Commit:  7d57652f33

.NET Core SDKs installed:
  2.1.509 [C:\Program Files\dotnet\sdk]
  2.1.801 [C:\Program Files\dotnet\sdk]
  2.2.401 [C:\Program Files\dotnet\sdk]
  3.0.100-preview8-013656 [C:\Program Files\dotnet\sdk]
  3.0.100 [C:\Program Files\dotnet\sdk]

.NET Core runtimes installed:
  Microsoft.AspNetCore.All 2.1.12 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.All 2.1.13 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.All 2.2.6 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.App 2.1.12 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 2.1.13 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 2.2.6 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 3.0.0-preview8.19405.7 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 3.0.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 2.1.12 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.1.13 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.2.6 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 3.0.0-preview8-28405-07 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 3.0.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.WindowsDesktop.App 3.0.0-preview8-28405-07 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 3.0.0 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

To install additional .NET Core runtimes or SDKs:
  https://aka.ms/dotnet-download

add .NET kernel quickstart docs and samples

  • Output APIs:
    • eval
    • display, Update
    • Console.Write
  • Formatters
  • PocketView
  • display helpers
    • %%Javascript
    • %%HTML
  • #r & #r NuGet
  • Magic commands
    • %%csharp
    • %%fsharp
    • %%html
    • %%markdown
    • %%javascript
    • %%time
  • Plotting with Xplot
  • CLI
  • Extensions
  • Middleware

include command type in JSON payload for events in stdio mode

Currently in stdio mode, events follow the following schema:

{
    "id": 1,
    "eventType": "CommandHandled",
    "event": {
        "command": {
            "code": "some code",
            "targetKernelName": null,
            "submissionType": 0
        }
    }
}

The command node should also have a way to identify the type of the command.

Graph error when running Tensorflow Transfer Learning on .NET Kernel

Describe the bug

I'm attempting to to Transfer Learning using ML.NET on top of Tensorflow in a Jupyter Notebook running a C# Kernel. The same scenario works well in Visual Studio 2019.
However, when running it on the C# Kernel, I'm getting the following error:

Unhandled Exception
Current graph is not default graph. Default Graph Key: grap-key-462764/, Current Graph Key: grap-key-1/
   at Tensorflow.Graph.OperationByName(String operName)
   at Microsoft.ML.Transforms.ImageClassificationTransformer.AddTransferLearningLayer(String labelColumn, String scoreColumnName, Single learningRate, Int32 classCount)
   at Microsoft.ML.Transforms.ImageClassificationTransformer..ctor(IHostEnvironment env, Session session, String[] outputColumnNames, String[] inputColumnNames, String modelLocation, Nullable`1 addBatchDimensionInput, Int32 batchSize, String labelColumnName, String finalModelPrefix, Architecture arch, String scoreColumnName, String predictedLabelColumnName, Single learningRate, DataViewSchema inputSchema, Nullable`1 classCount, Boolean loadModel, String predictionTensorName, String softMaxTensorName, String jpegDataTensorName, String resizeTensorName, String[] labelAnnotations)
   at Microsoft.ML.Transforms.ImageClassificationTransformer..ctor(IHostEnvironment env, Options options, DnnModel tensorFlowModel, IDataView input)
   at Microsoft.ML.Transforms.ImageClassificationEstimator.Fit(IDataView input)
   at Microsoft.ML.Data.EstimatorChain`1.Fit(IDataView input)
   at Submission#16.<<Initialize>>d__0.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at Microsoft.CodeAnalysis.Scripting.ScriptExecutionState.RunSubmissionsAsync[TResult](ImmutableArray`1 precedingExecutors, Func`2 currentExecutor, StrongBox`1 exceptionHolderOpt, Func`2 catchExceptionOpt, CancellationToken cancellationToken)

Did this error occur while using dotnet try or online?

  • dotnet-try
  • online

What kind of error was it?

  • User Interface (UI): For example the output never displayed
  • Service Error: For example "The service is temporarily unavailable. We are working on it"
  • Other:

Screenshots

If applicable, add screenshots to help explain your problem.
image

Please complete the following:

  • OS
    • Windows 10
    • macOS
    • Linux (Please specify distro)
    • iOS
    • Android
  • Browser
    • Chrome
    • Edge
    • Safari

Unable to use System.Text.Json iin Jupyter c# kernel

Describe the bug

I just installed the c# jupyter kernel today for trying out. I can not get System.Text.Json namespace to import. If I do
using System.Text.Json;
I get this error
(1,19): error CS0234: The type or namespace name 'Json' does not exist in the namespace 'System.Text' (are you missing an assembly reference?)
I also tried to reference it as a nuget package, with
#r "nuget:System.Text.Json"
and it complete successful, but I still cannot use the namespace.

If I run Environment.Version from within the notebook I get 3.0.0 back. And dotnet --version shows 3.0.100 so I think I have the proper version installed.

I have installed some other packages, for example MongoDB.Driver could be installed with nuget and imported with using just fine, so it seems its something specifically with this package.

Did this error occur while using dotnet try or online?

  • dotnet-try
  • online

What kind of error was it?

  • User Interface (UI): For example the output never displayed
  • Service Error: For example "The service is temporarily unavailable. We are working on it"
  • Other:

Screenshots

image

Please complete the following:

  • OS
    • Windows 10
    • macOS
    • Linux (Please specify distro)
    • iOS
    • Android
  • Browser
    • Chrome
    • Edge
    • Safari
    • Firefox

Support rendering Google charts

XPlot also supports Google Charts: https://www.nuget.org/packages/XPlot.GoogleCharts/

However, when executed in the notebook they do not render. Given this code in an F# notebook:

#r "nuget: deedle"
#r "nuget: fsharp.data"
#r "nuget: XPlot.GoogleCharts"
#r "nuget: XPlot.GoogleCharts.Deedle"
    
open Deedle
open FSharp.Data
open XPlot.GoogleCharts
open XPlot.GoogleCharts.Deedle

let wb = WorldBankData.GetDataContext()
let cz = wb.Countries.``Czech Republic``.Indicators
let eu = wb.Countries.``European Union``.Indicators
let czforest = series cz.``Forest area (% of land area)``
let euforest = series eu.``Forest area (% of land area)``

[ czforest.[1990 .. 1993]; euforest.[1990 .. 1993] ]
|> Chart.Line

We get this output:

image

dotnet-try kernel-server fails to start without options

Describe the bug

the command dotnet-try kernel-server fails but works when --default-kernel is specified

dotnet-try kernel-server
Unhandled exception. System.InvalidOperationException: Sequence contains no matching element at System.Linq.Enumerable.First[TSource](IEnumerable1 source, Func2 predicate) at System.CommandLine.Parsing.ParseResultVisitor.PopulateDefaultValues(CommandResult parentCommandResult, ISymbol symbol) at System.CommandLine.Parsing.ParseResultVisitor.Stop(SyntaxNode node) at System.CommandLine.Parsing.SyntaxVisitor.Visit(SyntaxNode node) at System.CommandLine.Parsing.CommandLineParser.Parse(IReadOnlyList1 arguments, String rawInput) at System.CommandLine.Parser.Parse(IReadOnlyList1 arguments, String rawInput) at System.CommandLine.Invocation.InvocationExtensions.InvokeAsync(Parser parser, String[] args, IConsole console) at MLS.Agent.Program.Main(String[] args) in C:\Users\dicolomb\source\repos\Public\try\MLS.Agent\Program.cs:line 36 at MLS.Agent.Program.

(String[] args) PS C:\Users\dicolomb> dotnet-try kernel-server --deault-kernel csharp Unhandled exception. System.InvalidOperationException: Sequence contains no matching element at System.Linq.ThrowHelper.ThrowNoMatchException() at System.Linq.Enumerable.First[TSource](IEnumerable1 source, Func2 predicate) at System.CommandLine.SymbolExtensions.CreateImplicitToken(IOption option) at System.CommandLine.Parsing.ParseResultVisitor.PopulateDefaultValues(CommandResult parentCommandResult, ISymbol symbol) at System.CommandLine.Parsing.ParseResultVisitor.Stop(SyntaxNode node) at System.CommandLine.Parsing.SyntaxVisitor.Visit(SyntaxNode node) at System.CommandLine.Parsing.CommandLineParser.Parse(IReadOnlyList1 arguments, String rawInput) at System.CommandLine.Parser.Parse(IReadOnlyList1 arguments, String rawInput) at System.CommandLine.Invocation.InvocationExtensions.InvokeAsync(Parser parser, String[] args, IConsole console) at MLS.Agent.Program.Main(String[] args) in ..c\try\MLS.Agent\Program.cs:line 36 at MLS.Agent.Program.(String[] args)

Did this error occur while using dotnet try or online?

  • dotnet-try
  • online

What kind of error was it?

  • User Interface (UI): For example the output never displayed
  • Service Error: For example "The service is temporarily unavailable. We are working on it"
  • Other:
    start up error

Screenshots

If applicable, add screenshots to help explain your problem.

Please complete the following:

  • OS
    • Windows 10
    • macOS
    • Linux (Please specify distro)
    • iOS
    • Android
  • Browser
    • Chrome
    • Edge
    • Safari

Implicitly ignore the result of `display`

Currently, display returns a value that is evaluated by F#:

let names = [ "phillip"; "will"; "diego" ]
display names

image

To not display that bottom part, F# needs to explicitly ignore it:

let names = [ "phillip"; "will"; "diego" ]
display names |> ignore

image

Talking with @colombod, it doesn't seem to be particularly useful for either C# or F# to have that evaluated value. I propose that we implicitly ignore it, since any updates to the display won't be by manipulating the object and then evaluating it; they'll come from calling the Update method.

#r doesn't work as expected with local libraries

Describe the bug

This issue has two parts, not sure if they are related:

  1. Attempting to load a locally available library using #r with an absolute path fails partially. An error will be printed as if the #r command failed but namespace is available and types are usable if included with a using statement. Regardless, autocompletion of anything involving this local library doesn't work except when writing the using statement.
  2. Attempting to load a locally available library using #r with a relative path fails completely. It will print out the standard file not found error. I'm not certain if this is intended to work so a clarification would be great. Without using an absolute path, certain (all?) system packaged libraries seem to be loadable just fine which makes me think there is some special handling concerning those.

Both issues are present in Jupyter Notebook, Lab and Console. Tried with various dlls that were either originally downloaded with nuget or built locally.

Did this error occur while using dotnet try or online?

  • dotnet-try (jupyter)
  • online

What kind of error was it?

  • User Interface (UI): For example the output never displayed
  • Service Error: For example "The service is temporarily unavailable. We are working on it"
  • Other: Potential issue with .NET C# Kernel for Jupyter

Screenshots

No screenshots but:

Windows

#r "C:/Users/Mehmet/.nuget/packages/newtonsoft.json/12.0.2/lib/netstandard2.0/Newtonsoft.Json.dll"

Invalid: Command: #r C:/Users/Mehmet/.nuget/packages/newtonsoft.json/12.0.2/lib/netstandard2.0/Newtonsoft.Json.dll

Linux

#r "/home/mehmet/.nuget/packages/newtonsoft.json/12.0.2/lib/netstandard2.0/Newtonsoft.Json.dll"

Invalid: Command: #r /home/mehmet/.nuget/packages/newtonsoft.json/12.0.2/lib/netstandard2.0/Newtonsoft.Json.dll

Please complete the following:

  • OS
    • Windows 10
    • macOS
    • Linux (Ubuntu 18.04)
    • iOS
    • Android
  • Browser
    • Chrome
    • Edge
    • Safari

#r directive parsing probably needs to be language specific

Examples:

C#:
> #r "C:\Users\kevinr\.nuget\packages\newtonsoft.json\12.0.2\lib\netstandard2.0\Newtonsoft.Json.dll"
> using Newtonsoft.Json;
> var json = JsonConvert.SerializeObject(new { value = "hello" });
> json
"{\"value\":\"hello\"}"
>



F#:
// Invalid because \ is an escape char
> #r "C:\Users\kevinr\.nuget\packages\newtonsoft.json\12.0.2\lib\netstandard2.0\Newtonsoft.Json.dll";;
  #r ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

stdin(1,1): error FS2301: 'C:\Users\kevinr\.nuget\packages
ewtonsoft.json\12.0.2\lib
etstandard2.0\Newtonsoft.Json.dll' is not a valid assembly name

>

// Valid no escape chars in string.
> #r "C:/Users/kevinr/.nuget/packages/newtonsoft.json/12.0.2/lib/netstandard2.0/Newtonsoft.Json.dll";;

--> Referenced 'C:/Users/kevinr/.nuget/packages/newtonsoft.json/12.0.2/lib/netstandard2.0/Newtonsoft.Json.dll' (file may be locked by F# Interactive process)

// Valid because we use @"" to delimit unescaped string.
> #r @"C:\Users\kevinr\.nuget\packages\newtonsoft.json\12.0.2\lib\netstandard2.0\Newtonsoft.Json.dll";;

--> Referenced 'C:\Users\kevinr\.nuget\packages\newtonsoft.json\12.0.2\lib\netstandard2.0\Newtonsoft.Json.dll' (file may be locked by F# Interactive process)

// Valid because triple quotes indicate an unescaped multi-line string.  Which can of course occupy less than a line
> #r """C:\Users\kevinr\.nuget\packages\newtonsoft.json\12.0.2\lib\netstandard2.0\Newtonsoft.Json.dll""";;

--> Referenced 'C:\Users\kevinr\.nuget\packages\newtonsoft.json\12.0.2\lib\netstandard2.0\Newtonsoft.Json.dll' (file may be locked by F# Interactive process)


unify #r nuget behavior between C# and F#

The #r nuget behavior and capabilities are different between C# and F#, with F#'s features being more developed. C# currently only supports specifying package id and version. F# supports other parameters such as a package feed (RestoreSources).

Unlike the current C# code, the F# semantics allow for multiple #r nuget statements to aggregate parameters, e.g.

#r "nuget:bl=true"
#r "nuget:RestoreSources=https://dotnet.myget.org/F/dotnet-corefxlab/api/v3/index.json"
#r "nuget:Microsoft.ML,version=1.4.0-preview"
#r "nuget:Microsoft.ML.AutoML"
#r "nuget:Microsoft.Data.DataFrame,version=0.1.1-e191008-1"

This behavior should be added to C#.

In terms of naming, parameter naming seems to draw from several sources in an inconsistent manner, e.g. in the example above bl is an MSBuild command line parameter, RestoreSources is an MSBuild property, version is shared with the dotnet CLI. We should consider making these consistent and hopefully more predictable and easier to remember.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.