Skip to content

๐Ÿง‘โ€๐Ÿ’ป Interactive Routines โ€‹

An interactive routine runs an app you use in the browser: a notebook, an IDE, a dashboard or a small web service. It's an ordinary WKubeTask with one extra setting, interactive_socket, the address your app listens on inside the container.

Every interactive job gets:

  • A stable address, https://<name>.wkube.iiasa.ac.at, kept for all your later runs.
  • Sleep and wake. The app stops after its idle time with no visitors and starts again on the next visit to its address. Nothing to keep running, nothing to restart by hand.
  • An optional custom domain, such as https://app.example.org.

Interactive apps are for work done through the browser. Work that keeps running with no tab open, such as training or long processing, belongs in a normal (batch) routine.


โš™๏ธ Settings โ€‹

All settings go in the job's conf. Every value is a string, also numbers: conf becomes the job's environment variables, so write "30", not 30.

KeyRequiredDefaultAllowed valuesExample
interactive_socketYesnonehost:port or port your app listens on in the container"0.0.0.0:8888"
TUNNEL_NAMENorandom 32-character nameLowercase letters, digits and -, not starting or ending with -, at most 63 characters"sales-dashboard"
IDLE_TIMEOUT_MINUTESNo"60"Whole minutes, "15" to "1440" (1 day)"120"
CUSTOM_DOMAINNononeA domain you control, without https:// or a path"app.example.org"

TUNNEL_PREFIX from older routines still works as an alias of TUNNEL_NAME. In the web app these settings appear in the run form of the built-in interactive routines. For interactive routines the timeout field is hidden: they end by idle time instead, and at the latest after 7 days.


๐Ÿงช Example โ€‹

python
from accli import WKubeTask

notebook = WKubeTask(
    name="Team notebook",
    docker_image="jupyter/base-notebook:latest",
    command="start-notebook.sh --ServerApp.ip=0.0.0.0 --ServerApp.port=8888",
    required_cores=2,
    required_ram=4 * 1024 * 1024 * 1024,
    required_storage_local=2 * 1024 * 1024 * 1024,
    required_storage_workflow=0,
    timeout=3600,  # ignored for interactive jobs: they stop by idle time
    conf={
        "interactive_socket": "0.0.0.0:8888",
        "TUNNEL_NAME": "team-notebook",
        "IDLE_TIMEOUT_MINUTES": "120",
    },
)

Dispatch it with accli dispatch as any routine. The job log shows the address once the app is reachable:

Interactive socket tunneled at: team-notebook.wkube.iiasa.ac.at

๐ŸŒ Your app's address โ€‹

  • With TUNNEL_NAME, the address is https://<TUNNEL_NAME>.wkube.iiasa.ac.at. Without it, a random name is generated, which is hard to guess since the address has no login of its own.
  • Names are global and personal. The first job that uses a name reserves it for you, across all projects. Your later jobs can use it again; anyone else's dispatch with that name is refused.
  • A name can be used by one running job at a time. To move it to a new job, stop the old one first.
  • The Apps page in the web app lists your names with their state (running, starting or asleep), project, idle time and last use. Release frees a name you no longer need, so anyone can take it. Names unused for 3 months are released automatically.
  • Some names are kept by the platform, such as www, api, gateway and admin.

๐Ÿ˜ด Sleep and wake โ€‹

  • The app counts as in use while anyone has a connection open to it. An open Jupyter or RStudio tab keeps it awake.
  • After IDLE_TIMEOUT_MINUTES with no connections, the app stops. The job ends as KILLED, and its log says it was an idle stop. A freshly started app gets 15 minutes for its first visitor.
  • The next visit to its address shows a waiting page that starts the app again and switches to it when it's ready, usually within a minute or two. Bookmarks keep working.
  • A woken app starts fresh, from the same job settings. Files in /mnt/wdrv and your outputs are kept; /mnt/tmp and memory are not. Save anything you need to keep to your project.
  • Set IDLE_TIMEOUT_MINUTES to at least the longest task the app runs with no tab open. Longer than a day belongs in a batch routine.
  • Link previews, crawlers and bots don't start an app: only a visitor's browser does. One visitor can start up to 20 different apps per hour.
  • If a woken app fails within 2 minutes of being started, the waiting page asks you to wait until those 2 minutes are up before it tries again, so a broken app isn't restarted in a loop. Check the job log for the error.

๐Ÿ”— Custom domains โ€‹

Serve the app at a domain you control, in addition to its normal address.

  1. Open the Apps page and enter the domain under Use your own domain. It shows two DNS records:

    app.example.org                CNAME  <target shown on the Apps page>
    _wkube-verify.app.example.org  TXT    wkube-<your code>

    The code is personal: it proves that you, not another user, control the domain.

  2. Add both records at your DNS provider. Changes can take a few minutes to show up.

  3. Dispatch the job with CUSTOM_DOMAIN set to the domain.

At dispatch the platform checks the TXT record. If it's missing, the dispatch fails and the error shows both records with your code, so you can also start from step 3 with accli. Dispatching without CUSTOM_DOMAIN always works, and the normal address works either way.

  • The first visit after setup takes a few seconds while the HTTPS certificate is issued. It's renewed automatically.
  • Once verified, your later jobs can use the domain without a new check. Another user can take it over only by publishing their own code, which needs control of the domain's DNS.
  • Dispatching under the same TUNNEL_NAME without CUSTOM_DOMAIN removes the domain. Releasing the name removes it too.
  • Root domains like example.org can't have a CNAME. Use an ALIAS record (also called ANAME or CNAME flattening) if your DNS provider offers it, or a subdomain such as app.example.org.
  • If custom domains aren't enabled on the platform yet, the dispatch says so.

โœ… Before you dispatch โ€‹

  • [ ] interactive_socket is set, and the app listens on 0.0.0.0 and that port. An app listening only on 127.0.0.1 may not be reachable.
  • [ ] All conf values are strings.
  • [ ] TUNNEL_NAME, if set, is lowercase letters, digits and hyphens, and not used by another user.
  • [ ] IDLE_TIMEOUT_MINUTES, if set, is between "15" and "1440" and covers the longest task the app runs on its own.
  • [ ] For CUSTOM_DOMAIN: both DNS records exist.
  • [ ] Anything worth keeping is written to /mnt/wdrv or an output mapping, since a woken app starts fresh.

๐Ÿงฏ Troubleshooting โ€‹

What you seeCause and fix
Dispatch fails: name reserved by another userChoose another TUNNEL_NAME.
Dispatch fails: name in use by your jobStop that job first, or choose another name.
Dispatch fails: invalid TUNNEL_NAME or IDLE_TIMEOUT_MINUTESFix the value as the message says, and write it as a string.
Dispatch fails: couldn't verify CUSTOM_DOMAINAdd the two records from the message and try again in a few minutes, or dispatch without CUSTOM_DOMAIN.
"No app here"Nobody holds that name. Check the spelling, or the Apps page.
The waiting page never finishesThe app doesn't start or doesn't listen on interactive_socket. Open the job's log.
The app stops while you're awayExpected after the idle time. Raise IDLE_TIMEOUT_MINUTES if it runs work on its own.