Question about "WARNING: Output truncated!"

110 views
Skip to first unread message

kcrisman

unread,
Jul 30, 2008, 2:09:03 PM7/30/08
to sage-support
Hi support,

I am doing a long but not difficult computation in the notebook
(v3.0.2) which yields the usual 'WARNING: Output truncated!' while it
is processing. Because I was primarily interested in the text output,
my function is just printing to the screen as it does the
calculations, not saving as an object or something. I guess that
isn't the way to do it, but it's the only way I currently know how to
do it.

The computation is going very long, and although intermittently
various bits and pieces of it show up (different ones each time), I
assume I will have to wait for the 'full_output.txt' or whatever to
show up. However, I will have to pack up and take my machine home for
the day eventually and am hesitant to 'Interrupt' the calculation
(lest it all disappear!), or to try to poke around in the actual
notebook files (lest I screw something up in accessing a file
currently being written to).

Assuming I need to turn the computer off, or at least sleep it, before
the calculation is done, is there a location I can find the *partial*
output of this calculation, which would be very helpful to me? Or, is
there pretty much no place this exists until the output is done, in
which case I would be advised to learn something about i/o and
printing to files? I am hoping that is not the case.

Thanks!

- kcrisman

William Stein

unread,
Jul 30, 2008, 2:30:29 PM7/30/08
to sage-s...@googlegroups.com

The output exists only in memory (RAM) until the calculation finishes,
in which case it is written to a file. Unfortunately the only way you
can ever see that full log is if Sage thinks the calculation finished.
There is exactly one hack that will give you what you want if you
do it right. If you kill the Python process that is actually doing the
calculation (which is probably taking up a lot of CPU resources),
then Sage will (probably) *think* that the calculation finished, and
write all the
output to a file and give you a link to the output. This will probably
work -- I tried testing it myself just now and it did.

But don't kill the sage notebook server by accident, since if you do that
then you'll loose all the output.

Good luck.

William

kcrisman

unread,
Jul 30, 2008, 3:01:14 PM7/30/08
to sage-support

>
> > Assuming I need to turn the computer off, or at least sleep it, before
> > the calculation is done, is there a location I can find the *partial*
> > output of this calculation, which would be very helpful to me?  Or, is
> > there pretty much no place this exists until the output is done, in
> > which case I would be advised to learn something about i/o and
> > printing to files?  I am hoping that is not the case.
>
> The output exists only in memory (RAM) until the calculation finishes,
> in which case it is written to a file.   Unfortunately the only way you
> can ever see that full log is if Sage thinks the calculation finished.
> There is exactly one hack that will give you what you want if you
> do it right.   If you kill the Python process that is actually doing the
> calculation (which is probably taking up a lot of CPU resources),
> then Sage will (probably) *think* that the calculation finished, and
> write all the
> output to a file and give you a link to the output.   This will probably
> work -- I tried testing it myself just now and it did.
>
> But don't kill the sage notebook server by accident, since if you do that
> then you'll loose all the output.
>

Thanks for the feedback, and interesting hack. I may try this out.

Followups:
1. What does a Sage computation (or any Terminal process) do on a Mac
when one 'sleeps' it; does it just stop, or will it
automatically continue when 'awoken'? I assume that it may interfere
with a notebook-initiated process, maybe not a Terminal-only one.
2. Is there a good place to look for how to write output of a
calculation to a file one line at a time in the Sage documentation?
That is, each new datum from the computation would use 'print' to
print to the screen for immediate feedback, and whatever I printed
would then somehow also immediately be appended to some other file
which does NOT live in RAM, but on the disk, so that I have whatever
output I get to before my computer is turned off/runs out of power/
whatever. The page http://www.sagemath.org/doc/tut/node43.html
doesn't seem relevant (this file would still have to live in RAM
first, right?) and I thought I would ask about any Sage-specific stuff
before diving into Python i/o, which I would rather avoid if
possible.

> Good luck.
>

Thanks; looks like I'll need it.

- kcrisman

John Cremona

unread,
Jul 30, 2008, 7:24:59 PM7/30/08
to sage-s...@googlegroups.com
You could try logstart. But that does not work for me. If I have the
following session:

sage: logstart sage_log
Activating auto-logging. Current session state plus future input saved.
Filename : sage_log
Mode : backup
Output logging : False
Raw input log : False
Timestamping : False
State : active
sage: for n in srange(50):
....: if n.is_prime():
....: print n
....:
2
3
5
7
11
13
17
19
23
29
31
37
41
43
47
sage:
Exiting SAGE (CPU time 0m0.02s, Wall time 0m12.31s).

Then "cat sage_log" contains:

#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,
'c': '\nimport sage.misc.misc; print
sage.misc.misc.branch_current_hg_notice(sage.misc.misc.branch_current_hg());
from sage.misc.interpreter import preparser; preparser(True);import
sage.all_cmdline; sage.all_cmdline._init_cmdline(globals());from
sage.all import Integer, RealNumber;import os;
os.chdir("/home/john");import sage.misc.interpreter;from
sage.misc.interpreter import attached_files;from sage.all_cmdline
import *;_=sage.misc.interpreter.load_startup_file("/home/john/.sage//init.sage");',
'logfile': 'sage_log'})
#log# args = []
#log# It is safe to make manual edits below here.
#log#-----------------------------------------------------------------------
import sage.misc.misc; print
sage.misc.misc.branch_current_hg_notice(sage.misc.misc.branch_current_hg());
from sage.misc.interpreter import preparser; preparser(True);import
sage.all_cmdline; sage.all_cmdline._init_cmdline(globals());from
sage.all import Integer, RealNumber;import os;
os.chdir("/home/john");import sage.misc.interpreter;from
sage.misc.interpreter import attached_files;from sage.all_cmdline
import *;_=sage.misc.interpreter.load_startup_file("/home/john/.sage//init.sage");
_ip.magic("logstart sage_log")

for n in srange(Integer(50)):
if n.is_prime():
print n

(end of file) i.e. everything *except* the output. Clearly logstart
is not doing what I hoped it would (more like gp's \l (logfile)).

John

2008/7/30 kcrisman <kcri...@gmail.com>:

Robert Bradshaw

unread,
Jul 31, 2008, 1:46:23 PM7/31/08
to sage-support

I'm not sure about getting partial output from the notebook (I assume it
can be done) but an easy solution is to do (from the command line)

$ sage script.sage > output_file.txt

which will execute script.sage and write the results (though possibly
buffered) to output_file.txt. You will be able to sleep without any
problem this way too--it will resume right where it left off.

- Robert

kcrisman

unread,
Aug 8, 2008, 1:25:33 PM8/8/08
to sage-support
Just for completeness, should someone else have the same question...

William's idea worked perfectly; it isn't hard to tell which process
is the CPU hog using 'top' in this case (if I had multiple big things
running that might not be the case). Thanks!

Robert's idea worked great as well (and is still working... it's a
looong computation). Thanks!

Postscript to Rob's idea: yes, the results must be 'buffered', because
I am getting lots of carriage returns before even seeing my first
actual result. Is there any way to get rid of that? Or, alternately,
how much of that blank space should I expect - 1 per 100 loops of
something, 1 per 100 seconds of something, no rhyme or reason, etc.?

- kcrisman

On Jul 31, 1:46 pm, Robert Bradshaw <rober...@math.washington.edu>
wrote:
Reply all
Reply to author
Forward
0 new messages