Re: [sage-support] sagetex: granular builds for large documents

2009-12-01 Thread Dan Drake
On Tue, 01 Dec 2009 at 11:44AM -0800, Eric Drechsel wrote:
> I'm experimenting with a homework workflow using sagetex. I'd like to
> make efficient use of resources, which seems to be a (the?) major
> deficiency with sagetex, especially with large documents.
> 
> My initial thought was that by placing each problem in an included
> file, I could have my build tool generate individual problem_x.sage
> and problem_x.sout files only for problems with changes, and keep the
> master tex file as a simple list of includes. I see now that that
> can't work, however, at least with my limited knowledge of TeX tricks.

BTW, if your build tool is Latexmk [1] (which is included in TeXLive), I
wrote a "custom dependency rule" that makes it work intelligently with
SageTeX: put this into your .latexmkrc and it will run Sage as
necessary.

-
# a SageTeX custom dependency rule for latexmk

add_cus_dep('sage', 'sout', 0, 'makesout');

sub makesout {
my $oldmd5 = "x";
my $currentmd5 = (split / /,
  `egrep -v '^( _st_.goboom|print .SageT)' $_[0].sage | md5sum`)[0];
open(INFILE, "$_[0].sout");
while () {
if (/^%([0-9a-f]{32})%/) {
$oldmd5 = $1;
}
}
if ($currentmd5 ne $oldmd5) {
system("sage $_[0].sage");
}
else {
print "md5sums for $_[0].sage and $_[0].sout match, not running Sage\n";
return 0;
}
}
-

I'm very much not a Perl person, so that may not be the best way to do
it, but it seems to work well.

Dan

  1. http://www.phys.psu.edu/~collins/software/latexmk-jcc/
-- 
---  Dan Drake
-  http://mathsci.kaist.ac.kr/~drake
---


signature.asc
Description: Digital signature


Re: [sage-support] sagetex: granular builds for large documents

2009-12-01 Thread Dan Drake
Hi Eric,

On Tue, 01 Dec 2009 at 11:44AM -0800, Eric Drechsel wrote:
> I'm experimenting with a homework workflow using sagetex. I'd like to
> make efficient use of resources, which seems to be a (the?) major
> deficiency with sagetex, especially with large documents.
> 
> My initial thought was that by placing each problem in an included
> file, I could have my build tool generate individual problem_x.sage
> and problem_x.sout files only for problems with changes, and keep the
> master tex file as a simple list of includes. I see now that that
> can't work, however, at least with my limited knowledge of TeX tricks.
> 
> So I'm asking the group for ideas. Starters:
> 
>  1. Is it possible to have a master document that includes a bunch of
> complete subdocuments? If so, one could simply keep the master
> document clean of sagetex references, and build each subdocument
> separately.

My first thought is, if you're talking about using a master document and
compile times for your homework...you have way too much homework. :)

I don't know about keeping the master document clean of SageTeX
references, but by using \include, you can keep things separated, and
you can even compile only part of the document using \includeonly.

One thing you can do with SageTeX to make things go faster is to use the
pause and unpause commands -- \sagetexpause and \sagetexunpause.
Commands between those two don't get run when you run Sage on the .sage
file. (SageTeX literally just comments those sections out in the .sage
file.) 

Actually, with the stuff I've done, the most time-consuming part of
running Sage on the .sage file is simply startup time. Once it starts
executing the commands, it generally goes really fast, but starting Sage
takes a while.

I'll think about your per-file ideas, and about some kind of
\includeonly stuff. Right now, though, it works document-wide.

What would you like to see? Can you describe some commands or
functionality that you would find helpful?

Dan

-- 
---  Dan Drake
-  http://mathsci.kaist.ac.kr/~drake
---


signature.asc
Description: Digital signature


[sage-support] sagetex: granular builds for large documents

2009-12-01 Thread Eric Drechsel
Hi Dan, others using sagetex

I'm experimenting with a homework workflow using sagetex. I'd like to
make efficient use of resources, which seems to be a (the?) major
deficiency with sagetex, especially with large documents.

My initial thought was that by placing each problem in an included
file, I could have my build tool generate individual problem_x.sage
and problem_x.sout files only for problems with changes, and keep the
master tex file as a simple list of includes. I see now that that
can't work, however, at least with my limited knowledge of TeX tricks.

So I'm asking the group for ideas. Starters:

 1. Is it possible to have a master document that includes a bunch of
complete subdocuments? If so, one could simply keep the master
document clean of sagetex references, and build each subdocument
separately.
 2. Could sagetex be modified to work on a per-file level?

Thanks,
Eric

-- 
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support-unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org