Skip to content

config

config

get_jupyter_settings async

get_jupyter_settings(
    auth: DomoAuth,
    return_raw: bool = False,
    *,
    context: RouteContext | None = None,
    **context_kwargs
) -> ResponseGetData

Retrieve Jupyter settings for the Domo instance.

GET /api/datascience/v1/settings

Returns instance types, limits, kernel specs, feature flags, etc.

Example response shape::

{
    "instanceTypes": [{"cpu": 0.5, "memory": 4.0}, ...],
    "limits": {...},
    "isEnabled": true,
    "userAccess": {...},
    "currentUserInstanceTypes": [...],
    "jupyterKernels": [...],
    "featureFlags": {...},
    "locale": "en-US",
    "timeZone": "America/Denver",
    "maintenance": {...}
}

Parameters:

Name Type Description Default
auth DomoAuth

Authentication object (standard DomoAuth).

required
return_raw bool

Return raw response without error checking.

False
context RouteContext | None

Optional RouteContext.

None

Returns:

Type Description
ResponseGetData

ResponseGetData with settings dict.

Raises:

Type Description
Jupyter_GET_Error

On failure.

Source code in src/crew_dcs/routes/jupyter/config.py
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
@gd.route_function
@log_call(**_LOG_DECORATORS)
async def get_jupyter_settings(
    auth: DomoAuth,
    return_raw: bool = False,
    *,
    context: RouteContext | None = None,
    **context_kwargs,
) -> rgd.ResponseGetData:
    """Retrieve Jupyter settings for the Domo instance.

    ``GET /api/datascience/v1/settings``

    Returns instance types, limits, kernel specs, feature flags, etc.

    Example response shape::

        {
            "instanceTypes": [{"cpu": 0.5, "memory": 4.0}, ...],
            "limits": {...},
            "isEnabled": true,
            "userAccess": {...},
            "currentUserInstanceTypes": [...],
            "jupyterKernels": [...],
            "featureFlags": {...},
            "locale": "en-US",
            "timeZone": "America/Denver",
            "maintenance": {...}
        }

    Args:
        auth: Authentication object (standard ``DomoAuth``).
        return_raw: Return raw response without error checking.
        context: Optional ``RouteContext``.

    Returns:
        ``ResponseGetData`` with settings dict.

    Raises:
        Jupyter_GET_Error: On failure.
    """
    context = RouteContext.build_context(context=context, **context_kwargs)

    url = f"https://{auth.domo_instance}.domo.com/api/datascience/v1/settings"

    res = await gd.get_data(
        url=url,
        method="GET",
        auth=auth,
        context=context,
    )

    if return_raw:
        return res

    if not res.is_success:
        raise Jupyter_GET_Error(message="Failed to retrieve Jupyter settings", res=res)

    return res

get_jupyter_user_namespace async

get_jupyter_user_namespace(
    auth: DomoAuth,
    return_raw: bool = False,
    *,
    context: RouteContext | None = None,
    **context_kwargs
) -> ResponseGetData

Retrieve the Jupyter user namespace for the current user.

GET /api/datascience/v1/workspaces/user

The namespace string (e.g. "my-company-config-672596669") appears in the service_prefix path of all Jupyter server URLs: /user/{namespace}/{workspace_short_id}/api/contents/...

Example response::

{"name": "my-company-config-672596669"}

Parameters:

Name Type Description Default
auth DomoAuth

Authentication object (standard DomoAuth).

required
return_raw bool

Return raw response without error checking.

False
context RouteContext | None

Optional RouteContext.

None

Returns:

Type Description
ResponseGetData

ResponseGetData whose .response is {"name": str}.

Raises:

Type Description
Jupyter_GET_Error

On failure.

Source code in src/crew_dcs/routes/jupyter/config.py
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
@gd.route_function
@log_call(**_LOG_DECORATORS)
async def get_jupyter_user_namespace(
    auth: DomoAuth,
    return_raw: bool = False,
    *,
    context: RouteContext | None = None,
    **context_kwargs,
) -> rgd.ResponseGetData:
    """Retrieve the Jupyter user namespace for the current user.

    ``GET /api/datascience/v1/workspaces/user``

    The namespace string (e.g. ``"my-company-config-672596669"``) appears in
    the ``service_prefix`` path of all Jupyter server URLs:
    ``/user/{namespace}/{workspace_short_id}/api/contents/...``

    Example response::

        {"name": "my-company-config-672596669"}

    Args:
        auth: Authentication object (standard ``DomoAuth``).
        return_raw: Return raw response without error checking.
        context: Optional ``RouteContext``.

    Returns:
        ``ResponseGetData`` whose ``.response`` is ``{"name": str}``.

    Raises:
        Jupyter_GET_Error: On failure.
    """
    context = RouteContext.build_context(context=context, **context_kwargs)

    url = f"https://{auth.domo_instance}.domo.com/api/datascience/v1/workspaces/user"

    res = await gd.get_data(
        url=url,
        method="GET",
        auth=auth,
        context=context,
    )

    if return_raw:
        return res

    if not res.is_success:
        raise Jupyter_GET_Error(
            message="Failed to retrieve Jupyter user namespace", res=res
        )

    return res

resolve_compute_tier

resolve_compute_tier(
    cpu: float | int | None,
    memory: float | int | None,
    instance_types: list[dict] | None = None,
) -> str | None

Resolve a human-readable compute tier label for a workspace's cpu/memory.

Domo's instanceTypes (returned by both get_jupyter_settings and the per-workspace GET /api/datascience/v1/workspaces/{id} response) only carries {"cpu": ..., "memory": ...} pairs — there is no name/label field to surface as-is (confirmed against a live instance while implementing this — see issue #1497). The label is therefore synthesized as "{cpu} CPU / {memory} GB".

When instance_types is supplied, the cpu/memory pair must match one of the listed tiers or None is returned — this distinguishes a known/standard tier from a custom or unrecognized allocation. When instance_types is omitted, the label is synthesized unconditionally.

Parameters:

Name Type Description Default
cpu float | int | None

Workspace cpu allocation (e.g. 0.5).

required
memory float | int | None

Workspace memory allocation in GB (e.g. 4.0).

required
instance_types list[dict] | None

Optional list of {"cpu": ..., "memory": ...} dicts (from workspace instanceTypes or settings instanceTypes/currentUserInstanceTypes) to validate against.

None

Returns:

Type Description
str | None

A label like "0.5 CPU / 4 GB", or None if cpu/memory is

str | None

missing, or if instance_types was provided and no entry matches.

Source code in src/crew_dcs/routes/jupyter/config.py
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
def resolve_compute_tier(
    cpu: float | int | None,
    memory: float | int | None,
    instance_types: list[dict] | None = None,
) -> str | None:
    """Resolve a human-readable compute tier label for a workspace's cpu/memory.

    Domo's ``instanceTypes`` (returned by both ``get_jupyter_settings`` and
    the per-workspace ``GET /api/datascience/v1/workspaces/{id}`` response)
    only carries ``{"cpu": ..., "memory": ...}`` pairs — there is no
    ``name``/``label`` field to surface as-is (confirmed against a live
    instance while implementing this — see issue #1497). The label is
    therefore synthesized as ``"{cpu} CPU / {memory} GB"``.

    When ``instance_types`` is supplied, the cpu/memory pair must match one
    of the listed tiers or ``None`` is returned — this distinguishes a
    known/standard tier from a custom or unrecognized allocation. When
    ``instance_types`` is omitted, the label is synthesized unconditionally.

    Args:
        cpu: Workspace cpu allocation (e.g. ``0.5``).
        memory: Workspace memory allocation in GB (e.g. ``4.0``).
        instance_types: Optional list of ``{"cpu": ..., "memory": ...}``
            dicts (from workspace ``instanceTypes`` or settings
            ``instanceTypes``/``currentUserInstanceTypes``) to validate against.

    Returns:
        A label like ``"0.5 CPU / 4 GB"``, or ``None`` if cpu/memory is
        missing, or if ``instance_types`` was provided and no entry matches.
    """
    if cpu is None or memory is None:
        return None

    if instance_types is not None:
        is_known = any(
            it.get("cpu") == cpu and it.get("memory") == memory for it in instance_types
        )
        if not is_known:
            return None

    return f"{_format_number(cpu)} CPU / {_format_number(memory)} GB"

resolve_python_version

resolve_python_version(
    jupyter_kernel: str | None,
) -> str | None

Parse a Python version string out of a Domo jupyterKernel code.

The workspace API (GET /api/datascience/v1/workspaces/{id}) returns the active kernel as a code such as "PYTHON_3_12" or "R_4_1" on the workspace itself (confirmed present on live workspaces regardless of whether the workspace is currently running — see issue #1497). This parses that code directly rather than requiring a separate get_jupyter_settings call to look the code up in jupyterKernels.

Parameters:

Name Type Description Default
jupyter_kernel str | None

Raw kernel code, e.g. "PYTHON_3_12".

required

Returns:

Type Description
str | None

A version string like "3.12" for Python kernels, or None for

str | None

non-Python kernels (e.g. R) or a missing value.

Source code in src/crew_dcs/routes/jupyter/config.py
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
def resolve_python_version(jupyter_kernel: str | None) -> str | None:
    """Parse a Python version string out of a Domo ``jupyterKernel`` code.

    The workspace API (``GET /api/datascience/v1/workspaces/{id}``) returns
    the active kernel as a code such as ``"PYTHON_3_12"`` or ``"R_4_1"`` on
    the workspace itself (confirmed present on live workspaces regardless of
    whether the workspace is currently running — see issue #1497). This
    parses that code directly rather than requiring a separate
    ``get_jupyter_settings`` call to look the code up in ``jupyterKernels``.

    Args:
        jupyter_kernel: Raw kernel code, e.g. ``"PYTHON_3_12"``.

    Returns:
        A version string like ``"3.12"`` for Python kernels, or ``None`` for
        non-Python kernels (e.g. R) or a missing value.
    """
    if not jupyter_kernel or not jupyter_kernel.upper().startswith("PYTHON_"):
        return None

    version_parts = jupyter_kernel.split("_")[1:]
    if not version_parts:
        return None

    return ".".join(version_parts)

update_jupyter_workspace_config async

update_jupyter_workspace_config(
    auth: DomoAuth,
    workspace_id: str,
    config: dict,
    return_raw: bool = False,
    *,
    context: RouteContext | None = None,
    **context_kwargs
) -> ResponseGetData

Update the configuration of a Jupyter workspace.

PUT /api/datascience/v1/workspaces/{workspace_id}

Parameters:

Name Type Description Default
auth DomoAuth

Authentication object.

required
workspace_id str

UUID of the workspace.

required
config dict

Configuration dict (inputConfiguration, outputConfiguration, etc.).

required
return_raw bool

Return raw response without error checking.

False
context RouteContext | None

Optional RouteContext.

None

Returns:

Type Description
ResponseGetData

ResponseGetData with updated workspace configuration.

Raises:

Type Description
Jupyter_CRUD_Error

On update failure.

SearchJupyterNotFoundError

If workspace does not exist (404).

Source code in src/crew_dcs/routes/jupyter/config.py
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
@gd.route_function
@log_call(**_LOG_DECORATORS)
async def update_jupyter_workspace_config(
    auth: DomoAuth,
    workspace_id: str,
    config: dict,
    return_raw: bool = False,
    *,
    context: RouteContext | None = None,
    **context_kwargs,
) -> rgd.ResponseGetData:
    """Update the configuration of a Jupyter workspace.

    ``PUT /api/datascience/v1/workspaces/{workspace_id}``

    Args:
        auth: Authentication object.
        workspace_id: UUID of the workspace.
        config: Configuration dict (inputConfiguration, outputConfiguration, etc.).
        return_raw: Return raw response without error checking.
        context: Optional ``RouteContext``.

    Returns:
        ``ResponseGetData`` with updated workspace configuration.

    Raises:
        Jupyter_CRUD_Error: On update failure.
        SearchJupyterNotFoundError: If workspace does not exist (404).
    """
    context = RouteContext.build_context(context=context, **context_kwargs)

    url = f"https://{auth.domo_instance}.domo.com/api/datascience/v1/workspaces/{workspace_id}"

    res = await gd.get_data(
        url=url,
        method="PUT",
        auth=auth,
        body=config,
        context=context,
    )

    if return_raw:
        return res

    if res.status == 404:
        raise SearchJupyterNotFoundError(
            search_criteria=f"workspace_id: {workspace_id}", res=res
        )

    if not res.is_success:
        raise Jupyter_CRUD_Error(
            operation="update_config",
            workspace_id=workspace_id,
            message=f"Error updating workspace configuration for {workspace_id}",
            res=res,
        )

    return res