plasma-umass / scalene

Scalene: a high-performance, high-precision CPU, GPU, and memory profiler for Python with AI-powered optimization proposals
Apache License 2.0
11.57k stars 388 forks source link

No such file or directory: 'scalene\\scalene-gui\\scalene-gui.js' #491

Closed erikbrntsn closed 1 year ago

erikbrntsn commented 1 year ago

Describe the bug Running python -m scalene my_script.py fails with

FileNotFoundError: [Errno 2] No such file or directory: 'scalene\scalene-gui\scalene-gui.js'

To Reproduce Steps to reproduce the behavior: Not sure how to make this reproducible for others. I do not really think it is related to my code as it is fairly simple nor to my setup as it is also pretty standard: windows 11 + python venv. Let me know if you need me to share my code though.

Desktop (please complete the following information):

Additional context This is my first time trying to use Scalene. After installing it and running it the first time I got the error described in #462. After uninstalling it and installing it directly from the repo as described in the comments - along with installing wheel - that error mostly disappeared (still get it if I use the --cli flag). Now, however, I get the FileNotFoundError mentioned above.

emeryberger commented 1 year ago

Thanks for the report! I just pushed a change that should fix the issue above; please try re-installing from the repo.

erikbrntsn commented 1 year ago

The newest version in the repo fixes the FileNotFoundError. Thank you!

Note that when using --cli the OSError: [Errno 22] Invalid argument described in #462 is still there though.

erikbrntsn commented 1 year ago

This is my first use of scalene as mentioned earlier so please bear with me. Maybe this is a problem on my side.

With the newest version in the repository scalene finishes without errors, but the visualization of the profile seems to be missing most of the info it is supposed to contain. Specifically it is missing all the info on the left half of the screen.

missing_info

emeryberger commented 1 year ago

Can you elaborate on the --cli issue? I can't reproduce it. I also see the visualization fine in the web version on Windows, see below. Can you open up the Javascript console to see if that reveals any issues?

Screen Shot 2022-11-16 at 10 08 37 AM
emeryberger commented 1 year ago

Without seeing the messages, it's hard to say, but it looks like there is some issue with access to the CDN that hosts the visualization toolkit (Vega and Vega-Lite). Can you try to just load the following URL in your browser? https://cdn.jsdelivr.net/npm/vega@5.21.0

erikbrntsn commented 1 year ago

There is one error in the JavaScript Console:

Uncaught (in promise) TypeError: document.getElementById(...) is null
    display file:///C:/projects/ricochet robots/profile.html:4777
    load file:///C:/projects/ricochet robots/profile.html:4842
    load file:///C:/projects/ricochet robots/profile.html:4843
    <anonymous> file:///C:/projects/ricochet robots/profile.html:4872

The URL loads fine (contains a bunch of dense code).

erikbrntsn commented 1 year ago

If I run my code like this scalene --cli board_manager.py I get the following

Scalene: An exception of type OSError occurred. Arguments:
(22, 'Invalid argument')
Traceback (most recent call last):
  File "C:\projects\ricochet robots\.venv\lib\site-packages\scalene\scalene_profiler.py", line 1952, in run_profiler
    exit_status = profiler.profile_code(
  File "C:\projects\ricochet robots\.venv\lib\site-packages\scalene\scalene_profiler.py", line 1770, in profile_code
    did_output = Scalene.output_profile()
  File "C:\projects\ricochet robots\.venv\lib\site-packages\scalene\scalene_profiler.py", line 905, in output_profile
    did_output: bool = output.output_profiles(
  File "C:\projects\ricochet robots\.venv\lib\site-packages\scalene\scalene_output.py", line 534, in output_profiles
    with open(full_fname, "r", encoding="utf-8") as source_file:
OSError: [Errno 22] Invalid argument: 'C:\\projects\\ricochet robots\\<frozen importlib._bootstrap>'

This exception is only thrown if I use the --cli flag

emeryberger commented 1 year ago

I just pushed a change that should fix the --cli issue.

erikbrntsn commented 1 year ago

Removing the space from the path and reinstalling scalene removes the problem. The profile is now shown correctly.

I can confirm that the problem with the flag --cli is resolved in the newest version (I did not test it before removing the space from the path though)

emeryberger commented 1 year ago

Thanks for testing, and glad it is working for you now! Weirdly I could not reproduce the issue with the space in the path, which is annoying since I would like to be able to handle that case if it arises for someone else.