Administration#

Here are some more global administration tasks that can be performed using the DSS Public API:

  • Reading and writing general instance settings

  • Managing user and group impersonation rules for User Isolation Framework

  • Managing (creating/modifying) code environments

  • Managing instance variables

  • Listing long-running tasks, getting their status, aborting them

  • Listing running notebooks, getting their status, unloading them

  • Managing global API keys

  • Listing global DSS usages (projects, datasets, recipes, scenarios…)

  • Managing personal API keys

Detailed examples#

This section contains more advanced examples on administration tasks.

List running Jupyter notebooks#

You can use dataikuapi.dss.project.DSSProject.list_jupyter_notebooks() to retrieve a list of notebooks for a given Project, along with useful metadata.

import pprint
import dataiku

def get_instance_notebooks(client):
    all_notebooks = dict()
    for p in client.list_projects():
        p_key = p["projectKey"]
        project = client.get_project(p_key)
        project_notebooks = project.list_jupyter_notebooks()
        if project_notebooks:
            notebooks = []
            for nb in project_notebooks:
                # If the notebook is active then it has at least 1 running session
                sessions = nb.get_sessions()
                if sessions:
                    status = "ACTIVE - {} session(s)".format(len(sessions))
                else:
                    status = "INACTIVE"
                notebooks.append({"name": nb.notebook_name,
                                  "status": status})
            all_notebooks[p_key] = notebooks
    return all_notebooks

def pprint_instance_notebooks(client):
    all_notebooks = get_instance_notebooks(client)
    pprint.pprint(all_notebooks)

client = dataiku.api_client()
pprint_instance_notebooks(client)

Reference documentation#

dataikuapi.dss.admin.DSSGeneralSettings(client)

The general settings of the DSS instance.

dataikuapi.dss.admin.DSSUserImpersonationRule([raw])

An user-level rule items for the impersonation settings

dataikuapi.dss.admin.DSSGroupImpersonationRule([raw])

A group-level rule items for the impersonation settings

dataikuapi.dss.admin.DSSInstanceVariables(...)

Dict containing the instance variables.

dataikuapi.dss.future.DSSFuture(client, job_id)

A future represents a long-running task on a DSS instance.

dataikuapi.dss.jupyternotebook.DSSJupyterNotebook(...)

A handle on a Python/R/scala notebook.

dataikuapi.dss.jupyternotebook.DSSJupyterNotebookListItem(...)

An item in a list of Jupyter notebooks.

dataikuapi.dss.jupyternotebook.DSSNotebookSession(...)

Metadata associated to the session of a Jupyter Notebook.

dataikuapi.dss.jupyternotebook.DSSNotebookContent(...)

The content of a Jupyter Notebook.

dataikuapi.dss.notebook.DSSNotebook(client, ...)

A Python/R/Scala notebook on the DSS instance.

dataikuapi.dss.admin.DSSGlobalApiKey(client, ...)

A global API key on the DSS instance

dataikuapi.dss.admin.DSSGlobalApiKeyListItem(...)

An item in a list of global API keys.

dataikuapi.dss.admin.DSSPersonalApiKey(...)

A personal API key on the DSS instance.

dataikuapi.dss.admin.DSSPersonalApiKeyListItem(...)

An item in a list of personal API key.