# Launch interactive app programmatically

**URL:** <https://discourse.openondemand.org/t/launch-interactive-app-programmatically/929>\
**Category:** Feature Requests and Roadmap Discussion\
**Tags:** question\
**Created:** [May 25, 2020, 10:00am UTC](https://discourse.openondemand.org/t/launch-interactive-app-programmatically/929 "2020-05-25T10:00:53Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![danielfr](https://sea1.discourse-cdn.com/flex015/user_avatar/discourse.openondemand.org/danielfr/32/449_2.png) [@danielfr](https://discourse.openondemand.org/u/danielfr)\
**Post date:** [May 25, 2020, 10:00am UTC](https://discourse.openondemand.org/t/launch-interactive-app-programmatically/929/1 "2020-05-25T10:00:54Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![danielfr](https://sea1.discourse-cdn.com/flex015/user_avatar/discourse.openondemand.org/danielfr/32/449_2.png) [@danielfr](https://discourse.openondemand.org/u/danielfr)\
**Post date:** [May 25, 2020, 10:04am UTC](https://discourse.openondemand.org/t/launch-interactive-app-programmatically/929/2 "2020-05-25T10:04:08Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![alanc](https://sea1.discourse-cdn.com/flex015/user_avatar/discourse.openondemand.org/alanc/32/2524_2.png) [@alanc](https://discourse.openondemand.org/u/alanc)\
**Post date:** [May 25, 2020, 2:20pm UTC](https://discourse.openondemand.org/t/launch-interactive-app-programmatically/929/3 "2020-05-25T14:20:14Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![danielfr](https://sea1.discourse-cdn.com/flex015/user_avatar/discourse.openondemand.org/danielfr/32/449_2.png) [@danielfr](https://discourse.openondemand.org/u/danielfr)\
**Post date:** [May 25, 2020, 2:54pm UTC](https://discourse.openondemand.org/t/launch-interactive-app-programmatically/929/4 "2020-05-25T14:54:19Z")

</div>

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](https://ondemand.server/node/c1i0t5/42796/lab)?

I hope this makes sense.  
Thanks a lot!

---

<div class="post-metadata">

**Author:** ![alanc](https://sea1.discourse-cdn.com/flex015/user_avatar/discourse.openondemand.org/alanc/32/2524_2.png) [@alanc](https://discourse.openondemand.org/u/alanc)\
**Post date:** [May 26, 2020, 12:39pm UTC](https://discourse.openondemand.org/t/launch-interactive-app-programmatically/929/5 "2020-05-26T12:39:10Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![efranz](https://sea1.discourse-cdn.com/flex015/user_avatar/discourse.openondemand.org/efranz/32/27_2.png) [@efranz](https://discourse.openondemand.org/u/efranz)\
**Post date:** [May 26, 2020, 1:23pm UTC](https://discourse.openondemand.org/t/launch-interactive-app-programmatically/929/6 "2020-05-26T13:23:44Z")

</div>

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](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](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.

---

<div class="post-metadata">

**Author:** ![danielfr](https://sea1.discourse-cdn.com/flex015/user_avatar/discourse.openondemand.org/danielfr/32/449_2.png) [@danielfr](https://discourse.openondemand.org/u/danielfr)\
**Post date:** [May 26, 2020, 9:06pm UTC](https://discourse.openondemand.org/t/launch-interactive-app-programmatically/929/7 "2020-05-26T21:06:23Z")

</div>

> 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.

---

<div class="post-metadata">

**Author:** ![alanc](https://sea1.discourse-cdn.com/flex015/user_avatar/discourse.openondemand.org/alanc/32/2524_2.png) [@alanc](https://discourse.openondemand.org/u/alanc)\
**Post date:** [May 26, 2020, 9:39pm UTC](https://discourse.openondemand.org/t/launch-interactive-app-programmatically/929/8 "2020-05-26T21:39:29Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![danielfr](https://sea1.discourse-cdn.com/flex015/user_avatar/discourse.openondemand.org/danielfr/32/449_2.png) [@danielfr](https://discourse.openondemand.org/u/danielfr)\
**Post date:** [May 28, 2020, 11:32am UTC](https://discourse.openondemand.org/t/launch-interactive-app-programmatically/929/9 "2020-05-28T11:32:43Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![alanc](https://sea1.discourse-cdn.com/flex015/user_avatar/discourse.openondemand.org/alanc/32/2524_2.png) [@alanc](https://discourse.openondemand.org/u/alanc)\
**Post date:** [May 28, 2020, 1:30pm UTC](https://discourse.openondemand.org/t/launch-interactive-app-programmatically/929/10 "2020-05-28T13:30:39Z")

</div>

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).

---

<div class="post-metadata">

**Author:** ![westburg.2](https://avatars.discourse-cdn.com/v4/letter/w/0ea827/32.png) [@westburg.2](https://discourse.openondemand.org/u/westburg.2)\
**Post date:** [May 26, 2022, 4:11pm UTC](https://discourse.openondemand.org/t/launch-interactive-app-programmatically/929/11 "2022-05-26T16:11:37Z")

</div>


