kylebarron / vscode-jupyter-python

Run automatically-inferred Python code blocks in the VS Code Jupyter extension
https://marketplace.visualstudio.com/items?itemName=kylebarron.vscode-jupyter-python
MIT License
37 stars 3 forks source link

Error: Illegal value for `line` #14

Closed SimonB97 closed 1 month ago

SimonB97 commented 1 month ago

Hi Kyle,

firstly, thank you for the simple but great extension!

I'm running into an issue with Jupyter when trying to run the below python file using your extension. The Jupyter log is also below.

Steps to reproduce:

  1. pip install matplotlip
  2. step through all inferred code blocks with shift + enter

generate_cvbg_img.py:

"""Generate a background image for a CV with two colors."""

import matplotlib.pyplot as plt
import os

def generate_image(file_path, left_color, right_color, left_width_percentage, a4_width_inch=8.27, a4_height_inch=11.69):
    fig, ax = plt.subplots(figsize=(a4_width_inch, a4_height_inch))
    ax.fill_betweenx([0, 1], 0, left_width_percentage, color=left_color, transform=ax.transAxes)
    ax.fill_betweenx([0, 1], left_width_percentage, 1, color=right_color, transform=ax.transAxes)
    ax.axis('off')
    plt.savefig(file_path, bbox_inches='tight', pad_inches=0)
    plt.close()

if __name__ == "__main__":
    # Page size setup
    a4_width_inch = 8.27
    a4_height_inch = 11.69
    left_width_percentage = 0.26  # width of the left color in percentage
    right_color = '#ffffff'

    # create outputs folder if it does not exist
    if not os.path.exists('outputs'):
        os.makedirs('outputs')

    # Generate image with color #00162b
    left_color_0 = '#00162b'
    file_path_00162b = f'outputs/cvbg_{left_color_0[1:]}.png'
    generate_image(file_path_00162b, left_color_0, right_color, left_width_percentage, a4_width_inch, a4_height_inch)

    # Generate image with color #011d59
    left_color_1 = '#011d59'
    file_path_011d59 = f'outputs/cvbg_{left_color_1[1:]}.png'
    generate_image(file_path_011d59, left_color_1, right_color, left_width_percentage, a4_width_inch, a4_height_inch)

    print(f"Images saved as {file_path_00162b} and {file_path_011d59}")

Jupyter log:

14:55:28.206 [info] Generated code for 1 = <ipython-input-1-a0d2faabd9e9> with 1 lines
14:55:29.719 [info] Generated code for 2 = <ipython-input-2-543d7f3a58ae> with 1 lines
14:55:30.662 [info] Generated code for 3 = <ipython-input-3-d010b93169df> with 7 lines
14:55:32.562 [error] Error in execution (get message for cell) Error: Illegal value for `line`
    at u.t (e:\Programme\Microsoft VS Code Insiders\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:153:961)
    at Object.lineAt (e:\Programme\Microsoft VS Code Insiders\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:153:90)
    at XT.generateCodeImpl (c:\Users\~\.vscode-insiders\extensions\ms-toolsai.jupyter-2024.6.2024062802-win32-x64\dist\extension.node.js:332:2855)
    at XT.generateCode (c:\Users\~\.vscode-insiders\extensions\ms-toolsai.jupyter-2024.6.2024062802-win32-x64\dist\extension.node.js:332:1804)
    at wf.generateCodeAndAddMetadata (c:\Users\~\.vscode-insiders\extensions\ms-toolsai.jupyter-2024.6.2024062802-win32-x64\dist\extension.node.js:355:3566)
    at wf.createExecutionPromise (c:\Users\~\.vscode-insiders\extensions\ms-toolsai.jupyter-2024.6.2024062802-win32-x64\dist\extension.node.js:355:711)
14:55:32.562 [warn] DataScience Error Error: Illegal value for `line`
    at u.t (e:\Programme\Microsoft VS Code Insiders\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:153:961)
    at Object.lineAt (e:\Programme\Microsoft VS Code Insiders\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:153:90)
    at XT.generateCodeImpl (c:\Users\~\.vscode-insiders\extensions\ms-toolsai.jupyter-2024.6.2024062802-win32-x64\dist\extension.node.js:332:2855)
    at XT.generateCode (c:\Users\~\.vscode-insiders\extensions\ms-toolsai.jupyter-2024.6.2024062802-win32-x64\dist\extension.node.js:332:1804)
    at wf.generateCodeAndAddMetadata (c:\Users\~\.vscode-insiders\extensions\ms-toolsai.jupyter-2024.6.2024062802-win32-x64\dist\extension.node.js:355:3566)
    at wf.createExecutionPromise (c:\Users\~\.vscode-insiders\extensions\ms-toolsai.jupyter-2024.6.2024062802-win32-x64\dist\extension.node.js:355:711)
kylebarron commented 1 month ago

This is a duplicate of #6. It only happens when you run shift+enter on the last line of the text editor. I've never gotten around to actually fixing it, but I should look at #11