From: TEC <tecosaur@gmail.com>
To: Jack Kamm <jackkamm@gmail.com>
Cc: emacs-orgmode@gnu.org
Subject: Re: [PATCH] Async session eval (2nd attempt)
Date: Sun, 03 Jan 2021 16:51:15 +0800 [thread overview]
Message-ID: <87lfdatkys.fsf@gmail.com> (raw)
In-Reply-To: <87h7qi2l2m.fsf@gmail.com>
Hi Jack,
I love the look of this! Thanks for submitting a patch.
Sorry it's taken so long for someone to take a look at it, I think a lot
of the 'main' Org people have been pretty busy over the last few months.
I just tried to give this a shot.
First up, I had to remove the ORG-NEWS part of the patch to be able to
provide it. It would be nice if you could update the patch so this
applies cleanly.
#+begin_example
error: patch failed: etc/ORG-NEWS:88
error: etc/ORG-NEWS: patch does not apply
#+end_example
To test this, after applying your patch (with ORG-NEWS removed), I
started emacs -Q, loaded Org, and opened a new file.
I was initially unable to get this to seem to work, until I changed the
:results type to "output".
See a excerpt from my test file below:
----- excerpt start -----
#+begin_src python :async :session blah :results output
from time import sleep
a=2
sleep(2)
print("Hi")
#+end_src
#+RESULTS:
: Hi
#+begin_src python :async :session blah
return(a)
#+end_src
#+RESULTS:
: /tmp/babel-62cQRX/python-EfJ4o4
#+begin_src python :async :session blah :results output
print(a)
#+end_src
#+RESULTS:
: 2
----- excerpt end -----
I'm surprised this didn't work with the non-output block though.
Other than this, I'm rather happy to see that when I tried to execute
two long running blocks at once, the second one was not executed until
the first completed :)
Finally, I see that this requires :session to be set in order to work.
Might it be possible to have this work for non-session blocks too? It
seems odd that what I'd imagine is the harder case (session blocks) is
supported, but one-shot (non-session) blocks aren't.
Thanks again for your work, and I look forward to seeing what else you
have in the future!
--
Timothy
p.s. After this is merged, it would be great to see support for other
languages grow :)
Jack Kamm <jackkamm@gmail.com> writes:
> This patch adds asynchronous evaluation for session blocks in
> Python. It also adds functionality to implement async session eval for
> other languages using ob-comint.el.
>
> To test the attached patch, add ":async" to a Python session block
> with a long computation (or "time.sleep") in it. Upon evaluation, your
> Emacs won't freeze to wait for the result -- instead, a placeholder
> will be inserted, and replaced with the true result when it's ready.
>
> I'll note how this is different from some related projects. ob-async
> implements asynchronous evaluation for Babel, but it doesn't work with
> sessions. emacs-jupyter, ein, and ob-ipython all implement
> asynchronous session evaluation, but only for Jupyter kernels. Jupyter
> is great for some cases, but sometimes I prefer to use the built-in
> org-babel languages without jupyter.
>
> The new functionality is mainly implemented in
> `org-babel-comint-async-filter', which I've defined in ob-comint.el,
> and added as a hook to `comint-output-filter-functions'. Whenever new
> output is added to the comint buffer, the filter scans for an
> indicator token (this is inspired by
> `org-babel-comint-with-output'). Upon encountering the token, the
> filter uses a regular expression to extract a UUID or temp-file
> associated with the result, then searches for the appropriate location
> to add the result to.
>
> This is my 2nd attempt at this patch [0]. I have also ported it to an
> external package [1], but would like to have this functionality in Org
> proper, to permit better code reuse between async and sync
> implementations. The external package also includes an R
> implementation that I regularly use, as well as a Ruby implementation,
> but I've left these out to keep this initial patch smaller, and also I
> need to confirm copyright assignment on the Ruby implementation which
> was externally contributed.
>
> [0] https://orgmode.org/list/87muj04xim.fsf@jaheira.i-did-not-set--mail-host-address--so-tickle-me/
> [1] https://github.com/jackkamm/ob-session-async
next prev parent reply other threads:[~2021-01-03 9:43 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-10-25 18:54 [PATCH] Async session eval (2nd attempt) Jack Kamm
2020-10-26 2:23 ` stardiviner
2020-10-26 9:46 ` Eric S Fraga
2020-11-09 4:09 ` Kyle Meyer
2021-01-03 8:51 ` TEC [this message]
2021-02-28 22:23 ` Jack Kamm
2021-03-01 6:22 ` Timothy
2021-03-04 5:13 ` Kyle Meyer
2021-04-25 6:26 ` Timothy
2021-04-25 7:05 ` Jack Kamm
2021-04-25 12:40 ` ian martins
2021-05-18 16:18 ` Jack Kamm
2021-04-25 14:39 ` Bastien
2021-05-15 21:09 ` Bastien
2021-05-18 16:15 ` Jack Kamm
2021-05-18 16:20 ` Jack Kamm
2021-05-19 9:01 ` Bastien
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
List information: https://www.orgmode.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87lfdatkys.fsf@gmail.com \
--to=tecosaur@gmail.com \
--cc=emacs-orgmode@gnu.org \
--cc=jackkamm@gmail.com \
/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 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).