-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
PR: Load history from IPython directly #7141
Conversation
Hello @impact27! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found:
Comment last updated at 2019-06-02 10:59:50 UTC |
@impact27, looks good at first glance, but we really need a test for this because it's a major internal change. You need to add it to Also, please create a new issue for this because #7080 is really solved by your other PR. |
I did some tests on this and it works. I think this is the way forward. Having the history stored per entered commands in this way could lead to great new functionality in the history explorer. The only regression is the old history had date headers, but they weren't very useful. Here's an example of the date headers plt.figure("capacity2", clear=True)
plt.plot(cycles.cycle,cycles.c_cap)
## ---(Thu May 17 15:26:14 2018)---
x
import sympy
sympy.__version__ |
@impact27, please also migrate this to the master branch. |
I opened #7142 |
The dates are saved in the ipython database so It could be added back. |
Thanks @impact27 . FYI you should Also, apparently AppVeyor on Py3 isn't able to find |
@pep8speaks suggest diff for testing purposes |
I've been testing this and it's working great. Summary of text below: I think it would be best to have one history tab per console. On a more broader view it seems like there is a lot of code here that seems to be used to get all the ipython consoles to talk to one history tab so it mimics the way the previous code worked. From a use case prospective I think this isn't a good idea to have the history mixed and it would be better and simpler to have IPython take care of the history entirely. We can just take what the console gives not worry about it...it works great. This would require us to have one history tab per console, but luckily the history widget already has tabs implemented. Currently, If you change between tabs and run commands in each the history gives you a mess of code that is most likely unassociated and you can tell what commands were executed in each console. The up arrow history at the ipython prompt keeps the history separate and when both sessions are closed the two histories are appended into the main history one console after the other so the code is still in blocks that are still associated. The hardest part would be to synchronize the tab switching between the consoles and the history. I would open a new issue but this idea would greatly impact this work. |
@impact27, as @CAM-Gerlach suggested, please rebase this PR in top of latest master. Your merge was really unnecessary. |
Great!
What if we use a QStackedWidget instead to only display the history of the current console, but change to another history when users select a different console? That's what we do in the Variable Explorer and I think it works quite well.
Please do. We can work on it after this PR is merged. |
The only disadvantage there, that isn't the case for the variable explorer, is if a user wants to view or copy one console's history while working in another. It could be solved by a "lock" toggle locking the history shown to that of the currently selected console (like the one for Help). However, we'd then need to implement tabs in the history log like we have in the console to navigate between different console's logs independently, so not sure if the different use cases that require it would be worth the effort at this point. |
@CAM-Gerlach, we can still use a QStackedWidget widget and an option that allows users to select the console's history they want to see at the moment (but that would be changed to the current console as soon as they change consoles). I really don't want to use tabs for this because I really think it makes no sense. In any case, please stop discussing that in this PR (because it's unrelated to @impact27's work) and open a new issue about it. |
Sorry 😮 @bcolsen was the one with the detailed proposal above and said he could create the new issue, so I'll await that unless he wants me to do it—I don't want to get in his way there. |
No worries, I just didn't want us to keep polluting this PR ;-) |
I rebased the pull request |
spyder/app/mainwindow.py
Outdated
@@ -1261,7 +1261,9 @@ def post_visible_setup(self): | |||
|
|||
# Show history file if no console is visible | |||
if not self.ipyconsole.isvisible: | |||
self.historylog.add_history(get_conf_path('history.py')) | |||
self.historylog.add_history( | |||
"iPython history", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's call this simply History
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, its a moot point now but just for the record, its IPython
—they are actually pretty emphatic on that distinction.
spyder/plugins/console.py
Outdated
Not used anymore since v2.0""" | ||
historylog.add_history(self.shell.history_filename) | ||
self.shell.append_to_history.connect(historylog.append_to_history) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This needs to stay. It's used to save and load history in the internal console. So please put it back it.
spyder/plugins/history.py
Outdated
#------ Public API --------------------------------------------------------- | ||
def add_history(self, filename): | ||
def add_history(self, filename, history_list): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
history_list
must be optional, so that history in the internal console can still work.
spyder/plugins/ipythonconsole.py
Outdated
client.append_to_history.connect(self.historylog.append_to_history) | ||
|
||
self.historylog.add_history( | ||
"iPython history", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please change this to History
@impact27, this looks good, but you need to preserve saving history in the internal console. |
@impact27 Looks like this got hit big-time by the split-plugins merge. Are you interested in finishing it? With regard to your question, I'm not really sure why there need be a tab in the History log for Internal Console history, considering it is only used for testing and introspecting Spyder itself rather than production work, and can in any case still be accessed inside the internal console's one pane anyway, but even so it looks like it still works just fine. |
Unfortunately I don't really have time these days. Does somebody else want to finish that? |
I'll finish it. I'll implement the QStackedWidget solution I proposed some time ago. |
@ccordoba12 @impact27 Hey, is this ever going to be finished? A lot of conflicting files have built up over the time this has been sitting around... |
@ccordoba12 thoughts on this? Do you want some of the other devs to tackle this at some point? |
We'll take another look after we release beta2. |
@impact27, could you update and finish this PR? For now let's go with my proposed approach, i.e. showing the history of the current console when switching from one to another. |
I rebase it on the master and it still works, but I am not sure how to do the |
Thanks a lot for that!
Ok, no problem. We'll help you with that part then. |
Closing because too many conflicts accumulated and this would need a rewrite |
Pull Request Checklist
modified the
spyder/defaults
directory, or added new icons/assetsDescription of Changes
Spyder now loads the history from iPython instead of duplicating the history in a local file.
That is less confusing for the user as the history in iPython and the history in historylog are now the same.
Issue(s) Resolved
Fixes #7142