Run command from launcher

(Sorry for back ticking all the links, I’m being told I am only allowed two?)

Using https://github.com/jupyterlab/extension-examples/tree/master/launcher as a template I’m able to make a launcher icon in https://github.com/vivian-rook/sparql-install-front This will open a .py text file for me.

From https://github.com/jupyterlab/jupyterlab/issues/13393 I learned that I will need a backend as well. Which if I’m understanding correctly I would put in another git repo and then install them both with pip?

I have two questions. The first is that https://github.com/vivian-rook/sparql-install-front does install an icon. Though it feels like a lot of code, and requires having:

npm --prefix . install 
pip install -ve .

run out of an environment built out of instructions in https://jupyterlab.readthedocs.io/en/stable/extension/extension_tutorial.html
This seems like a lot of code and steps to install an icon. I’ve been trying to reduce the amount of code by transferring the seemingly pertinent files from what works into a new repo created with:

cookiecutter https://github.com/jupyterlab/mimerender-cookiecutter-ts

though so far with no success (ultimately failing on ValueError: missing files: ['/tmp/pip-req-build-70v8q3g6/sparql-install-front/labextension/package.json'] )
Is there a more lightweight way to make a launcher icon?

Second, am I on the right track for how one would create a backend? I’m guessing it would be from the cookiecutter from https://github.com/jupyterlab/extension-cookiecutter-ts ? (what’s the difference between that and the one suggested in the issue above, https://github.com/jupyterlab/mimerender-cookiecutter-ts ?)

Thank you!

Yes, starting from the extension-cookiecutter-ts is a pretty good plan. It will start with a serverextension, if requested, whereas a mimerenderer usually will not have a server component. It should also theoretically just require a python -m pip install -e ., which would handle the initial nodejs tasks, but indeed, for contributing to the collaborative hallucination that is a modular client/server application, there is a bit of boilerplate, as the goal is for end users to have a working system from PyPI-published packages.

But otherwise: no, unlike toolbars and menus, the launcher has not yet received a “configure-by-JSON-schema” treatment. There are a few other tools, such as jupyter-app-launcher, but if you are going to be doing anything else custom, the overhead your seeing might be worth it vs an added depdendency.

1 Like

Oh! A thing! You said a thing! A thing that gives hope!

But otherwise: no, unlike toolbars and menus, the launcher has not yet received a “configure-by-JSON-schema” treatment

Are you saying that if I don’t bother with a launcher tile, but instead make a menu, maybe a menu called “install stuff” this would be easy?

Still not sure what you’re trying to actually do, so there’s a limit to how much we can help.

You can configure a menu item by settings, even if your application doesn’t use the ISettingsRegistry.

You then still need to create a command, or find an extension that creates it for you, such as the one mentioned above, or even jupyterlab-starters (disclaimer: author).

https://github.com/vivian-rook/sparql-install-menu does get me a menu item that I can work with. For the command part I’m not sure where to proceed.

What I would like is my menu entry to run a bash script that will live in /srv/script.sh (which will install some things with pip).

I’ve yet to find an example of the command entry that seems to be running a bash command inside the a jupyter container. I don’t know that jupyterlab-starters would work for this, though I may be misunderstanding how it is intended.

Do you know a way to have the command run a well command line command?

Thank you!

run a bash script

jupyterlab-commands would do that.

Can jupyterlab-commands run a command from a menu entry? Or only the command pallet? If the former, what would that look like in the typescript file?

run a command from a menu entry

No, but you could ask for it on an issue.

what would that look like in the typescript file?

You’d have to figure out what the effective command ID would be.

Hmm…I don’t know if that will work for what I’m looking for. Is there anything like:

which runs a command, but then does additional work in trying to setup a server.

A little tinkering with a fork of the openrefine server-proxy gets me:

which does indeed touch a file, but then goes on to do more work that I would prefer that it does not.

Is there any kind of plugin like jupyter-server-proxy that runs a command and stops at that point? Without doing additional work after running the command?

Thanks!