spyder-ide / spyder

Official repository for Spyder - The Scientific Python Development Environment
https://www.spyder-ide.org
MIT License
8.25k stars 1.6k forks source link

Add run/working directory options for the Profiler and Pylint plugins #1110

Open spyder-bot opened 9 years ago

spyder-bot commented 9 years ago

From wenzesl...@gmail.com on 2012-07-05T02:23:07Z

What steps will reproduce the problem?

  1. Have some python script which needs parameters and/or working directory.
    1. Try to profile it.
    2. Profiler accepts only script path (file name). What is the expected output? What do you see instead? I want to use run option for a script/file as a run settings for Profiler.

Smaller improvement would be get current file path from Editor to Profiler. This applies also for Pylint. However some scripts needs some environment/parameters to run, so for Profiler this wouldn't be enough.

Original issue: http://code.google.com/p/spyderlib/issues/detail?id=1110

spyder-bot commented 9 years ago

From ccordoba12 on 2012-07-08T09:06:10Z

Thanks for the report and for your interest in Spyder.

I'll probably work on this after we release version 2.2 in October, but not before because there are several things we have to finish first :)

Summary: Add run options for the Profiler and Pylint plugins

CAM-Gerlach commented 6 years ago

I've had this issue as well FYI; I've had to hardcode absolute paths to temporarily get around it and it makes it a hassle profiling my code.

ccordoba12 commented 6 years ago

@CAM-Gerlach, do you want to work on it?

CAM-Gerlach commented 6 years ago

@ccordoba12 I could certainly give it a shot, though it might be a little bit.

What the original reporter asks for is to just read the file's working directory settings from the existing per-file run configuration, as is apparently currently done for command-line arguments. This would probably be the least work to implement I would think, and I'm not sure of many use cases that would require separate settings for the profiler and pylint vs. those used normally (in fact the impetus of this issue is asking for the latter to be respected, as is my use case). As this doesn't really add anything new, but just fixes the current bad behavior and reads the current settings properly, I'd think this would be feasible to squeeze into 3.x.

However, beyond just that, the issue title seems to suggest is a dedicated settings pane for the static analyzer and the profiler, allowing the user to override the per-file working dir settings or command-line arguments, either globally within the profiler/analyzer or even a whole separate per-file run configuration. Especially the latter seems like unnecessary complexity and effort for what I'd think would be a very small slice of use cases that couldn't just use the normal per-file settings for profiling, or just change them temporarily, and as something more substantial requiring a new UI pane and expanded functionality this would certainly push it to Spyder 4.

Your thoughts?

ccordoba12 commented 6 years ago

You could work on it for Spyder 4, adding the necessary options to the Profiler and Pylint plugins.

CAM-Gerlach commented 6 years ago

@ccordoba12 There are really two separate, though closely related issues being discussed here.

  1. The Profiler and pylint don't respect the working dir in the run config dialog which is what both the OP and myself are asking for. The fact that they don't (like they currently do for command-line options) can be viewed as a bug and can easily break script execution in the profiler and lead to lots of erroneous errors in pylint; is much more important to fix IMO (as it is the actual problem the OP, others, and myself are asking to be fixed, not adding a separate settings dialog) and should be able to be implemented relatively quickly without any new GUI elements, I propose I fix this aspect for Spyder 3.

  2. Separate working dir/command line options settings dialogs for the profiler and pylint If there is a genuine use case for separate settings and simply setting them temporarily in the Run Configuration dialog is too burdensome, then we (I, or someone else) can later implement separate Run-Configuration-like settings dialogs in the profiler for Spyder 4. If so, do we make them master overrides, or remember two more sets of partial per-file settings for the profiler and pylint respectively (either way, with checkboxes for each as to whether to apply them or use the per-file Run Config)?

lleeoo commented 6 years ago

I have a workaround on my mac. It makes me run the profiler twice, but it is the best I have so far.

I run from the iPython console:

!python -m cProfile -o /Users/myuid/.spyder-py3/profiler.results my_script.py
!python -m cProfile -o /Users/myuid/tmp/profiler.Result my_script.py

Note that the loader demands the extension .Result.

The first run creates a file in the default place (look under "Preferences" in case your path is different.) The second run creates a file that I can open in the Spyder Profiler page to "compare" to the first.

After the second time you can run just the second command. You can always copy your new file over the one in the standard location instead of rerunning your code twice.

I do look forward to an actual fix, though.

juanis2112 commented 4 years ago

@ccordoba12 There are really two separate, though closely related issues being discussed here.

  1. The Profiler and pylint don't respect the working dir in the run config dialog which is what both the OP and myself are asking for. The fact that they don't (like they currently do for command-line options) can be viewed as a bug and can easily break script execution in the profiler and lead to lots of erroneous errors in pylint; is much more important to fix IMO (as it is the actual problem the OP, others, and myself are asking to be fixed, not adding a separate settings dialog) and should be able to be implemented relatively quickly without any new GUI elements, I propose I fix this aspect for Spyder 3.

@ccordoba12 I think we should fix this soon because this is really confusing for users using the profiler. @CAM-Gerlach agreed to take a look at it so Im assigning him this issue

ccordoba12 commented 4 years ago

Ok, thanks @CAM-Gerlach for helping us with this one! I marked it for 4.2 because (I think) it's too late to include it in 4.1.4.

milindsmart commented 4 years ago

The first run creates a file in the default place (look under "Preferences" in case your path is different.) The second run creates a file that I can open in the Spyder Profiler page to "compare" to the first.

After the second time you can run just the second command. You can always copy your new file over the one in the standard location instead of rerunning your code twice.

I do look forward to an actual fix, though.

Thanks, this works, but I am unable to trust what it shows, because it has no refresh button. So I never know what it is comparing to. I think the profiler should allow loading of a cProfile Result without forcing users to "compare", and along with it also allow users to "reload from file". That should be a quick enough fix.

CAM-Gerlach commented 4 years ago

I think the profiler should allow loading of a cProfile Result without forcing users to "compare", and along with it also allow users to "reload from file". That should be a quick enough fix.

This sounds like a useful feature; can you open a new issue about it? Its not really related to this one, and would likely require substantially more changes than just fixing this issue properly. Thanks!