microsoft / vscode-data-wrangler

Other
418 stars 16 forks source link

Unable to view DataFrame in VS Code using Data Wrangler extension #270

Open mekanavsharma opened 2 weeks ago

mekanavsharma commented 2 weeks ago

Environment data

Expected behaviour

Showed be able to view dataframe in new pop-up

Actual behaviour

When attempting to view a DataFrame in Visual Studio Code using the Data Wrangler extension, I encounter the following error: "Could not retrieve variable autos from the Jupyter extension. Please file an issue on the Data Wrangler GitHub repository."

Steps to reproduce:

I've verified that the DataFrame exists and is accessible in my code. The issue persists after restarting VS Code and updating all relevant extensions. I can view the DataFrame using alternative methods (e.g., print statements, Jupyter notebooks), but not through the Data Wrangler extension. image

image

These are the issues.

Also, I am not able to see Open 'df' in Data Wrangler in my dataframe image

pwang347 commented 2 weeks ago

Hi @mekanavsharma, thank you for opening this issue! Could you please confirm the following:

It would be very helpful if you could provide the information above. Thanks!

mekanavsharma commented 2 weeks ago

Hi @mekanavsharma, thank you for opening this issue! Could you please confirm the following:

  • Are you able to see the Open 'df' in Data Wrangler button and launch from the variable panel with the following simple DataFrame?
df = pd.DataFrame(data={'col1': [1, 2], 'col2': [3, 4]})
df
  • Could you try to reproduce the issue again with the developer console open and check to see if there are any related error messages? You can open the developer console as follows:

image image It would be very helpful if you could provide the information above. Thanks!

Thanks for the help.

Point 1: No I am not able to see, Open 'df' in Data Wrangler

image

Point 2: Here is what I got when I reproduced the issue again with the developer console open. image

On clicking "console.ts.137" I got: image

On Clicking "notificationsAlerts.ts.42" I got: image

pwang347 commented 2 weeks ago

Hi @mekanavsharma, thanks for the quick response! Some more followups:

mekanavsharma commented 2 weeks ago

Hi @mekanavsharma, thanks for the quick response! Some more followups:

image image (then reproduce the issue and copy output from the output panel)

Thanks for the response :

  1. No I didn't get any such popup.
  2. Here Is what I have in my settings : image

Here is what I did :

image Still I am not getting "Open 'df' in Data Wrangler" . But there is change when I am clicking on popup in Jupyter -Variables. Earlier I was getting the error "Could not retrieve ......" which I have shared the screeshot. This time I am getting a pop-up: image Which would re-direct me to Data wrangler which is already installed.

image

FYI: I used to get this popup a month ago. But then I don't what changes were made and I am not getting this pop.

pwang347 commented 2 weeks ago

@mekanavsharma, got it thanks for giving it a try - actually your original settings are correct, the affinity setting is what has caused some problems previously. Please remove that setting for now.

This error message you posted below seems to be the culprit:

image

Data Wrangler needs permission from the Jupyter extension to access the kernel and it seems to not have permission in this case, but it's strange that you're also not getting a popup. It would be great if you could open an issue on the Jupyter side, as this seems to be related to their kernel API.

mekanavsharma commented 2 weeks ago

@mekanavsharma, got it thanks for giving it a try - actually your original settings are correct, the affinity setting is what has caused some problems previously. Please remove that setting for now.

This error message you posted below seems to be the culprit: image

Data Wrangler needs permission from the Jupyter extension to access the kernel and it seems to not have permission in this case, but it's strange that you're also not getting a popup. It would be great if you could open an issue on the Jupyter side, as this seems to be related to their kernel API.

Thanks for the help. Will do that.

jjbochard commented 1 week ago

To solve this problem, I unchecked this settings Capture d’écran 2024-09-02 à 13 23 34

mekanavsharma commented 1 week ago

To solve this problem, I unchecked this settings Capture d’écran 2024-09-02 à 13 23 34

It worked. Thanks

NiKoenig commented 1 week ago

To solve this problem, I unchecked this settings Capture d’écran 2024-09-02 à 13 23 34

Worked for me as well, thank you!! :)

DonJayamanne commented 1 week ago

Solution

Also ensure the setting Experiments: Use Jupyter Proposed API is enabled.

The reason this may not have worked in the past is users may have received a prompt requesting Data Wrangler extension to gain access to Kernels. Its very likely this prompt was dismissed, meaning access was not granted.

The error message logged here is evidence of that https://github.com/microsoft/vscode-data-wrangler/issues/270#issuecomment-2316779172

pwang347 commented 1 week ago

Thanks all!

Please follow the solution shared by @DonJayamanne as it will soon become the default option moving forward (and you may run into this issue again). It seems like we can also handle this error better on our side to ask for permissions, so I will leave this issue open until that gets checked in.

dark-tonebone commented 1 week ago

I have tried the the recommended steps and It's still not working.

I have a pandas dataframe, and i'm right-clicking, then selecting 'View Value in Data Viewer' and I get a small pop up error (attached).

My settings are exactly as described by Don Jayamanne (here).

image

pwang347 commented 1 week ago

Hi @dark-tonebone, could you please check to see if you have the same error message in the developer console? You can run the following command to open it

image

And then make sure you are on the "Console" tab

image

Do you also have this message or is it something different? image

If you are attempting to open a PySpark DataFrame and you see this error, then you may need to follow instructions here: https://github.com/microsoft/vscode-data-wrangler/issues/255#issuecomment-2330415787 (if not, it would be great if you could share what data type you are using!)

DonJayamanne commented 6 days ago

Please can you share a screenshot of the following screen Select the command Jupyter: Manage Access to Jupyter kernels from the command palette

ZWX013 commented 5 days ago

微信截图_20240909111134 I also tried the the recommended steps and It's still not working.

DonJayamanne commented 5 days ago

Please could you enable logging as follows:

pwang347 commented 4 days ago

@ZWX013 Could you please also expand the highlighted objects by clicking on the arrow? image

After you expand it (and any other relevant errors above), it would be great if you could share the following log file

image

Thanks!

dark-tonebone commented 4 days ago

Hi @DonJayamanne thanks for your response!

DataWrangler worked a bunch for me today, and then I encountered a dataframe it would not load. Here are the requested screenshots taken right after clicking 'View Value in DataViewer' (which failed to open my df in DataWrangler).

Expanded variable in my variable inspector image

Jupyter Logs image

dark-tonebone commented 4 days ago

@pwang347 sorry I'm not sure where in VSCode I can find that arrow to expand... It looks like you're in a web browser dev tools panel? I'm using VSCode on Windows 11.

dark-tonebone commented 4 days ago

Interestingly, after closing and reopening VSCode, the DataWrangler now works with that exact same dataframe!

pwang347 commented 4 days ago

Hi @dark-tonebone! If you are able to view DataFrames sometimes, I think this is a different issue. The permissions issue would prevent you from viewing completely.

In case you are able to reproduce the issue again, could you please try the steps here? You should be able to also see the dev tools panel within VS Code: https://github.com/microsoft/vscode-data-wrangler/issues/270#issuecomment-2334998717

Alternatively, you can try opening it this way:

image
dark-tonebone commented 4 days ago

Hi @pwang347 thanks for the updated instructions to access the dev tools :)

I managed to make it error again. It happened soon after i closed a DataWrangler window that was stale from an old debug session. I closed it while some code was running.

Anyways, here are the screenshots and files you requested in your previous comment: 1) Screenshot of 'Console' tab immediately after error image

2) Screenshot of expanded error line image

3) Screenshot of the notificationAlerts.ts file image

4) .log file obtained by right-clicking the error and saving as vscode-app-1725926313871.log

pwang347 commented 4 days ago

Hi @dark-tonebone, no problem and thank you for sharing the logs! Looks like you're running into this issue https://github.com/microsoft/vscode-data-wrangler/issues/275

We should have a fix soon this week, but if you'd like a workaround build for now it's available here: https://github.com/microsoft/vscode-data-wrangler/issues/275#issuecomment-2336852687

dark-tonebone commented 4 days ago

Awesome! Great to hear there's a fix incoming. I'm happy to wait for the update. Thanks for your prompt responses on this issue, it's very much appreciated 💯

pwang347 commented 3 days ago

@dark-tonebone small update, the fix for https://github.com/microsoft/vscode-data-wrangler/issues/275 should be available now in pre-release 1.9.2. Please feel free to give it a try and let me know if you're still running into any issues!

WulfNovak commented 3 days ago

@pwang347

Hello,

Have been following this thread and trying the suggestions. I have been unable to view the data viewer regardless of suggestion. After the recent pre-release this still holds true. Gave same information as dark-tonebone as best I can.

Here are my existing settings relevant to this thread:

  1. Selected Experimental: image
  2. Installed Data Wrangler v1.9.2 (pre-release)

Console tab has a lot of information - here is the screenshot of the bottom portion image

Screenshot of the notificationsAlerts image image

.log file vscode-app-1725999265621.log

Thank you for your time - please let me know if there's any additional information needed!

pwang347 commented 3 days ago

Hi @WulfNovak, thanks for sharing. Based on the logs it looks like you're encountering something different, could you please open a new issue to help us with tracking?

In the new issue, I'd like you to share the following info:

  1. Does this happen for any data viewing? E.g. can you try creating a new Python file with just the following code and try to open the variable l?:

    l = [1,2,3]
    print(l) # <- add breakpoint here
  2. Could you please share the output of running this code in the same environment where you are getting the error:

    
    def __DW_GET_EXPRESSION_VARIABLE__():
    import builtins
    import json
    import sys
    supported_dataframe_types = {
        builtins.list: "list",
        builtins.dict: "dictionary",
    }
    
    if 'numpy' in sys.modules:
        try:
            import numpy as np
            supported_dataframe_types[np.ndarray] = "ndarray"
        except builtins.Exception:
            pass
    
    if 'pandas' in sys.modules:
        try:
            import pandas as pd
            supported_dataframe_types[pd.DataFrame] = "pandas"
            supported_dataframe_types[pd.Series] = "series"
        except builtins.Exception:
            pass
    
    if 'polars' in sys.modules:
        try:
            import polars as pl
            supported_dataframe_types[pl.DataFrame] = "polars"
            supported_dataframe_types[pl.Series] = "polarsSeries"
        except builtins.Exception:
            pass
    
    if 'xarray' in sys.modules:
        try:
            import xarray as xr
            supported_dataframe_types[xr.DataArray] = "dataArray"
        except builtins.Exception:
            pass
    
    if 'tensorflow' in sys.modules:
        try:
            import tensorflow as tf
            supported_dataframe_types[tf.Tensor] = "eagerTensor"
        except builtins.Exception:
            pass
    
    if 'torch' in sys.modules:
        try:
            import torch
            supported_dataframe_types[torch.Tensor] = "tensor"
        except builtins.Exception:
            pass
    
    if 'pyspark' in sys.modules and False:
        try:
            import pyspark
            supported_dataframe_types[pyspark.sql.dataframe.DataFrame] = "pyspark"
        except builtins.Exception:
            pass
    
    eval_result = data_viewer_check
    if builtins.type(eval_result) not in supported_dataframe_types:
        return None
    return builtins.print(json.dumps({
        "type": supported_dataframe_types[builtins.type(eval_result)],
        "supportedEngines": ["pandas"],
    }))

try: DW_GET_EXPRESSION_VARIABLE() finally: del DW_GET_EXPRESSION_VARIABLE



Thanks!