Skip to content
This repository has been archived by the owner on Aug 5, 2023. It is now read-only.

Added support for executing shell commands via magic in code cells. #4

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

HelgeCPH
Copy link

@HelgeCPH HelgeCPH commented Feb 5, 2018

Hej Gustavo,

Thank you for your nice MongoDB kernel for Jupyter! I like it a lot, especially the visualisation of the JSON values, which are returned from the DB engine.

For a current presentation, I needed support for executing some shell commands in separate code cells next to the Mongo cells. I implemented that quickly by adding a check for if a code cell starts with a line of %%bash, similar to Python notebooks. Shell commands are then executed line by line and all of their output (stdout only) are then returned and displayed in a plain string.

That is working for my use cases and perhaps you think it may be useful. However, since I never did anything on Jupyter kernels, I do not know if it makes sense what I did and how I did it.

Best,
Helge

@gusutabopb
Copy link
Owner

Hi, thanks for the PR and sorry for taking so long to reply.

I did a little bit of research and it seems that in IPython, there's a whole machinery to support the so called magic commands. IMongo is a pretty bare bones kernel and doesn't support any of that.

I have just tested your code and it seems to work just fine. The approach would need some refactoring if we were to scale it to support multiple magic commands, but since there's no such plan for that, the new functionality code looks good as it is and shouldn't interfere with the actual MongoDB commands.

However, before merging, I'd like to ask you to address the following points:

  • Version update: please make it 0.1.1dev0. I will change it to 0.1.1 only when I actually update the package on PyPI.
  • Formatting changes: there are about 8 or so lines breaks (I guess inserted by automatically by an IDE due to max column width settings), which are unrelated to the new functionality. Please undo those.

Again, thanks for the PR!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants