From mboxrd@z Thu Jan 1 00:00:00 1970 From: Michael Hannon Subject: Re: Question about using :cache in Babel (for R) Date: Tue, 27 Sep 2011 20:14:32 -0700 (PDT) Message-ID: <1317179672.25512.YahooMailNeo@web161912.mail.bf1.yahoo.com> References: <1317156800.22065.YahooMailNeo@web161912.mail.bf1.yahoo.com> <87vcsdwl79.fsf@gmail.com> Reply-To: Michael Hannon Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="1923625488-475164961-1317179672=:25512" Return-path: Received: from eggs.gnu.org ([140.186.70.92]:39831) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R8kbS-0003Te-OL for emacs-orgmode@gnu.org; Tue, 27 Sep 2011 23:14:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1R8kbQ-0000aJ-VM for emacs-orgmode@gnu.org; Tue, 27 Sep 2011 23:14:34 -0400 Received: from nm32-vm5.bullet.mail.bf1.yahoo.com ([72.30.239.141]:31430) by eggs.gnu.org with smtp (Exim 4.71) (envelope-from ) id 1R8kbQ-0000aD-QY for emacs-orgmode@gnu.org; Tue, 27 Sep 2011 23:14:32 -0400 In-Reply-To: <87vcsdwl79.fsf@gmail.com> List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Eric Schulte Cc: Org-Mode List --1923625488-475164961-1317179672=:25512 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable Thanks, Eric. =A0That's very clear. =A0(This is a great list.)=0A=0A-- Mike= =0A=0A=0A=0A>________________________________=0A>From: Eric Schulte =0A>To: Michael Hannon =0A>Cc: Org-Mo= de List =0A>Sent: Tuesday, September 27, 2011 5:42 P= M=0A>Subject: Re: [O] Question about using :cache in Babel (for R)=0A>=0A>M= ichael Hannon writes:=0A>=0A>> Greetings. =A0I have a= question that relates to the use of the :cache option in=0A>> Babel sessio= ns using R.=0A>>=0A>> Here's the relevant configuration information:=0A>>= =0A>> =A0 =A0 Emacs =A0: GNU Emacs 23.2.1 (x86_64-redhat-linux-gnu, GTK+ Ve= rsion 2.24.4)=0A>> =A0 =A0 =A0of 2011-05-23 on x86-12.phx2.fedoraproject.or= g=0A>> =A0 =A0 Package: Org-mode version 7.7 (release_7.7.328.g1a97)=0A>>= =0A>> I've appended the text of a file that exhibits the issue, which is th= e=0A>> following. =A0If I explicitly evaluate a given code block, using, le= t's say, C-c=0A>> C-c, I get the results stuck into the Org file, as in the= first source-code=0A>> block below. =A0If I then repeatedly export the fil= e (to PDF, HTML, etc.), I get=0A>> the cached results in the exported docum= ent. =A0For instance, the mean of the=0A>> random variable does not change = as I repeatedly export the file.=0A>>=0A>> If for some reason I have NOT ex= plicitly evaluated a given code block, as with=0A>> the second code block b= elow, then during export I see a message "Evaluating=0A>> code block" (or s= imilar), indicating that Babel is NOT using a cached version,=0A>> and no c= acheable output is produced as a result, meaning that the entire=0A>> calcu= lation will be repeated during the next export. =A0For instance, the mean= =0A>> of the random variable will be different every time I export the file= .=0A>>=0A>=0A>Hi Mike,=0A>=0A>This is the expected behavior.=A0 Org-mode fi= les are just plain text, so=0A>if the results are not saved in the Org-mode= file then there is no place=0A>to cache them.=A0 Since Org does not change= the contents of Org-mode files=0A>the only way to save the result of a cod= e block is to interactively=0A>evaluate the code block -- there is no way t= o generate and save cached=0A>results during export.=0A>=0A>>=0A>> I guess = I can see the logic of this, but I wonder if there is some way to=0A>> inst= ruct Babel to automatically cache the output of any code blocks it=0A>> eva= luates, i.e., via a header argument or elisp variable or ... .=0A>>=0A>=0A>= Nope, in the past we have played with things like an in-memory variable,=0A= >but have abandoned such things as they would move away from the "just=0A>p= lain text" spirit of Org-mode, would require external storage on disk,=0A>a= nd could ultimately lead to more confusing behavior than the current=0A>sit= uation.=0A>=0A>>=0A>> Thanks,=0A>>=0A>> -- Mike=0A>>=0A>> P.S. Is the SHA1(= ?) identifier for the results a new feature?=0A>>=0A>=0A>No, this is how Ba= bel knows if the contents of the code block have=0A>changed and hence if th= e cached results are still valid.=0A>=0A>Best -- Eric=0A>=0A>>=0A>> -------= ---=0A>>=0A>> #+TITLE:=A0=0A>> #+AUTHOR:=0A>> #+DATE:=0A>>=0A>> #+STARTUP: = hideblocks=0A>> #+BABEL: :session *R* :cache yes :results output verbatim := exports both=0A>> :tangle yes=0A>>=0A>> * This is a test=0A>>=0A>> #+begin_= src R=0A>>=0A>>=A0 x =3D rnorm(10)=0A>>=A0 mean(x)=0A>>=0A>> #+end_src=0A>>= =0A>> #+results[9b9372488662083d0d211b9aad9c2985faba20cd]:=0A>> : [1] -0.07= 904561=0A>>=0A>> * Here's a second test=0A>>=0A>> #+begin_src R=0A>>=0A>>= =A0 x =3D rnorm (50)=0A>>=A0 summary(x)=0A>>=0A>> #+end_src=0A>=0A>-- =0A>E= ric Schulte=0A>http://cs.unm.edu/~eschulte/=0A>=0A>=0A>=0A> --1923625488-475164961-1317179672=:25512 Content-Type: text/html; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable
Thanks, Eric.  Tha= t's very clear.  (This is a great list.)

-- Mike


From: Eric Schulte <schulte.eric@g= mail.com>
To: Michae= l Hannon <jm_hannon@yahoo.com>
Cc: Org-Mode List <emacs-orgmode@gnu.org>
Sent: Tuesday, September 27, 2011 5:= 42 PM
Subject: Re: [O] Qu= estion about using :cache in Babel (for R)

Michael Hannon <= ;jm_hannon@yahoo.com> writes:

> Greetings.  I have= a question that relates to the use of the :cache option in
> Babel s= essions using R.
>
> Here's the relevant configuration informat= ion:
>
>     Emacs  : GNU Emacs 23.2.1 (x86_64-r= edhat-linux-gnu, GTK+ Version 2.24.4)
>      of 2011-0= 5-23 on x86-12.phx2.fedoraproject.org
>     Package: Org-mo= de version 7.7 (release_7.7.328.g1a97)
>
> I've appended the te= xt of a file that exhibits the issue, which is the
> following.  = ;If I explicitly evaluate a given code block, using, let's say, C-c
>= C-c, I get the results stuck into the Org file, as in the first source-code
> block below.  If I then repeatedly export the fil= e (to PDF, HTML, etc.), I get
> the cached results in the exported do= cument.  For instance, the mean of the
> random variable does no= t change as I repeatedly export the file.
>
> If for some reaso= n I have NOT explicitly evaluated a given code block, as with
> the s= econd code block below, then during export I see a message "Evaluating
&= gt; code block" (or similar), indicating that Babel is NOT using a cached v= ersion,
> and no cacheable output is produced as a result, meaning th= at the entire
> calculation will be repeated during the next export. =  For instance, the mean
> of the random variable will be differe= nt every time I export the file.
>

Hi Mike,

This is the= expected behavior.  Org-mode files are just plain text, so
if the = results are not saved in the Org-mode file then there is no place
to cache them.  Since Org does not change the contents of Or= g-mode files
the only way to save the result of a code block is to inter= actively
evaluate the code block -- there is no way to generate and save= cached
results during export.

>
> I guess I can see the= logic of this, but I wonder if there is some way to
> instruct Babel= to automatically cache the output of any code blocks it
> evaluates,= i.e., via a header argument or elisp variable or ... .
>

Nope= , in the past we have played with things like an in-memory variable,
but= have abandoned such things as they would move away from the "just
plain= text" spirit of Org-mode, would require external storage on disk,
and c= ould ultimately lead to more confusing behavior than the current
situati= on.

>
> Thanks,
>
> -- Mike
>
> P.S= . Is the SHA1(?) identifier for the results a new feature?
>

No, this is how Babel knows if the contents of the= code block have
changed and hence if the cached results are still valid= .

Best -- Eric

>
> ----------
>
> #+TITL= E: 
> #+AUTHOR:
> #+DATE:
>
> #+STARTUP: hideb= locks
> #+BABEL: :session *R* :cache yes :results output verbatim :ex= ports both
> :tangle yes
>
> * This is a test
>
= > #+begin_src R
>
>  x =3D rnorm(10)
>  mean= (x)
>
> #+end_src
>
> #+results[9b9372488662083d0d2= 11b9aad9c2985faba20cd]:
> : [1] -0.07904561
>
> * Here's = a second test
>
> #+begin_src R
>
>  x =3D rno= rm (50)
>  summary(x)
>
> #+end_src

--
Er= ic Schulte
http://cs.unm.edu/~eschulte/



--1923625488-475164961-1317179672=:25512--