Add a simple menu option to run a batch script

Hey Jupyter folks. I have what I thought was a simple thing but as I google around I’m wondering if I’m just looking in the wrong place.

I have some analysts who are not super technical who use/maintain some Jupyter Notebooks which they run on a centralized JupyterLab instance. That works great. But we have a few common tasks that we’d like to make easier for them. Ideally as easy as adding a menu option for “Internal Tasks” with maybe 4-5 menu options. Most of these would be something simple like “run this shell script”.

Is there a drop dead simple tutorial for simply adding menu options to JupyterLab? I suspect I’m just overlooking it somewhere.

Many thanks,


1 Like

I don’t know of a simple one good tutorial for just adding menu items. Perhaps we could help you write one to contribute to the docs? I’d start with the JupyterLab extension cookiecutter, and go from there. Basically, you’ll need to require the menu, add your commands to the command registry, then add those commands to the menu you created.

1 Like

This sounds like a good idea. Is there a walkthrough somewhere that illustrates how to use JupyterLab extension Cookiecutter? While I am familiar with the concept of cookiecutter I’ve never used cookiecutter in anger.

Yep! Have you seen the xkcd JupyterLab extension tutorial?

Yes I did… to be honest I found it impenetrable and I stopped working on this idea because I had the thought “If this is what it takes to do something simple then I’m clearly considering the wrong platform.”

My interest in learning JavaScript is exactly zero. It seems that there is a very high burden of understanding Node and associated JS goodness in order to do even the most basic of things with JupyterLab customization. I’m sure that makes total sense to the designers who are fluent in JS and think this all makes sense. But as someone who’s quite technical but not at all motivated to climb the JS learning curve, this provides a pretty significant hurdle.

Thanks for the feedback.

Currently, you are right, adding any additional functionality to JupyterLab requires writing JavaScript.

It could be possible to go down the path of exposing the functionality in some way to programmers familiar in Python. Often I think that JS development is complicated enough that adding another heavy language abstraction on top of it would just make it even more crazy!

But it still might be useful to expose some subset of JupyterLab’s extensibility to the kernel layer or in some declarative way to let you write the sort of menu items you are proposing without touching JavaScript. This itself, would be an doable now if someone else who does have JS experience wrote a wrapper extension that allowed you to configure menu items to execute random shell commands.

This is sort of what I was sniffing around to see if someone had already built :wink:

I totally understand why JupyterLab is tightly coupled with JS. But that produces a hurdle… so there are trade offs, for sure.

When I get a little bandwidth I may wade into the cookiecutter JS world. But it’s not going to be real soon.

Thank you all for the work you do with JupyterLab and supporting the community. I really hope my comments don’t come across as disrespectful.


1 Like

I’ve often thought that we should have a lightweight way to write extensions that did not require making an npm package. I’m thinking basically a single js file that is can be edited and stored in settings or something, and can be loaded at initializiation. It would probably require us using js modules so we could import things.

That makes a huge amount of sense to me. I have a number of things I’d like to sort of “bolt on” for our corporate environment. But none of them seem worth the effort of climbing the npm packaging learning curve.