New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Configure babel blocks for each kernel #74
Conversation
Use cases: - Start an ipython kernel on a server with lots of ram and cpu and connect it to local lightweight machine running emacs. - Ipython kernel launched by some tool. My team have a tool that configures ipython session and configuration can't simply be added to profile_default. I considered passing additional argument, but simply naming session with connection json is simple solution that works well. I am running it in my emacs and it works. To test: 1. Start ipython session outside of org mode with: import os from ipykernel.kernelapp import IPKernelApp app = IPKernelApp.instance() app.initialize([]) kernel = app.kernel kernel.shell.push({'print_me': 'Running in previously started kernel.'}) app.start() 2. Get json from previous command and name a session after your json file. For example: #+BEGIN_SRC ipython :session kernel-8520.json
I would prefer to wrap these in an interactive function and let the user decide whether use it or not. |
ob-ipython.el
Outdated
(set (intern (format "org-babel-default-header-args:jupyter-%S" | ||
(intern (car (cdr x))))) | ||
`((:session . ,(car (cdr x))) | ||
(:kernel . ,(symbol-name (car x))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not use a variable to store the language? These 'cadr' calls appear many times.
Thanks so much for the PR. I like the idea! Let me dig in to this and check it out. I've got a backlog of PRs so you'll have to bear with me. |
I cleaned things up following the feedback from @jiegec. Still probably not ready for prime time in terms of code quality, but closer. |
Snippet of code to active 'ob-ipython' in org-babel
Update readme
Opportunistically interpret output as a table.
When text output is beyond a certain length, the result supplied from Jupyter can be incomplete. With the IHaskell Jupyter backend, at least, It turns out this is because the alist can have mulitple 'text/plain key-value pairs in the alist, where earlier values are strict prefixes of later onces. Reversing the alist before applying assoc gives us the final, complete text output.
We support 5.0 and later only.
Any word on this? I'd really love to make use of this feature. I don't have a lot of know how about org-babel or jupyter but I'm willing to learn if that means this feature will be available. I just don't want to duplicate effort... |
Document ox-latex + minted source block lexer workaround
pass extra arguments to ipython kernel
…e paramter for src block and for exporing image output to file use :async-file file.png Fix list and temp file handling on error Better handling on error
Use result parameters from a source block when replacing sentinel
No longer do you have to provide files. With pandoc, tables (for example) get rendered to org.
I rebased on current master in preparation for additional cleanup/documentation etc. |
Finally merged as part of #138. This is so good. Thanks for working on this. |
This is a first pass at addressing some of the goals in #57. Specifically it
jupyter-<language>
entries toorg-src-lang-modes
for each detected kernelkernel
mresults
andsession
values for each detected kernel inorg-babel-default-header-args:jupyter-<language>
org-babel-execute:jupyter-<language>
toorg-babel-execute:ipython
for each detected kernelThe upshot is that you can now write
instead of
In addition, editing code blocks with
C-c '
(orM-x org-edit-special
) will now (usually) put you in the correct mode.This PR is probably not ready to be merged. My emacs-lisp is not good, I basically just tried stuff, got error messages, tried stuff to make the errors go away, and repeated until it worked. I would very much appreciate suggestions for improving this code. My hope is that despite my obvious lack of elisp skills this PR can serve as a starting point for improving multi-kernel support in ob-ipython.