Skip to content
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

Add options to not include runfile, execute a cell and run selsection in the history #7233

Open
bcolsen opened this issue May 31, 2018 · 3 comments

Comments

@bcolsen
Copy link
Member

bcolsen commented May 31, 2018

There could be options in the history preferences to include run file, run cells and run selections events in the history.

Something like:

Save in History:
[x] Run Files
[x] Run Cells
[x] Run Selections

If the option is unchecked the commands would still show up in the shell when they run but there would be no entry in the history or in the previous commands (the up arrow)

I thought I would split this off from #7113

When #7141 gets merged the solution could look something like running this after the command is executed.

hismgr = self.kernel_client.history_manager
session_id = hismgr.get_last_session_id()
line = self.kernel_client.history_accessor.get_tail(1, include_latest=True)[1]
hismgr.db.execute('DELETE FROM history WHERE line={0} and session={1}'.format(line, session_id))

This is untested and isn't really skipping the history, more like undoing it. I think this might be all we can do without patching IPython.

There is a "store_history" option in the ipython execute which sounds promising but it is functionally equivalent to "silent". It doesn't show the command in the console and the "busy" status isn't activated.

The best option I suppose would be to get an option on IPython execute to skip the history.

@ccordoba12
Copy link
Member

ccordoba12 commented May 31, 2018

@bcolsen, I don't think you proposal is feasible as it is because if two evaluations in different consoles finish at the same time, trying to delete their entries in the global history could corrupt the database.

Maybe there's an option to tell IPython: don't save history for this evaluation.

@bcolsen
Copy link
Member Author

bcolsen commented May 31, 2018

I don't think you proposal is feasible as it is because if two evaluations in different consoles finish at the same time

The history for each console would need to be separate for this to work(which they are already) but I think that's the best way forward at this point. We would just need to be sure to have the right session id for the console. I think the get line is actually unnecessary because we should already know this.

Maybe there's an option to tell IPython: don't save history for this evaluation.

That would be ideal. Is this something that can be done in qtconsole? I had a look at the hidden option there but it was more like silent.

@ccordoba12
Copy link
Member

The history for each console would need to be separate for this to work(which they are already) but I think that's the best way forward at this point.

The cached history is different but there's only one history database for all IPython sessions.

Is this something that can be done in qtconsole?

If it's possible, it should be available in IPython, not qtconsole.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants