[IPython-dev] Reposting : an issue in replaying logs with profile
Johann Cohen-Tanugi
cohen at slac.stanford.edu
Fri Jun 27 05:00:26 EDT 2008
hello,
my problem below did not get addressed. Can someone help me understand
what I am doing wrong?
thanks in advance,
Johann
-------------------
hi there,
I am using a very recent bazaar build of ipython and python 2.5. I have
the following profile in my IPYTHONDIR:
[cohen at jarrett ~]$ more .ipython/ipy_profile_test.py
import IPython.ipapi
ip = IPython.ipapi.get()
ip.ex("print '*****************************************************'")
ip.ex("print '* TEST *'")
ip.ex("print '*****************************************************'")
ip.ex("import os")
I then run the following :
[cohen at jarrett ~]$ ipython -profile test -log
Activating auto-logging. Current session state plus future input saved.
Filename : ipython_log.py
Mode : rotate
Output logging : False
Raw input log : False
Timestamping : False
State : active
*****************************************************
* TEST *
*****************************************************
Python 2.5.1 (r251:54863, Oct 30 2007, 13:54:11)
Type "copyright", "credits" or "license" for more information.
IPython 0.8.4 -- An enhanced Interactive Python.
? -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help -> Python's own help system.
object? -> Details about 'object'. ?object also works, ?? prints more.
IPython profile: test
In [1]: n=5.2
In [2]: os
Out[2]: <module 'os' from '/usr/lib/python2.5/os.pyc'>
after exiting the session, the log looks like :
[cohen at jarrett ~]$ more ipython_log.py
#log# Automatic Logger file. *** THIS MUST BE THE FIRST LINE ***
#log# DO NOT CHANGE THIS LINE OR THE TWO BELOW
#log# opts = Struct({'__allownew': True, 'log': 1, 'logfile':
'ipython_log.py', 'profile': ''})
#log# args = []
#log# It is safe to make manual edits below here.
#log#-----------------------------------------------------------------------
n=5.2
os
That does *not* look good because the 'profile' value is blank, and
indeed :
[cohen at jarrett ~]$ ipython -logplay ipython_log.py
Activating auto-logging. Current session state plus future input saved.
Filename : ipython_log.py
Mode : append
Output logging : False
Raw input log : False
Timestamping : False
State : active
Replaying log...
Loading log file <ipython_log.py> one line at a time...
Finished replaying log file <ipython_log.py>
The following lines/blocks in file <ipython_log.py> reported errors:
os
Python 2.5.1 (r251:54863, Oct 30 2007, 13:54:11)
Type "copyright", "credits" or "license" for more information.
IPython 0.8.4 -- An enhanced Interactive Python.
? -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help -> Python's own help system.
object? -> Details about 'object'. ?object also works, ?? prints more.
In [1]: os
---------------------------------------------------------------------------
NameError Traceback (most recent call last)
/home/cohen/<ipython console> in <module>()
NameError: name 'os' is not defined
There was no 'TEST' banner and no importing of os, as anticipated as the
profile is not filled in the log.
Even more problematic :
[cohen at jarrett ~]$ ipython -profile test -logplay ipython_log.py
Activating auto-logging. Current session state plus future input saved.
Filename : ipython_log.py
Mode : append
Output logging : False
Raw input log : False
Timestamping : False
State : active
Replaying log...
Loading log file <ipython_log.py> one line at a time...
Finished replaying log file <ipython_log.py>
The following lines/blocks in file <ipython_log.py> reported errors:
os
Python 2.5.1 (r251:54863, Oct 30 2007, 13:54:11)
Type "copyright", "credits" or "license" for more information.
IPython 0.8.4 -- An enhanced Interactive Python.
? -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help -> Python's own help system.
object? -> Details about 'object'. ?object also works, ?? prints more.
Here the -profile argument request is not even honored....
If I add test as the profile in the log file, then I get
the correct behavior in both cases :
[cohen at jarrett ~]$ ipython -logplay ipython_log.py
Activating auto-logging. Current session state plus future input saved.
Filename : ipython_log.py
Mode : append
Output logging : False
Raw input log : False
Timestamping : False
State : active
*****************************************************
* TEST *
*****************************************************
Replaying log...
Loading log file <ipython_log.py> one line at a time...
Finished replaying log file <ipython_log.py>
Python 2.5.1 (r251:54863, Oct 30 2007, 13:54:11)
Type "copyright", "credits" or "license" for more information.
IPython 0.8.4 -- An enhanced Interactive Python.
? -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help -> Python's own help system.
object? -> Details about 'object'. ?object also works, ?? prints more.
IPython profile: test
In [1]: os
Out[1]: <module 'os' from '/usr/lib/python2.5/os.pyc'>
In [2]: n
Out[2]: 5.2000000000000002
In [3]:
Do you really want to exit ([y]/n)?
[cohen at jarrett ~]$ ipython -profile test -logplay ipython_log.py
Activating auto-logging. Current session state plus future input saved.
Filename : ipython_log.py
Mode : append
Output logging : False
Raw input log : False
Timestamping : False
State : active
*****************************************************
* TEST *
*****************************************************
Replaying log...
Loading log file <ipython_log.py> one line at a time...
Finished replaying log file <ipython_log.py>
Python 2.5.1 (r251:54863, Oct 30 2007, 13:54:11)
Type "copyright", "credits" or "license" for more information.
IPython 0.8.4 -- An enhanced Interactive Python.
? -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help -> Python's own help system.
object? -> Details about 'object'. ?object also works, ?? prints more.
IPython profile: test
In [1]: os
Out[1]: <module 'os' from '/usr/lib/python2.5/os.pyc'>
In [2]: n
Out[2]: 5.2000000000000002
So to make a long story short : there is a faulty behavior of the logger
that does not correctly save the profile used. I am trying to read the
code (Logger.py and ipilib.py seem to be the natural candidates) but if
someone finds the correct patch more quickly, I will be happy too :) .
cheers,
Johann
------------------------------------------------------------------------
More information about the IPython-dev
mailing list