Lean icon indicating copy to clipboard operation
Lean copied to clipboard

Plotly.Net support in Research environment needs updating

Open jsboige opened this issue 9 months ago • 1 comments

Expected Behavior

After Lean was migrated to .Net 9, Plotly.Net should still be supported for charting in .Net interactive notebooks as per the official documentation.

Actual Behavior

Using the lib following the official doc (that is, loading the local assemblies) now brings the following warning:

warning CS1701: Assuming assembly reference 'FSharp.Core, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' used by 'Plotly.NET' matches identity 'FSharp.Core, Version=9.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' of 'FSharp.Core', you may need to supply runtime policy

Trying the Html method for displaying the chart inline (HTML(GenericChart.toChartHTML(...)) only returns the additional following warning without any display:

warning CS1701: Assuming assembly reference 'Microsoft.AspNetCore.Html.Abstractions, Version=2.2.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60' used by 'Microsoft.DotNet.Interactive' matches identity 'Microsoft.AspNetCore.Html.Abstractions, Version=9.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60' of 'Microsoft.AspNetCore.Html.Abstractions', you may need to supply runtime policy

Trying display(myChart) outputs a structured object without any display

Trying the myChart.Show() method throws the following exception:

System.ComponentModel.Win32Exception (2): An error occurred trying to start process 'xdg-open' with working directory '/Lean/Launcher/bin/Debug/Notebooks'. No such file or directory at System.Diagnostics.Process.ForkAndExecProcess(ProcessStartInfo startInfo, String resolvedFilename, String[] argv, String[] envp, String cwd, Boolean setCredentials, UInt32 userId, UInt32 groupId, UInt32[] groups, Int32& stdinFd, Int32& stdoutFd, Int32& stderrFd, Boolean usesTerminal, Boolean throwOnNoExec) at System.Diagnostics.Process.StartCore(ProcessStartInfo startInfo) at System.Diagnostics.Process.Start(ProcessStartInfo startInfo) at InternalUtils.ChartIO.openOsSpecificFile(String path) at <StartupCode$Plotly-NET>[email protected](GenericChart ch) at Plotly.NET.Chart.Show(GenericChart ch) at Submission#15.<<Initialize>>d__0.MoveNext() --- End of stack trace from previous location --- at Microsoft.CodeAnalysis.Scripting.ScriptExecutionState.RunSubmissionsAsync[TResult](ImmutableArray1 precedingExecutors, Func2 currentExecutor, StrongBox1 exceptionHolderOpt, Func2 catchExceptionOpt, CancellationToken cancellationToken) at System.Diagnostics.Process.ForkAndExecProcess(ProcessStartInfo startInfo, String resolvedFilename, String[] argv, String[] envp, String cwd, Boolean setCredentials, UInt32 userId, UInt32 groupId, UInt32[] groups, Int32& stdinFd, Int32& stdoutFd, Int32& stderrFd, Boolean usesTerminal, Boolean throwOnNoExec) at System.Diagnostics.Process.StartCore(ProcessStartInfo startInfo) at System.Diagnostics.Process.Start(ProcessStartInfo startInfo) at InternalUtils.ChartIO.openOsSpecificFile(String path) at <StartupCode$Plotly-NET>[email protected](GenericChart ch) at Plotly.NET.Chart.Show(GenericChart ch) at Submission#15.<<Initialize>>d__0.MoveNext() --- End of stack trace from previous location --- at Microsoft.CodeAnalysis.Scripting.ScriptExecutionState.RunSubmissionsAsync[TResult](ImmutableArray1 precedingExecutors, Func2 currentExecutor, StrongBox1 exceptionHolderOpt, Func2 catchExceptionOpt, CancellationToken cancellationToken)

Potential Solution

This probably has to do with Plotly.Net version. Trying to use the latest version in another non QC notebook, I had to do without inline display (images would open externally)

Reproducing the Problem

Had the error in distinct Notebooks so I believe the problem is general with Plotly.Net usage

System Information

Latest lean-cli, using vscode on Windows

Checklist

  • [x ] I have completely filled out this template
  • [ x] I have confirmed that this issue exists on the current master branch
  • [ x] I have confirmed that this is not a duplicate issue by searching issues
  • [ x] I have provided detailed steps to reproduce the issue

jsboige avatar Apr 04 '25 08:04 jsboige

The following works using the latest lean cli and lean image. Taken from https://github.com/plotly/Plotly.NET?tab=readme-ov-file#c Image

Martin-Molinero avatar May 08 '25 14:05 Martin-Molinero