emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Babel more verbose?
@ 2014-09-02 12:32 Gary Oberbrunner
  2014-09-02 14:15 ` John Kitchin
  0 siblings, 1 reply; 8+ messages in thread
From: Gary Oberbrunner @ 2014-09-02 12:32 UTC (permalink / raw)
  To: Orgmode Mailing List

[-- Attachment #1: Type: text/plain, Size: 362 bytes --]

I have an org-mode babel program/document that takes about half an hour to
run (end result is a LaTeX or HTML doc with figures).  It's a mix of SQL
and python.  (The SQL is the slow part.)  I'd really like it if org-mode
could tell me, while it's running, which named block it's processing.  Is
there anything like that available?  An option perhaps?


-- 
Gary

[-- Attachment #2: Type: text/html, Size: 451 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Babel more verbose?
  2014-09-02 12:32 Babel more verbose? Gary Oberbrunner
@ 2014-09-02 14:15 ` John Kitchin
  2014-09-02 14:54   ` Nick Dokos
  0 siblings, 1 reply; 8+ messages in thread
From: John Kitchin @ 2014-09-02 14:15 UTC (permalink / raw)
  To: Gary Oberbrunner; +Cc: Orgmode Mailing List


Try this:

#+BEGIN_SRC emacs-lisp
(defadvice org-babel-execute-src-block (around progress nil activate)
  "create a buffer indicating what is running"
  (let ((code-block (org-element-property :name (org-element-at-point)))
	(cb (current-buffer)))
    (split-window-below)
    (other-window 1)
    (switch-to-buffer "*My Babel*")
    (insert (format "Running %s" code-block))
    (other-window 1)
    ad-do-it
    (kill-buffer "*My Babel*")
    (delete-other-windows)))
#+END_SRC

It will mess with your windows a bit, but it does what you want I think.


Gary Oberbrunner <garyo@oberbrunner.com> writes:

> I have an org-mode babel program/document that takes about half an
> hour to run (end result is a LaTeX or HTML doc with figures). It's a
> mix of SQL and python. (The SQL is the slow part.) I'd really like it
> if org-mode could tell me, while it's running, which named block it's
> processing. Is there anything like that available? An option perhaps?

-- 
-----------------------------------
John Kitchin
Professor
Doherty Hall A207F
Department of Chemical Engineering
Carnegie Mellon University
Pittsburgh, PA 15213
412-268-7803
http://kitchingroup.cheme.cmu.edu

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Babel more verbose?
  2014-09-02 14:15 ` John Kitchin
@ 2014-09-02 14:54   ` Nick Dokos
  2014-09-02 15:01     ` David Wagle
  2014-09-02 17:30     ` John Kitchin
  0 siblings, 2 replies; 8+ messages in thread
From: Nick Dokos @ 2014-09-02 14:54 UTC (permalink / raw)
  To: emacs-orgmode

John Kitchin <jkitchin@andrew.cmu.edu> writes:

> Try this:
>
> #+BEGIN_SRC emacs-lisp
> (defadvice org-babel-execute-src-block (around progress nil activate)
>   "create a buffer indicating what is running"
>   (let ((code-block (org-element-property :name (org-element-at-point)))
> 	(cb (current-buffer)))
>     (split-window-below)
>     (other-window 1)
>     (switch-to-buffer "*My Babel*")
>     (insert (format "Running %s" code-block))
>     (other-window 1)
>     ad-do-it
>     (kill-buffer "*My Babel*")
>     (delete-other-windows)))
> #+END_SRC
>
> It will mess with your windows a bit, but it does what you want I think.
>

Wouldn't a (message (format "Running %s" code-block)) be enough?
That would avoid all the window munging.

>
> Gary Oberbrunner <garyo@oberbrunner.com> writes:
>
>> I have an org-mode babel program/document that takes about half an
>> hour to run (end result is a LaTeX or HTML doc with figures). It's a
>> mix of SQL and python. (The SQL is the slow part.) I'd really like it
>> if org-mode could tell me, while it's running, which named block it's
>> processing. Is there anything like that available? An option perhaps?

--
Nick

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Babel more verbose?
  2014-09-02 14:54   ` Nick Dokos
@ 2014-09-02 15:01     ` David Wagle
  2014-09-02 17:23       ` Grant Rettke
  2014-09-05 13:20       ` Gary Oberbrunner
  2014-09-02 17:30     ` John Kitchin
  1 sibling, 2 replies; 8+ messages in thread
From: David Wagle @ 2014-09-02 15:01 UTC (permalink / raw)
  To: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 1704 bytes --]

It sounds like perhaps the issue is code blocks with a long run-time that
may or may not fail or hang in some way?

If that's the case, the solution is probably simply breaking up your code
blocks into smaller bits of code so that you more easily follow what's
happening.

If the code is emacs-lisp, it's easy enough to put (message ...) calls
entering and leaving the code blocks.


On Tue, Sep 2, 2014 at 9:54 AM, Nick Dokos <ndokos@gmail.com> wrote:

> John Kitchin <jkitchin@andrew.cmu.edu> writes:
>
> > Try this:
> >
> > #+BEGIN_SRC emacs-lisp
> > (defadvice org-babel-execute-src-block (around progress nil activate)
> >   "create a buffer indicating what is running"
> >   (let ((code-block (org-element-property :name (org-element-at-point)))
> >       (cb (current-buffer)))
> >     (split-window-below)
> >     (other-window 1)
> >     (switch-to-buffer "*My Babel*")
> >     (insert (format "Running %s" code-block))
> >     (other-window 1)
> >     ad-do-it
> >     (kill-buffer "*My Babel*")
> >     (delete-other-windows)))
> > #+END_SRC
> >
> > It will mess with your windows a bit, but it does what you want I think.
> >
>
> Wouldn't a (message (format "Running %s" code-block)) be enough?
> That would avoid all the window munging.
>
> >
> > Gary Oberbrunner <garyo@oberbrunner.com> writes:
> >
> >> I have an org-mode babel program/document that takes about half an
> >> hour to run (end result is a LaTeX or HTML doc with figures). It's a
> >> mix of SQL and python. (The SQL is the slow part.) I'd really like it
> >> if org-mode could tell me, while it's running, which named block it's
> >> processing. Is there anything like that available? An option perhaps?
>
> --
> Nick
>
>
>

[-- Attachment #2: Type: text/html, Size: 2598 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Babel more verbose?
  2014-09-02 15:01     ` David Wagle
@ 2014-09-02 17:23       ` Grant Rettke
  2014-09-05 13:20       ` Gary Oberbrunner
  1 sibling, 0 replies; 8+ messages in thread
From: Grant Rettke @ 2014-09-02 17:23 UTC (permalink / raw)
  To: David Wagle; +Cc: emacs-orgmode@gnu.org

I am curious about how to get more reporting when tangling is
occurring because I would like to narrow down what parts of my
document are slow to tangle so that I can refactor them and speed it
up.
Grant Rettke | ACM, ASA, FSF
gcr@wisdomandwonder.com | http://www.wisdomandwonder.com/
“Wisdom begins in wonder.” --Socrates
((λ (x) (x x)) (λ (x) (x x)))
“Life has become immeasurably better since I have been forced to stop
taking it seriously.” --Thompson


On Tue, Sep 2, 2014 at 10:01 AM, David Wagle <david.wagle@gmail.com> wrote:
> It sounds like perhaps the issue is code blocks with a long run-time that
> may or may not fail or hang in some way?
>
> If that's the case, the solution is probably simply breaking up your code
> blocks into smaller bits of code so that you more easily follow what's
> happening.
>
> If the code is emacs-lisp, it's easy enough to put (message ...) calls
> entering and leaving the code blocks.
>
>
> On Tue, Sep 2, 2014 at 9:54 AM, Nick Dokos <ndokos@gmail.com> wrote:
>>
>> John Kitchin <jkitchin@andrew.cmu.edu> writes:
>>
>> > Try this:
>> >
>> > #+BEGIN_SRC emacs-lisp
>> > (defadvice org-babel-execute-src-block (around progress nil activate)
>> >   "create a buffer indicating what is running"
>> >   (let ((code-block (org-element-property :name (org-element-at-point)))
>> >       (cb (current-buffer)))
>> >     (split-window-below)
>> >     (other-window 1)
>> >     (switch-to-buffer "*My Babel*")
>> >     (insert (format "Running %s" code-block))
>> >     (other-window 1)
>> >     ad-do-it
>> >     (kill-buffer "*My Babel*")
>> >     (delete-other-windows)))
>> > #+END_SRC
>> >
>> > It will mess with your windows a bit, but it does what you want I think.
>> >
>>
>> Wouldn't a (message (format "Running %s" code-block)) be enough?
>> That would avoid all the window munging.
>>
>> >
>> > Gary Oberbrunner <garyo@oberbrunner.com> writes:
>> >
>> >> I have an org-mode babel program/document that takes about half an
>> >> hour to run (end result is a LaTeX or HTML doc with figures). It's a
>> >> mix of SQL and python. (The SQL is the slow part.) I'd really like it
>> >> if org-mode could tell me, while it's running, which named block it's
>> >> processing. Is there anything like that available? An option perhaps?
>>
>> --
>> Nick
>>
>>
>

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Babel more verbose?
  2014-09-02 14:54   ` Nick Dokos
  2014-09-02 15:01     ` David Wagle
@ 2014-09-02 17:30     ` John Kitchin
  2014-09-03  3:58       ` Nick Dokos
  1 sibling, 1 reply; 8+ messages in thread
From: John Kitchin @ 2014-09-02 17:30 UTC (permalink / raw)
  To: Nick Dokos; +Cc: emacs-orgmode

Nick Dokos <ndokos@gmail.com> writes:

I found a message is not sufficient because I get another message from
running the code block that looks like:

Wrote
/var/folders/5q/lllv2yf95hg_n6h6kjttbmdw0000gn/T/babel-27354lYd/ob-input-27354uxF

and it obscures the first message so you cannot tell what is happening.

Here is a another approach that simply puts an overlay to change the
color of the text in the code block while running.

#+BEGIN_SRC emacs-lisp
(defadvice org-babel-execute-src-block (around progress nil activate)
  "create a buffer indicating what is running"
  (let ((ol (make-overlay (org-element-property :begin (org-element-at-point))
			  (org-element-property :end (org-element-at-point)))))

    (overlay-put ol 'face '(foreground-color . "blue"))

    ad-do-it

    (delete-overlay ol)))
#+END_SRC



> John Kitchin <jkitchin@andrew.cmu.edu> writes:
>
>> Try this:
>>
>> #+BEGIN_SRC emacs-lisp
>> (defadvice org-babel-execute-src-block (around progress nil activate)
>>   "create a buffer indicating what is running"
>>   (let ((code-block (org-element-property :name (org-element-at-point)))
>> 	(cb (current-buffer)))
>>     (split-window-below)
>>     (other-window 1)
>>     (switch-to-buffer "*My Babel*")
>>     (insert (format "Running %s" code-block))
>>     (other-window 1)
>>     ad-do-it
>>     (kill-buffer "*My Babel*")
>>     (delete-other-windows)))
>> #+END_SRC
>>
>> It will mess with your windows a bit, but it does what you want I think.
>>
>
> Wouldn't a (message (format "Running %s" code-block)) be enough?
> That would avoid all the window munging.
>
>>
>> Gary Oberbrunner <garyo@oberbrunner.com> writes:
>>
>>> I have an org-mode babel program/document that takes about half an
>>> hour to run (end result is a LaTeX or HTML doc with figures). It's a
>>> mix of SQL and python. (The SQL is the slow part.) I'd really like it
>>> if org-mode could tell me, while it's running, which named block it's
>>> processing. Is there anything like that available? An option perhaps?
>
> --
> Nick
>
>
>

-- 
-----------------------------------
John Kitchin
Professor
Doherty Hall A207F
Department of Chemical Engineering
Carnegie Mellon University
Pittsburgh, PA 15213
412-268-7803
http://kitchingroup.cheme.cmu.edu

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Babel more verbose?
  2014-09-02 17:30     ` John Kitchin
@ 2014-09-03  3:58       ` Nick Dokos
  0 siblings, 0 replies; 8+ messages in thread
From: Nick Dokos @ 2014-09-03  3:58 UTC (permalink / raw)
  To: emacs-orgmode

John Kitchin <jkitchin@andrew.cmu.edu> writes:


> I found a message is not sufficient because I get another message from
> running the code block that looks like:
>
> Wrote
> /var/folders/5q/lllv2yf95hg_n6h6kjttbmdw0000gn/T/babel-27354lYd/ob-input-27354uxF
>
> and it obscures the first message so you cannot tell what is happening.
>

Right - that seems to be quite accidental though: it is done by
write-region in ob-eval.el:org-babel--shell-command-on-region when it
writes the input file, before it is passed to the shell for execution;
hardly a significant milestone. I wonder if that call should be changed
to suppress the message, something like

      (write-region start end input-file nil 'no-message)

quite apart from the problem at hand.

--
Nick

>>> Try this:
>>>
>>> #+BEGIN_SRC emacs-lisp
>>> (defadvice org-babel-execute-src-block (around progress nil activate)
>>>   "create a buffer indicating what is running"
>>>   (let ((code-block (org-element-property :name (org-element-at-point)))
>>> 	(cb (current-buffer)))
>>>     (split-window-below)
>>>     (other-window 1)
>>>     (switch-to-buffer "*My Babel*")
>>>     (insert (format "Running %s" code-block))
>>>     (other-window 1)
>>>     ad-do-it
>>>     (kill-buffer "*My Babel*")
>>>     (delete-other-windows)))
>>> #+END_SRC
>>>
>>> It will mess with your windows a bit, but it does what you want I think.
>>>
>>
>> Wouldn't a (message (format "Running %s" code-block)) be enough?
>> That would avoid all the window munging.
>>
>>>
>>> Gary Oberbrunner <garyo@oberbrunner.com> writes:
>>>
>>>> I have an org-mode babel program/document that takes about half an
>>>> hour to run (end result is a LaTeX or HTML doc with figures). It's a
>>>> mix of SQL and python. (The SQL is the slow part.) I'd really like it
>>>> if org-mode could tell me, while it's running, which named block it's
>>>> processing. Is there anything like that available? An option perhaps?
>>
>> --
>> Nick
>>
>>
>>

-- 
Nick

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Babel more verbose?
  2014-09-02 15:01     ` David Wagle
  2014-09-02 17:23       ` Grant Rettke
@ 2014-09-05 13:20       ` Gary Oberbrunner
  1 sibling, 0 replies; 8+ messages in thread
From: Gary Oberbrunner @ 2014-09-05 13:20 UTC (permalink / raw)
  To: David Wagle; +Cc: Orgmode Mailing List

[-- Attachment #1: Type: text/plain, Size: 1699 bytes --]

On Tue, Sep 2, 2014 at 11:01 AM, David Wagle <david.wagle@gmail.com> wrote:

> It sounds like perhaps the issue is code blocks with a long run-time that
> may or may not fail or hang in some way?
>
> If that's the case, the solution is probably simply breaking up your code
> blocks into smaller bits of code so that you more easily follow what's
> happening.
>
> If the code is emacs-lisp, it's easy enough to put (message ...) calls
> entering and leaving the code blocks.
>

The defadvice idea is great; I will try it and report back.  As for
breaking up my code blocks... I wish I could, but some of my SQL queries
are just very long running.  We have a lot of data.  I want to look into
indexing and other SQL optimizations -- but I need something in my org-mode
to at least show me which blocks are the long-running ones, so I can know
where to start!

Someone else mentioned that the message about "Wrote <sql input file>"
could be suppressed; just don't forget that we users need _something_ to
help debug our babel code.  If one of my sql queries goes wrong, I get
something like this in the messages buffer:

executing Sql code block (machines-by-week)...
mysql  ... -N  < "c:/tmp/babel-26204dNc/sql-in-26204uKN" >
"c:/tmp/babel-26204dNc/sql-out-262047UT"
Wrote c:/tmp/babel-26204dNc/ob-input-26204IfZ
Babel evaluation exited with code 1

so in this case it'd be OK if the "Wrote <file>" went away, because the
entire mysql command is still there, so I can find that temp file (which
babel doesn't clean up, btw, and in my case that's a good thing!) and trace
it back to which code block it came from.

But it would be way better if mysql-mode would actually show the sql error!

-- 
Gary

[-- Attachment #2: Type: text/html, Size: 2383 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2014-09-05 13:21 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-09-02 12:32 Babel more verbose? Gary Oberbrunner
2014-09-02 14:15 ` John Kitchin
2014-09-02 14:54   ` Nick Dokos
2014-09-02 15:01     ` David Wagle
2014-09-02 17:23       ` Grant Rettke
2014-09-05 13:20       ` Gary Oberbrunner
2014-09-02 17:30     ` John Kitchin
2014-09-03  3:58       ` Nick Dokos

Code repositories for project(s) associated with this public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).