Launch interactive app programmatically

Hello,

is it possible to start an interactive app from a script instead of from the browser?
Doing an HTTP POST for example.

Thanks,
Daniel.

Just to clarify:
I am asking if there is some kind of API I can use to launch interactive apps.
Thank you.

Can you clarify the workflow you are looking to implement? if you aren’t using a browser, how are you going to interact with the interactive app? The whole point of interactive apps is to be able to use your mouse to point and click things.

We want to use OpenOnDemand so our users can start jupyter notebooks on our cluster.

As you mentioned, for regular users OpenOnDemand is great and super simple to use.

But there is another use case where developers want to request the notebook directly from their code (instead of going filling in the form into the Ondemand website). Ideally they will end up getting a URL, and they will access the jupyter notebook via the ondemand server:

Example: https://ondemand.server/node/c1i0t5/42796/lab?

I hope this makes sense.
Thanks a lot!

I’m sorry but I’m still a bit confused. Is this code they are running in a batch system or via a terminal window of some sort? If so, they still would need to transition to opening up a browser to interact with the interactive app.

Regardless, conceptually you could just look at the URL that the the interactive app form is constructing and utilize that, but there is an authentication and scheduling piece of this workflow as well that needs to be taken into account.

Can the code be run on the web node where OnDemand is installed, and run as the user that will be starting the Juypter Notebook?

One problem is that the URL to connect is not known till after the job starts.

On possibility is an experimental rake task that lets you start an interactive app from the command line (https://github.com/OSC/ondemand/wiki/start_interactive_app_from_command_line and https://github.com/OSC/ondemand/blob/bbac62225175360f5bd92ee0d9591ac8b5db46b2/apps/dashboard/lib/tasks/batch_connect.rake) but it is not fully developed - it doesn’t return anything useful upon completion so it might need to be modified to suit your needs.

Regardless, conceptually you could just look at the URL that the the interactive app form is constructing and utilize that, but there is an authentication and scheduling piece of this workflow as well that needs to be taken into account.

Exactly. Inspecting my browser calls, I saw a POST request to https://ondemand.server/pun/sys/dashboard/batch_connect/sys/bc_osc_jupyter/session_contexts. I was wondering if I can do the same with curl for example. What do you think?

Can the code be run on the web node where OnDemand is installed, and run as the user that will be starting the Juypter Notebook?

Unfortunately not. The idea is that external services can spawn a new jupyter notebook without the user accessing to the OnDemand website.

Thanks a lot for your help.

I’m still a bit confused as to the exact proposed workflow here. Would the user be connected via terminal to a login node or compute node? Or would they have code running a batch job? This code would then request a jupyter session? Then they would have to open a browser to connect to it?

One general rule of thumb I like to emphasize with people is that OOD is essentially just a series of wrappers and scripts around existing system tools like your resource manager, batch scheduler, vnc servers, etc. When someone asks if OOD can do ‘X’, the general response is if a knowledgable user do ‘X’ from the command line then OOD can do ‘X’. So in this case, the question is could a knowledgable user execute a series of commands to accomplish what you are asking for (e.g. could they launch a jupyter session and connect to it independent of OOD?

Hi @alanc,

I must admit I am no expert in HPC systems nor its terminology. So apologies in advance if I am saying nonsense.

I set up a OOD server and configured a Jupyter interactive app that runs on our cluster through Slurm.
This works great for most of our users.

Now, I have a group of developers, who want to integrate their application(s) with this jupyter setup based on OOD. They will use OOD as an interface to schedule jupyter notebook jobs on the cluster without taking care of slurm/munge configuration, credentials, etc. The jupyter session will be managed entirely by OOD. An external service (developer’s app/webapp) will be the one initiating the session instead of from the OOD website.

My idea was, OK, I will figure out how OOD starts the job and just try to replicate that from a script, but I was not able to do it.

Does this make sense?
Thanks a lot.

That helps clarify quite a bit. But I suspect there is still a fundamental misunderstanding somewhere on this. Note, we’d be happy to jump on a call or WebEx to discuss this in more detail with you.

As I mentioned before, OOD is essentially just a series of wrapper scripts that interface to existing other software on your cluster. That software includes whatever you use for authentication / identity management (e.g. Active Directory, LDAP, etc. ), whatever software you use for resource scheduling and batch job management (e.g. SLURM), and whatever software applications users want to run (e.g. Jupyter).

So, pretty much every HPC system configuration has some sort of user authentication piece to it. How are these developers applications authenticating into your cluster? OOD can’t do anything magical there since it doesn’t do the authentication itself, just provides an interface to your existing systems.

Likewise, you obviously have Jupyter configured on your system since OOD itself doesn’t embed Jupyter within it. Just like OOD can launch Jupyter, any user on your system should be able to directly launch Jupyter without having to go through OOD by just executing the correct commands.

Finally, OOD doesn’t ‘manage’ any application sessions. All job and resource management is being handled via your resource / job scheduler (SLURM).