WillKoehrsen / Data-Analysis

Data Science Using Python
https://medium.com/@williamkoehrsen/
MIT License
5.16k stars 3.64k forks source link

Slack magic? #29

Open psychemedia opened 5 years ago

psychemedia commented 5 years ago

Have you looked at creating some IPython line or block magic (%slack or %%slack) to support issuing Slack commands from notebook code cells?

I'm think that your Interacting with Slack.ipynb probably contains many of the necessary ingredients already?

WillKoehrsen commented 5 years ago

That is a brilliant idea! It doesn't appear to be very hard to write your own cell magic so I'll give it a shot. Thanks for the recommendation!

psychemedia commented 5 years ago

@WillKoehrsen This magic — https://github.com/catherinedevlin/ipython-sql — is quite a rich one (I think a Slack magic could be easier), but it demonstrates a feature that might be useful for a Slack magic, specifically persisting the connection so that you only need to set it once.

I've also wondered about a complementary approach - defining a Slack slash command that could send a code fragment to a Jupyter kernel launched on Binderhub, and get the response back into Slack? Something like the ThebeLab js package might provide a clue as to how to do this?

psychemedia commented 5 years ago

Here's another thought on the side... In terms of notification-style working, jupyter-notify provides "Jupyter magic for browser notifications of cell completion". Just prefix a long running cell with%%notify and you'll get a notification when it completes via a browser push notification.

So if a browser notification, why not a Slack channel notification?