all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Eric Schulte <schulte.eric@gmail.com>
To: Eric Schulte <schulte.eric@gmail.com>
Cc: Achim Gratz <Stromeko@nexgo.de>, emacs-orgmode@gnu.org
Subject: Re: [PATCH] * lisp/ob-core.el (org-babel-execute-src-block): insert hash for silent results
Date: Sat, 09 Mar 2013 13:26:09 -0700	[thread overview]
Message-ID: <87y5dwpbfi.fsf@gmail.com> (raw)
In-Reply-To: <87li9wcr9e.fsf@gmail.com> (Aaron Ecay's message of "Sat, 09 Mar 2013 14:22:37 -0500")

>> 
>> As I understand this particular case, the OP is using a hash not to mark
>> a result as up to date, but rather to mark a side effect (loading data
>> into R) as having taken place.  I think this is a misuse of a cache.
>
> It depends on whether one looks at a cache as “a place to store results”
> or “a way to conditionally rerun code blocks only when they change”, I
> suppose.  I guess you hold with the former; I think the latter is a
> useful conceptual extension.  Knitr (http://yihui.name/knitr/) is a very
> useful literate programming tool for R, and it supports “caching” code
> with side-effects using clever means.  I don’t think org should do all
> the tricks knitr does, but it would be useful to be able to
> conditionally reexecute code with no results/with side effects.
>

Could something like the following work?  Removing ":results none" and
adding something small as the returned result which may easily be parsed
and placed in the buffer w/o problem.

    #+begin_src R :cache yes
      # code to perform side effect
      x <- 'side effect'
      'done'
    #+end_src

    #+RESULTS[9f4e5b4b07e93c680ab37fc4ba1f75e1bfc0ee0a]:
    : done

>
>> 
>> What if the R process restarts?  The hash would still be valid, but the
>> side effects have been lost.
>
> This is also an issue if the external data files have changed, the RNG
> seed is no longer the same, etc.  In such cases, the user has to be
> clever.  But the same is true of any cached code that is not a pure
> function.
>
> In practice, if the R process is restarted the “variable not found”
> errors quickly become apparent, and reloading the data is a simple C-u
> C-c C-c away.
>
> (That being said, including the PID of the R process in the results
> hash, to the effect that the code would be rerun in the case you
> mention, might not be a bad idea.  But that is a separate discussion.)

This does not need special built in support, e.g.,

    #+name: R-pid
    #+begin_src sh :var R="/usr/lib64/R/bin/exec/R"
      ps auxwww|grep "$R"|grep -v 'grep'|awk '{print $2}'
    #+end_src

    #+begin_src R :cache yes :var pid=R-pid
      # code to perform side effect
      x <- 'side effect'
      'done'
    #+end_src

    #+RESULTS[da16f09882a6295815db51247592b77c80ed0056]:
    : done

Best,

-- 
Eric Schulte
http://cs.unm.edu/~eschulte

  reply	other threads:[~2013-03-09 20:26 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-03-06  4:07 [PATCH] * lisp/ob-core.el (org-babel-execute-src-block): insert hash for silent results Aaron Ecay
2013-03-08 21:25 ` Aaron Ecay
2013-03-08 22:07   ` Eric Schulte
2013-03-08 21:53 ` Achim Gratz
2013-03-08 22:09   ` Eric Schulte
2013-03-08 22:24     ` aaronecay
2013-03-09 17:45       ` Eric Schulte
2013-03-09 18:56         ` Aaron Ecay
2013-03-09 20:03         ` Achim Gratz
2013-03-09  0:57     ` Achim Gratz
2013-03-09 18:35       ` Eric Schulte
2013-03-09 19:22         ` Aaron Ecay
2013-03-09 20:26           ` Eric Schulte [this message]
2013-03-13  3:55             ` Aaron Ecay
2013-03-13 14:45               ` Eric Schulte
2013-03-19  4:49                 ` Aaron Ecay
2013-03-23 22:34                   ` Eric Schulte
2013-04-01  5:10                     ` Aaron Ecay
2013-04-02 22:14                       ` Eric Schulte
2013-03-10  8:52         ` Achim Gratz
2013-03-10 20:14           ` Sebastien Vauban
2013-03-10 21:06             ` Achim Gratz
2013-03-13  4:12           ` Aaron Ecay
2013-03-13  7:50             ` Achim Gratz
2013-03-13 14:42             ` Eric Schulte
2013-03-13 18:25               ` Achim Gratz
2013-03-14 19:52                 ` Eric Schulte

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87y5dwpbfi.fsf@gmail.com \
    --to=schulte.eric@gmail.com \
    --cc=Stromeko@nexgo.de \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.