Skip to content

Managing Jupyter Workspaces

Two different tasks live under "Jupyter in Domo," and they have two different tools:

  • Working in a notebook (read/write DataSets, run analyses): Domo's own domojupyter library, pre-authenticated inside the workspace (Domo KB). crew-dcs is not involved.
  • Working on workspaces (list them, pull their config, audit who has what, automate lifecycle): the Jupyter server API, which is what this guide covers.

For auth setup (workspace token, service location/prefix, or plain access tokens), start with the Authenticating to Domo guide.

The two classes

  • DomoJupyterWorkspace: one workspace. get_by_id() is the entry point.
  • DomoJupyterWorkspaces: the manager. .get(maximum=N) lists workspaces.
import os
from crew_dcs.auth import DomoTokenAuth
from crew_dcs.classes.DomoJupyter import DomoJupyterWorkspace, DomoJupyterWorkspaces

auth = DomoTokenAuth(
    domo_access_token=os.environ["DOMO_ACCESS_TOKEN"],
    domo_instance="mycompany",
)

# One workspace
ws = await DomoJupyterWorkspace.get_by_id(
    auth=auth,
    workspace_id=os.environ["JUPYTER_WORKSPACE_ID"],
)

# List the workspaces the token's user can see
workspaces = await DomoJupyterWorkspaces(auth=auth).get()
for w in workspaces:
    print(w.id, w)

Speeding up repeated lookups

If your script touches the same workspace repeatedly, turn on response caching via a RouteContext; it wraps calls with the SDK's HTTP cache so repeated get_by_id calls don't round-trip:

from crew_dcs.classes.DomoJupyter import DomoJupyterWorkspace
from crew_dcs.client.context import RouteContext

ws = await DomoJupyterWorkspace.get_by_id(
    auth=auth,
    workspace_id=workspace_id,
    context=RouteContext(use_cache=True),
)

Error handling

A workspace ID that doesn't exist (or that your token's user can't see) raises Jupyter_GET_Error: catch it explicitly so a stale ID in a config file fails with a useful message instead of a stack trace:

from crew_dcs.routes.jupyter.exceptions import Jupyter_GET_Error

try:
    ws = await DomoJupyterWorkspace.get_by_id(auth=auth, workspace_id=workspace_id)
except Jupyter_GET_Error:
    print(f"Workspace {workspace_id} not found — check the ID and the token's user")

Debug logging

Pass debug_api=True (or a RouteContext with logging options) to see the exact request/response the SDK makes. Invaluable when a workspace call behaves differently than the Domo UI suggests it should.

Further reading