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

hvplots only work when executed line by line #5991

Open
jonvanausdeln opened this issue Jan 14, 2025 · 3 comments
Open

hvplots only work when executed line by line #5991

jonvanausdeln opened this issue Jan 14, 2025 · 3 comments
Labels
area: plots Issues related to Plots category. lang: python regression

Comments

@jonvanausdeln
Copy link
Contributor

jonvanausdeln commented Jan 14, 2025

System details:

Positron and OS details:

Positron Version: 2025.02.0 (system setup) build 39
Code - OSS Version: 1.95.0
Commit: 968a8ac
Date: 2025-01-13T02:52:35.414Z
Electron: 32.2.1
Chromium: 128.0.6613.186
Node.js: 20.18.0
V8: 12.8.374.38-electron.0
OS: Windows_NT x64 10.0.26100

Interpreter details:

Python 3.10.10

Describe the issue:

This just started occurring on 1/14/2025. There seems to be some package dependency that updated, but we can't figure out which. It is similar to #4891

A simple python script to generate a plot using hvplot will only show if the script is executed line by line. It will not show if the entire file is sent to the console via the "run" button nor if you copy the entire block and past it in into the console.

Image

Steps to reproduce the issue:

import hvplot.pandas
import pandas as pd
hvplot.extension('plotly')
pd.DataFrame(dict(x=[1,2,3], y=[4,5,6])).hvplot.scatter(x="x", y="y")
  1. Create a new venv
  2. Create new python file with above example code
  3. Click run button to "Run Python file in console"
  4. The plot does not display correctly.
  5. Copy entire contents of the file
  6. Paste into console and hit enter to execute entire block
  7. The plot does not display correctly.

Only by executing line by line (using ctrl+enter) will get the plot to show

Expected or desired behavior:

Plot to show when executing entire file.

Were there any error messages in the UI, Output panel, or Developer Tools console?

vscode-app-1736882274763.log

Image

QA Notes

See #5993 for disabled tests. Re-enable when this is resolved

@jonvanausdeln jonvanausdeln added area: plots Issues related to Plots category. lang: python regression labels Jan 14, 2025
jonvanausdeln added a commit that referenced this issue Jan 14, 2025
Due to #5991 we need to skip this test for now.

<!-- Thank you for submitting a pull request.
If this is your first pull request you can find information about
contributing here:
  * https://github.com/posit-dev/positron/blob/main/CONTRIBUTING.md

We recommend synchronizing your branch with the latest changes in the
main branch by either pulling or rebasing.
-->

<!--
  Describe briefly what problem this pull request resolves, or what
  new feature it introduces. Include screenshots of any new or altered
  UI. Link to any GitHub issues but avoid "magic" keywords that will
  automatically close the issue. If there are any details about your
  approach that are unintuitive or you want to draw attention to, please
  describe them here.
-->


### Release Notes

<!--
  Optionally, replace `N/A` with text to be included in the next release notes.
  The `N/A` bullets are ignored. If you refer to one or more Positron issues,
  these issues are used to collect information about the feature or bugfix, such
  as the relevant language pack as determined by Github labels of type `lang: `.
  The note will automatically be tagged with the language.

  These notes are typically filled by the Positron team. If you are an external
  contributor, you may ignore this section.
-->

#### New Features

- N/A

#### Bug Fixes

- N/A


### QA Notes
@:plots
<!--
  Add additional information for QA on how to validate the change,
  paying special attention to the level of risk, adjacent areas that
  could be affected by the change, and any important contextual
  information not present in the linked issues.
-->
@timtmok
Copy link
Contributor

timtmok commented Jan 14, 2025

I just updated hvplot to see if it would do the same thing. It seems to only fail when using Run Python File in Console. It was the same failure as before updating hvplot.

Although, I added a line of code and couldn't get the execute selection to show the plot:

import hvplot.pandas
import pandas as pd
hvplot.extension('plotly')
pd.DataFrame(dict(x=[1,2,3], y=[4,5,6])).hvplot.scatter(x="x", y="y")
x=25

I used Ctrl+Enter to run the selection and sourcing the file. Only running line-by-line works. It does appear to execute the entire block since x shows up in the Variables pane but no plot is displayed.

@timtmok
Copy link
Contributor

timtmok commented Jan 15, 2025

function isHoloviewsDisplayBundle(mimeTypes: Set<string>): boolean {
return mimeTypes.has(MIME_TYPES.HOLOVIEWS_EXEC) &&
mimeTypes.has(MIME_TYPES.HTML) &&
mimeTypes.has(MIME_TYPES.PLAIN);
}

It seems to be something with checking the mime types. We get the holoviews mime type but the check requires more than that to trigger displaying the plot.

These are the mime types when executing the file:

  • application/javascript
  • application/vnd.holoviews_load.v0+json

There's also a second message that comes in with these mime types:

  • text/html
  • application/vnd.holoviews_load.v0+json

So the file execution doesn't have the right mime types to display the plot and the message from the backend is effectively dropped.

@timtmok
Copy link
Contributor

timtmok commented Jan 15, 2025

This is the only place that includes the holoviews exec mime type but it doesn't seem to add in text/plain.

https://github.com/holoviz/holoviews/blob/e1f584b4bf2398113c652f0c52c93660959488a9/holoviews/plotting/renderer.py#L381

@nstrayer I'm not really sure the reason we only render when receiving all three mime types but that only happens when running the code line-by-line.

@juliasilge juliasilge added this to the 2025.06 Pre-Release milestone Jan 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: plots Issues related to Plots category. lang: python regression
Projects
None yet
Development

No branches or pull requests

3 participants