From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id KHLKLC5XSl+2YwAA0tVLHw (envelope-from ) for ; Sat, 29 Aug 2020 13:25:02 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1 with LMTPS id YPaFKC5XSl9EZAAAbx9fmQ (envelope-from ) for ; Sat, 29 Aug 2020 13:25:02 +0000 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 879ED9403EC for ; Sat, 29 Aug 2020 13:25:01 +0000 (UTC) Received: from localhost ([::1]:34524 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kC0qp-0006Rj-0d for larch@yhetil.org; Sat, 29 Aug 2020 09:24:59 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53996) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kC0pz-0006QF-Ov for emacs-orgmode@gnu.org; Sat, 29 Aug 2020 09:24:07 -0400 Received: from pb-smtp20.pobox.com ([173.228.157.52]:63030) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kC0px-0000O0-4v for emacs-orgmode@gnu.org; Sat, 29 Aug 2020 09:24:07 -0400 Received: from pb-smtp20.pobox.com (unknown [127.0.0.1]) by pb-smtp20.pobox.com (Postfix) with ESMTP id E0329DF755; Sat, 29 Aug 2020 09:24:01 -0400 (EDT) (envelope-from kyle@kyleam.com) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=pobox.com; h=from:to:cc :subject:in-reply-to:references:date:message-id:mime-version :content-type; s=sasl; bh=vKe4/f4Ox1V/oGTwcEwdHvl1dBA=; b=wjpUxK bgjU04MuNGF2jDsY7V8fdcCK13mF1n6CYFiIk4nK1nU3jDb5Tbx2FYbA+g07yV/O fHDxPyknyD1GSD0jaA0SpoaWxnQju1dv+SNu0j7/ifFvU+Zx0GptriGfQfx41jSG KWDE1BhkDynL6cYL4NUidYg++RrOQFjUiVVMI= Received: from pb-smtp20.sea.icgroup.com (unknown [127.0.0.1]) by pb-smtp20.pobox.com (Postfix) with ESMTP id DAB60DF754; Sat, 29 Aug 2020 09:24:01 -0400 (EDT) (envelope-from kyle@kyleam.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed; d=kyleam.com; h=from:to:cc:subject:in-reply-to:references:date:message-id:mime-version:content-type; s=mesmtp; bh=gL9zzsLg9GP88StFItn0tpEU8FhzDy6FtVCXihUawJU=; b=vf886z9ehPT1050PqRD40bd/iNBsploBAxTFcif5u4228AXquVfOfNJGocEEAnMkYk2ooRmBfO2qWMbPS0PYs23wn9b8cnxoXE434R/bCi8Jt7Lu0sfSPPgKgeLDbPNeBdAipXSHK1Fme7/ijuSqoyZtMSg2AS8DAGeEXyZoxJk= Received: from localhost (unknown [45.33.91.115]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by pb-smtp20.pobox.com (Postfix) with ESMTPSA id 58403DF752; Sat, 29 Aug 2020 09:23:59 -0400 (EDT) (envelope-from kyle@kyleam.com) From: Kyle Meyer To: Jack Kamm Subject: Re: [RFC] ob-reticulate: R+Python interface from Babel In-Reply-To: <875z98gj4f.fsf@gmail.com> References: <875z98gj4f.fsf@gmail.com> Date: Sat, 29 Aug 2020 09:23:57 -0400 Message-ID: <87k0xhshzm.fsf@kyleam.com> MIME-Version: 1.0 Content-Type: text/plain X-Pobox-Relay-ID: E5BE7272-E9FA-11EA-9AA3-F0EA2EB3C613-24757444!pb-smtp20.pobox.com Received-SPF: pass client-ip=173.228.157.52; envelope-from=kyle@kyleam.com; helo=pb-smtp20.pobox.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/08/29 08:07:47 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-orgmode@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: emacs-orgmode@gnu.org Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: "Emacs-orgmode" X-Scanner: scn0 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=pobox.com header.s=sasl header.b=wjpUxK b; dkim=pass header.d=kyleam.com header.s=mesmtp header.b=vf886z9e; dmarc=none; spf=pass (aspmx1.migadu.com: domain of emacs-orgmode-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=emacs-orgmode-bounces@gnu.org X-Spam-Score: -1.21 X-TUID: +6bOiYGb/sxK Jack Kamm writes: > Hi all, > > Reticulate is an R package for interfacing between R and Python. It > allows accessing objects in a Python session from R and vice > versa. See https://rstudio.github.io/reticulate/ for more info about > it. > > I've written a small patch for using reticulate from org-babel. It > allows creating a source block of lang "reticulate", which behaves as > Python for font highlighting and editing, but is executed in an R > session via reticulate. Neat, thanks for sharing. > I'm wondering whether this should go into org-mode, or whether to > package this separately. I'm also curious whether this would be useful > to anyone here. Any feedback is appreciated. It'd be good to hear from others, but in my view this would be fine to add to Org proper. I will say that in general new Babel libraries make me nervous. My impression is that Babel brings in a good number of bug reports, and a new library is adding surface to that area [*] while not necessarily adding eyes and hands. Of course that worry doesn't apply here, as you're already taking care of ob-python. [*] And that surface can be quite challenging to deal with because it is not just Elisp code; it brings in a whole outside language that other developers may have no clue about. > +;;; Code: > + > +(require 'ob-R) > +(require 'ob-python) > + > +(defalias 'org-babel-edit-prep:reticulate 'org-babel-edit-prep:R) > + > +(defun org-babel-execute:reticulate (body params) > + (let* ((tmp-src-file (org-babel-temp-file "reticulate-")) > + (result-type (cdr (assq :result-type params)))) > + (with-temp-file tmp-src-file (insert body)) > + (org-babel-execute:R > + (format (concat "reticulate::py_run_string(\"%s\")" > + (when (equal result-type 'value) " > +reticulate::py$`__org_babel_python_final`")) > + (format org-babel-python--eval-ast > + (org-babel-process-file-name > + tmp-src-file 'noquote))) > + params))) > + > +(provide 'ob-reticulate) Well, that's pleasantly few lines of code :)