plotly / Plotly.NET

interactive graphing library for .NET programming languages :chart_with_upwards_trend:
https://plotly.net
MIT License
663 stars 88 forks source link

Exception when using .NET Polyglot Notebook due to strong naming #433

Closed poopsicles closed 1 year ago

poopsicles commented 1 year ago

Description

When I make a minimal C#/F# notebook, it fails to render under the cell when the chart is the last variable. However when Chart.Show() is called, it opens fine in a browser window.

Repro steps

  1. Download the Polyglot Notebooks extension
  2. Make a new .ipynb file
  3. Add the following cells:

    --------------------------------- 
    #r "nuget: Plotly.NET.Interactive"
    #r "nuget: Plotly.NET.CSharp"
    ---------------------------------
    let xData' = [ 0. .. 10. ]
    let yData' = [ 0. .. 10. ]
    Chart.Point(xData', yData')
    ---------------------------------
    using Plotly.NET.CSharp;
    
    Chart.Point<int, int, string>(
        x: Enumerable.Range(0,11),
        y: Enumerable.Range(0,11)
    )

Expected behavior

The chart is rendered under both cells.

Actual behavior

An exception is thrown:

{
    "name": "Error",
    "message": "System.IO.FileNotFoundException: Could not load file or assembly 'Giraffe.ViewEngine.StrongName, Version=2.0.0.0, Culture=neutral, PublicKeyToken=028aa8e2a326f4d0'. The system cannot find the file specified.

File name: 'Giraffe.ViewEngine.StrongName, Version=2.0.0.0, Culture=neutral, PublicKeyToken=028aa8e2a326f4d0'
   at Plotly.NET.Interactive.Formatters.toInteractiveHTML(GenericChart gChart)
   at <StartupCode$Plotly-NET-Interactive>.$Extension.Microsoft-DotNet-Interactive-IKernelExtension-OnLoadAsync@16.Invoke(GenericChart chart, TextWriter writer)
   at Microsoft.DotNet.Interactive.Formatting.Formatter.<>c__DisplayClass46_0`1.<Register>b__0(Object value, FormatContext context) in D:\\a\\_work\\1\\s\\src\\Microsoft.DotNet.Interactive.Formatting\\Formatter.cs:line 427
   at Microsoft.DotNet.Interactive.Formatting.Formatter`1.FormatTo(T obj, FormatContext context, String mimeType) in D:\\a\\_work\\1\\s\\src\\Microsoft.DotNet.Interactive.Formatting\\Formatter{T}.cs:line 86
   at Microsoft.DotNet.Interactive.Formatting.Formatter.ToDisplayString(Object obj, String mimeType) in D:\\a\\_work\\1\\s\\src\\Microsoft.DotNet.Interactive.Formatting\\Formatter.cs:line 281
   at Microsoft.DotNet.Interactive.FormattedValue.<>c__DisplayClass12_0.<CreateManyFromObject>b__0(String mimeType) in D:\\a\\_work\\1\\s\\src\\Microsoft.DotNet.Interactive\\FormattedValue.cs:line 49
   at System.Linq.Enumerable.SelectArrayIterator`2.ToArray()
   at Microsoft.DotNet.Interactive.CSharp.CSharpKernel.Microsoft.DotNet.Interactive.IKernelCommandHandler<Microsoft.DotNet.Interactive.Commands.SubmitCode>.HandleAsync(SubmitCode submitCode, KernelInvocationContext context) in D:\\a\\_work\\1\\s\\src\\Microsoft.DotNet.Interactive.CSharp\\CSharpKernel.cs:line 335
   at Microsoft.DotNet.Interactive.Kernel.HandleAsync(KernelCommand command, KernelInvocationContext context) in D:\\a\\_work\\1\\s\\src\\Microsoft.DotNet.Interactive\\Kernel.cs:line 331
   at Microsoft.DotNet.Interactive.KernelCommandPipeline.<BuildPipeline>b__6_0(KernelCommand command, KernelInvocationContext context, KernelPipelineContinuation _) in D:\\a\\_work\\1\\s\\src\\Microsoft.DotNet.Interactive\\KernelCommandPipeline.cs:line 60
   at Microsoft.DotNet.Interactive.KernelCommandPipeline.SendAsync(KernelCommand command, KernelInvocationContext context) in D:\\a\\_work\\1\\s\\src\\Microsoft.DotNet.Interactive\\KernelCommandPipeline.cs:line 51"
}

Known workarounds

Don't display the cell output in the cell, call .Show() to open it in a browser

Related information

kMutagene commented 1 year ago

Hey @poopsicles thanks for reporting this.

I can not reproduce this issue, at least not on windows. You seem to be mixing F# and C# cells, but have no dependency loading cell for both (your first cell can only work for one, C# or F#)

However, i tried all permutations that are expected to work, and all of them produce the desired chart:

image

What version of the extension are you using?

poopsicles commented 1 year ago

Hey @kMutagene, thanks for the quick response.

Yeah I saw that the library was somewhat F#-first, that's why I tried to do it in both languages. I'll see if I can try and get the issue on some of my other friends' devices, they use the whole spectrum (macOS, Windows, Fedora) so that I can see if it's just a me problem.

I'm using v1.0.4552010 of Polyglot Notebooks, and the output indicates Plotly.NET.CSharp, 0.11.1 & Plotly.NET.Interactive, 4.2.1 is being installed.

And I just tried now and it works anyways, I think maybe me mixing both C# and F# might have broken it (or maybe the order?)

Thank you soo much for your help!

image image

kMutagene commented 1 year ago

Still a weird error, never seen before. Happy that it works for you now 👍