[IPython-user] profile and logplay

Johann Cohen-Tanugi cohen@slac.stanford....
Wed Jun 4 02:46:08 CDT 2008


hi Fernando, thanks for saving this old message from of oblivion....
So here is my test profile :

[cohen@jarrett test]$ more 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")

and here is the still problematic sequence :
[cohen@jarrett test]$ 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.

In [1]: os.path.exists('ipython_log.py')
Out[1]: True

In [2]:
Do you really want to exit ([y]/n)?
[cohen@jarrett test]$ 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.path.exists('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.

In [1]: os.path.exists('ipython_log.py')
---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)

/home/cohen/data1/WORK/test/<ipython console> in <module>()

NameError: name 'os' is not defined

In [2]:
Do you really want to exit ([y]/n)?
[cohen@jarrett test]$

looking at the log file I see :
[cohen@jarrett test]$ 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#-----------------------------------------------------------------------
os.path.exists('ipython_log.py')

So the 'import os' statement present in the profile does not seem to 
have been honored when the log file is replayed.... pretty weird.
I pulled out of my recent build the files ipythonrc and ipy_user_conf to 
make sure I was in synch with recent versions of these files. So I have 
a test directory with these 2 files and the ipy_profile_test.py and I 
set IPYTHONDIR to point to this test directory, which is actually not 
necessary because that is the dir I am working in.

Voila.... I still see this problem, and it is very weird because the 
*TEST* printout onscreen proves that the profile file is read back at 
replay so that the last command ip.ex("import os") should also be 
honored! Note that, though I don't understand the internals of this 
logging  mechanism, I notice that the log file does not mention that a 
specific profile was used.... which looks to me as a potential flaw, no?

thanks,
Johann

Fernando Perez wrote:
> On Thu, Feb 28, 2008 at 10:43 AM, Cohen-Tanugi, Johann
> <cohen@slac.stanford.edu> wrote:
>   
>> hello,
>>
>> I have an issue with replaying a logfile :
>> I have a test profile which imports os and that is it.
>>     
>
> [ one more of these old catchup messages that I never replied to ... :) ]
>
> With current ipython I can't reproduce this problem.  Can you try
> again, and if you still see it, could you please also post your
> profile?  I've tried the exact same steps and it works here...
>
> Thanks!
>
> f
>   


More information about the IPython-user mailing list