From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1.migadu.com ([2001:41d0:403:58f0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms8.migadu.com with LMTPS id mLmGNm4bu2XylwAA62LTzQ:P1 (envelope-from ) for ; Thu, 01 Feb 2024 05:17:51 +0100 Received: from aspmx1.migadu.com ([2001:41d0:403:58f0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1.migadu.com with LMTPS id mLmGNm4bu2XylwAA62LTzQ (envelope-from ) for ; Thu, 01 Feb 2024 05:17:50 +0100 X-Envelope-To: larch@yhetil.org Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=ECO9SjLn; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org"; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1706761070; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=cy1xXkkIJtt3TusCHkD5pdUOkBx3YaQPNiVV2Qvup28=; b=YGq3+CPkbLwmyy/JtH2Xer3koPTfsR8g+5EH8SLXeAY2Fvg4qMpy42MgceCwOwBMdTorQP DmSwxSiC8nnBZvC7BQw85vHebNixT41P1UjLQQglRv3Q2WrWgT+ApchvHpH0ufahB5M9ta hJQSajaq/Cdp4ULo0bUh8dkp3nxqQ8RBRabAujYzGC+BBNCL/87c4v75UANgwmOJ+/Vdxu ghZa8+8meLxRRi4S2PVL/WL8TgS63c7JpQ8mAHsYdEfv8Fj0PkIVENZp9eS7bJeePxi+7Y AZEZxO0VkJrqIVFyeAroYQPJWCD+dTzgvG/oNnN5OiIKfrmcAak7R3xaA0dx/g== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=ECO9SjLn; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org"; dmarc=pass (policy=none) header.from=gmail.com ARC-Seal: i=1; s=key1; d=yhetil.org; t=1706761070; a=rsa-sha256; cv=none; b=Cho5P1xbTFqwZesAVxh7/OMQuDre45GmrJI96vkbXEcCxKZyRftgsTqk0GxzbfS20Xmm7B RTRiucCY5DA45E7H0zhxHnAQar60F0749YrYc1t+UeApTsG9BStlEvrC7xWDCTuz7cCs+w YTJOTFpyv2eq/T3t6jT/asI1VtCm5V5VVTfmXdrIa8wDLv0EF/WeZdPCKDgGckvemY8kHE fXCxNQdXwNeNHWLawasuD7SHcOepTJUdrbdmRnXcxXjy/sBzcY71P2PvvWnjmJKTJTsxqA mbuHH0iHq2YRh06xb8ifLGEeDEdYTtrpivlmrI5bJYlMr2xEHAJWe6Bat6vl5g== 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 7EDAD5E503 for ; Thu, 1 Feb 2024 05:17:50 +0100 (CET) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rVOVX-00032l-1G; Wed, 31 Jan 2024 23:16:59 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rVOVV-00032O-Bi for emacs-orgmode@gnu.org; Wed, 31 Jan 2024 23:16:57 -0500 Received: from mail-pg1-x52f.google.com ([2607:f8b0:4864:20::52f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rVOVT-0003j6-DJ for emacs-orgmode@gnu.org; Wed, 31 Jan 2024 23:16:57 -0500 Received: by mail-pg1-x52f.google.com with SMTP id 41be03b00d2f7-5d4a1e66750so441213a12.0 for ; Wed, 31 Jan 2024 20:16:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1706761013; x=1707365813; darn=gnu.org; h=mime-version:message-id:date:references:in-reply-to:subject:cc:to :from:from:to:cc:subject:date:message-id:reply-to; bh=cy1xXkkIJtt3TusCHkD5pdUOkBx3YaQPNiVV2Qvup28=; b=ECO9SjLnG9qOr7sTtwVQriuf4QWqIBb3SCsFfF/EJGg3iHR2bsE1fak21SIWE54e1R 5JjcZNm+cofxcCv66TfVK7fB1Mpq70MRUxVslCie3G7N9cJJOMsKCfSyiyB8ZW0siwRF IZRiqCqLmGaH1FGpNIFs6VB8E/mw6xVlDFtVNLgUj8cUZjGwd35ZIG4wvCAntNYWQQN8 yPX8UjqBCOQSDaRfpH/n8BEMOKMgtlU5bGvVxeUrEcRbaS6viF0p4JRPuk9WzRlXYC2s rEt0fWOn2MzpbW+QTWPTRPPfmN6I1M5FLcWEIVQulKEfWXQhlxJO9bxAvTrA7cOtUoHU ib8w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706761013; x=1707365813; h=mime-version:message-id:date:references:in-reply-to:subject:cc:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=cy1xXkkIJtt3TusCHkD5pdUOkBx3YaQPNiVV2Qvup28=; b=gGU+3OX1nroTm2dj6l2EiDQ+3l5+QG3Zn9XlfNBRflJ7TdJ71wL/dqZK3D4Ws/YCNC 4Gj4iI2eYP6eO7l8vYWDyFyuq4qsU9S9eUePcA8Oi5aFP6lIOAP1Zu5CdJTfgUTSq0d3 PR8OpQaWLe+9RISDx+Q2LK9RsCKkTVko9McJbGzCF6FSdA+cooyzVWs1oxZhUsnvhEH0 XL20iFJCD5AK5MM2s+Wb3hg5ukw8DKUApQOXgaO3XqQG5leHeQrsc9AbszohkOV5vgpt 7rENsM24YiEVUwCGizH7aBPfUA/QXGjF9MjHnsZy8TodKTf+nBg3wVgXO9lMEwzuCtJq OISA== X-Gm-Message-State: AOJu0YxrPedyb8ZqTaAkn4sV+dl9X+PB5OT9tD6CI1/m5nnkJWS4ficq slSKpDX1voRCZRHzKXfanGw4ds3GhGYaSG+39KqQMJqjNS27Yo0umBdK3PTD X-Google-Smtp-Source: AGHT+IFOcZePUNCuh47YbOds+y6czgYLfg21QLo5HBkqMhcFbMWv1PnlTW1v446Z6jDu+UWNwaQLMQ== X-Received: by 2002:a05:6a21:3511:b0:19c:b3e7:fe39 with SMTP id zc17-20020a056a21351100b0019cb3e7fe39mr4582276pzb.0.1706761013257; Wed, 31 Jan 2024 20:16:53 -0800 (PST) X-Forwarded-Encrypted: i=0; AJvYcCVMzydcwdZOlbLphpFud5i4tq9Bo3MEltnohbYtcp4mZ3xQV+IQY7qKQboIBOOrh7ilYr6eyIsspOs+lRXjzTIGNgQOR660ag== Received: from localhost (157-131-78-143.fiber.dynamic.sonic.net. [157.131.78.143]) by smtp.gmail.com with ESMTPSA id ld7-20020a170902fac700b001d92f2129dasm2010358plb.233.2024.01.31.20.16.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 Jan 2024 20:16:52 -0800 (PST) From: Jack Kamm To: Ihor Radchenko , Nasser Alkmim Cc: emacs-orgmode@gnu.org Subject: Re: Async Python src block behavior with :dir header property In-Reply-To: <875xz9o4nj.fsf@localhost> References: <87il3a55bg.fsf@gmail.com> <8734udvjai.fsf@localhost> <86plxhely9.fsf@gmail.com> <8734udoejo.fsf@localhost> <86y1c5cztv.fsf@gmail.com> <875xz9o4nj.fsf@localhost> Date: Wed, 31 Jan 2024 20:16:51 -0800 Message-ID: <87plxg95u4.fsf@gmail.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Received-SPF: pass client-ip=2607:f8b0:4864:20::52f; envelope-from=jackkamm@gmail.com; helo=mail-pg1-x52f.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-orgmode@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: emacs-orgmode-bounces+larch=yhetil.org@gnu.org X-Migadu-Flow: FLOW_IN X-Migadu-Country: US X-Migadu-Spam-Score: -9.97 X-Migadu-Queue-Id: 7EDAD5E503 X-Spam-Score: -9.97 X-Migadu-Scanner: mx11.migadu.com X-TUID: qbsw4ZXJ4jbD --=-=-= Content-Type: text/plain Ihor Radchenko writes: > [ CCing ob-python maintainer ] > > Nasser Alkmim writes: > >> Here is a clearer description of the unwanted behavior: >> >> 1. emacs -Q ~/Desktop/testasync.org >> >> Then evaluate (require 'ob-python) and paste this source block: >> >> #+begin_src python :dir otherdir :async yes :session pysession :return figname :results file value :mkdirp yes >> import matplotlib.pyplot as plt >> plt.figure(figsize=(1, 1)) >> plt.plot([1, 2]) >> figname = 'fig.svg' >> plt.savefig(figname) >> #+end_src >> >> Execute the source block, which results in >> >> #+RESULTS: >> [[file:fig.svg]] > > I don't even see this. > Confirmed. Does the attached patch fix the issue? It seems the problem is with async sessions generally (not just ob-python), and happens because `org-babel-comint-async-filter' does not set `default-directory' before calling `org-babel-insert-result', unlike `org-babel-execute-src-block'. --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=0001-ob-comint-Make-file-results-from-async-sessions-resp.patch >From 1430a27e4416d5e88094a64360015a6a2ae7315c Mon Sep 17 00:00:00 2001 From: Jack Kamm Date: Wed, 31 Jan 2024 20:06:00 -0800 Subject: [PATCH] ob-comint: Make file results from async sessions respect :dir header * lisp/ob-comint.el (org-babel-comint-async-filter): Set default-directory before calling `org-babel-insert-result' https://list.orgmode.org/875xz9o4nj.fsf@localhost/T/#t --- lisp/ob-comint.el | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/lisp/ob-comint.el b/lisp/ob-comint.el index 7d258ea0e..ecce18a95 100644 --- a/lisp/ob-comint.el +++ b/lisp/ob-comint.el @@ -248,7 +248,14 @@ (defun org-babel-comint-async-filter (string) (let* ((info (org-babel-get-src-block-info)) (params (nth 2 info)) (result-params - (cdr (assq :result-params params)))) + (cdr (assq :result-params params))) + (tmp-file (expand-file-name tmp-file)) + (dir (cdr (assq :dir params))) + (default-directory + (if dir + (file-name-as-directory + (expand-file-name dir)) + default-directory))) (org-babel-insert-result (funcall file-callback (nth @@ -291,7 +298,13 @@ (defun org-babel-comint-async-filter (string) (let* ((info (org-babel-get-src-block-info)) (params (nth 2 info)) (result-params - (cdr (assq :result-params params)))) + (cdr (assq :result-params params))) + (dir (cdr (assq :dir params))) + (default-directory + (if dir + (file-name-as-directory + (expand-file-name dir)) + default-directory))) (org-babel-insert-result res-str result-params info)) t)))) -- 2.43.0 --=-=-=--