Other administration tasks#

class dataikuapi.dss.admin.DSSGeneralSettings(client)#

The general settings of the DSS instance.

Important

Do not instantiate directly, use dataikuapi.DSSClient.get_general_settings() instead.

save()#

Save the changes that were made to the settings on the DSS instance

Note

This call requires an API key with admin rights

get_raw()#

Get the settings as a dictionary

Returns:

the settings

Return type:

dict

add_impersonation_rule(rule, is_user_rule=True)#

Add a rule to the impersonation settings

Parameters:
get_impersonation_rules(dss_user=None, dss_group=None, unix_user=None, hadoop_user=None, project_key=None, scope=None, rule_type=None, is_user=None, rule_from=None)#

Retrieve the user or group impersonation rules that match the parameters

Parameters:
  • dss_user (string) – a DSS user name

  • dss_group (string) – a DSS group name

  • rule_from (string) – a regex (which will be applied to user or group names)

  • unix_user (string) – a name to match the target UNIX user

  • hadoop_user (string) – a name to match the target Hadoop user

  • project_key (string) – a project key

  • scope (string) – project-scoped (‘PROJECT’) or global (‘GLOBAL’)

  • type (string) – the rule user or group matching method (‘IDENTITY’, ‘SINGLE_MAPPING’, ‘REGEXP_RULE’)

  • is_user (boolean) – True if only user-level rules should be considered, False for only group-level rules, None to consider both

remove_impersonation_rules(dss_user=None, dss_group=None, unix_user=None, hadoop_user=None, project_key=None, scope=None, rule_type=None, is_user=None, rule_from=None)#

Remove the user or group impersonation rules that matches the parameters from the settings

Parameters:
  • dss_user (string) – a DSS user name

  • dss_group (string) – a DSS group name

  • rule_from (string) – a regex (which will be applied to user or group names)

  • unix_user (string) – a name to match the target UNIX user

  • hadoop_user (string) – a name to match the target Hadoop user

  • project_key (string) – a project key

  • scope (string) – project-scoped (‘PROJECT’) or global (‘GLOBAL’)

  • type (string) – the rule user or group matching method (‘IDENTITY’, ‘SINGLE_MAPPING’, ‘REGEXP_RULE’)

  • is_user (boolean) – True if only user-level rules should be considered, False for only group-level rules, None to consider both

push_container_exec_base_images()#

Push the container exec base images to their repository

class dataikuapi.dss.admin.DSSUserImpersonationRule(raw=None)#

An user-level rule items for the impersonation settings

scope_global()#

Make the rule apply to all projects

scope_project(project_key)#

Make the rule apply to a given project

Parameters:

project_key (string) – the project this rule applies to

user_identity()#

Make the rule map each DSS user to a UNIX user of the same name

user_single(dss_user, unix_user, hadoop_user=None)#

Make the rule map a given DSS user to a given UNIX user

Parameters:
  • dss_user (string) – a DSS user

  • unix_user (string) – a UNIX user

  • hadoop_user (string) – a hadoop user (optional, defaults to unix_user)

user_regexp(regexp, unix_user, hadoop_user=None)#

Make the rule map a DSS users matching a given regular expression to a given UNIX user

Parameters:
  • regexp (string) – a regular expression to match DSS user names

  • unix_user (string) – a UNIX user

  • hadoop_user (string) – a hadoop user (optional, defaults to unix_user)

class dataikuapi.dss.admin.DSSGroupImpersonationRule(raw=None)#

A group-level rule items for the impersonation settings

group_identity()#

Make the rule map each DSS user to a UNIX user of the same name

group_single(dss_group, unix_user, hadoop_user=None)#

Make the rule map a given DSS user to a given UNIX user

Parameters:
  • dss_group (string) – a DSS group

  • unix_user (string) – a UNIX user

  • hadoop_user (string) – a hadoop user (optional, defaults to unix_user)

group_regexp(regexp, unix_user, hadoop_user=None)#

Make the rule map a DSS users matching a given regular expression to a given UNIX user

Parameters:
  • regexp (string) – a regular expression to match DSS groups

  • unix_user (string) – a UNIX user

  • hadoop_user (string) – a hadoop user (optional, defaults to unix_user)

class dataikuapi.dss.admin.DSSInstanceVariables(client, variables)#

Dict containing the instance variables.

The variables can be modified directly in the dict and persisted using its save() method.

Important

Do not instantiate directly, use dataikuapi.DSSClient.get_global_variables() instead.

save()#

Save the changes made to the instance variables.

Note

This call requires an API key with admin rights.

class dataikuapi.dss.future.DSSFuture(client, job_id, state=None, result_wrapper=<function DSSFuture.<lambda>>)#

A future represents a long-running task on a DSS instance. It allows you to track the state of the task, retrieve its result when it is ready or abort it.

Usage example:

# In this example, 'folder' is a DSSManagedFolder
future = folder.compute_metrics()

# Waits until the metrics are computed
metrics = future.wait_for_result()

Note

This class does not need to be instantiated directly. A dataikuapi.dss.future.DSSFuture is usually returned by the API calls that are initiating long running-tasks.

static from_resp(client, resp, result_wrapper=<function DSSFuture.<lambda>>)#

Creates a dataikuapi.dss.future.DSSFuture from the response of an endpoint that initiated a long-running task.

Parameters:
  • client (dataikuapi.dssclient.DSSClient) – An api client to connect to the DSS backend

  • resp (dict) – The response of the API call that initiated a long-running task.

  • result_wrapper (callable) – (optional) a function to apply to the result of the future, before it is returned by get_result or wait_for_result methods.

Returns:

dataikuapi.dss.future.DSSFuture

abort()#

Aborts the long-running task.

get_state()#

Queries the state of the future, and fetches the result if it’s ready.

Returns:

the state of the future, including the result if it is ready.

Return type:

dict

peek_state()#

Queries the state of the future, without fetching the result.

Returns:

the state of the future

Return type:

dict

get_result()#

Returns the future’s result if it’s ready.

Note

if a custom result_wrapper was provided, it will be applied on the result that will be returned.

Returns:

the result of the future

Return type:

object

Raises:

Exception – if the result is not ready (i.e. the task is still running, or it has failed)

has_result()#

Checks whether the task is completed successfully and has a result.

Returns:

True if the task has successfully returned a result, False otherwise

Return type:

bool

wait_for_result()#

Waits for the completion of the long-running task, and returns its result.

Note

if a custom result_wrapper was provided, it will be applied on the result that will be returned.

Returns:

the result of the future

Return type:

object

Raises:

Exception – if the task failed

class dataikuapi.dss.jupyternotebook.DSSJupyterNotebook(client, project_key, notebook_name)#

A handle on a Python/R/scala notebook.

unload(session_id=None)#

Stop this Jupyter notebook and release its resources.

get_sessions(as_objects=False)#

Get the list of running sessions of this Jupyter notebook.

Usage example:

# list the running notebooks in a project
for notebook in project.list_jupyter_notebooks(as_type="object"):
    if len(notebook.get_sessions()) > 0:
        print("Notebook %s is running" % notebook.notebook_name)
Parameters:

as_objects (boolean) – if True, each returned item will be a dataikuapi.dss.jupyternotebook.DSSNotebookSession

Returns:

a list of dataikuapi.dss.jupyternotebook.DSSNotebookSession if as_objects is True, a list of dict otherwise. The dict holds information about the kernels currently running the notebook, notably a sessionId for the Jupyter session id, and a kernelId for the Jupyter kernel id.

Return type:

list

get_content()#

Get the full contents of this Jupyter notebook.

The content comprises metadata, cells, notebook format info.

Usage example:

# collect all the source code of a notebook
lines = []
for cell in notebook.get_content().get_cells():
    if cell["cell_type"] != 'code':
        continue
    lines = lines + cell["source"]
print('\n'.join(lines))
Return type:

dataikuapi.dss.jupyternotebook.DSSNotebookContent

delete()#

Delete this Jupyter notebook and stop all of its active sessions.

get_object_discussions()#

Get a handle to manage discussions on the notebook.

Returns:

the handle to manage discussions

Return type:

dataikuapi.dss.discussion.DSSObjectDiscussions

class dataikuapi.dss.jupyternotebook.DSSJupyterNotebookListItem(client, data)#

An item in a list of Jupyter notebooks.

Important

Do not instantiate directly, use dataikuapi.dss.project.DSSProject.list_jupyter_notebooks()

to_notebook()#

Get a handle on the corresponding notebook

Return type:

DSSJupyterNotebook

property name#

Get the name of the notebook.

Used as identifier.

property language#

Get the language of the notebook.

Possible values are ‘python’, ‘R’, ‘toree’ (scala)

Return type:

string

property kernel_spec#

Get the raw kernel spec of the notebook.

The kernel spec is internal data for Jupyter, that identifies the kernel.

Returns:

the Jupyter spec of a Jupyter kernel. Top-level fields are:

  • name : identifier of the kernel in Jupyter, for example ‘python2’ or ‘python3’

  • display_name : name of the kernel as shown in the Jupyter UI

  • language : language of the notebook (informative field)

Return type:

dict

class dataikuapi.dss.jupyternotebook.DSSNotebookSession(client, session)#

Metadata associated to the session of a Jupyter Notebook.

Important

Do not instantiate directly, use dataikuapi.dss.jupyternotebook.DSSJupyterNotebook.get_sessions()

unload()#

Stop this Jupyter notebook and release its resources.

class dataikuapi.dss.jupyternotebook.DSSNotebookContent(client, project_key, notebook_name, content)#

The content of a Jupyter Notebook.

This is the actual notebook data, see the nbformat doc .

Important

Do not instantiate directly, use dataikuapi.dss.jupyternotebook.DSSJupyterNotebook.get_content()

get_raw()#

Get the raw content of this Jupyter notebook.

The content comprises metadata, cells, notebook format info.

Returns:

a dict containing the full content of a notebook. Notable fields are:

  • metadata : the metadata of the notebook, as a dict (see get_metadata())

  • nbformat and nbformat_minor : the version of the notebook format

  • cells : list of cells, each one a dict (see get_cells())

Return type:

dict

get_metadata()#

Get the metadata associated to this Jupyter notebook.

Returns:

the Jupyter metadata of the notebook, with fields:

  • kernelspec : identification of the kernel used to run the notebook

  • creator : name of the user that created the notebook

  • createdOn : timestamp of creation, in milliseconds

  • modifiedBy : name of last modifier

  • language_info : information on the language of the notebook

Return type:

dict

get_cells()#

Get the cells of this Jupyter notebook.

Returns:

a list of cells, as defined by Jupyter. Each cell is a dict, with notable fields:

  • cell_type : type of cell, for example ‘code’

  • metadata : notebook metadata in the cell

  • executionCount : index of the last run of this cell

  • source : content of the cell, as a list of string

  • output : list of outputs of the last run of the cell, as a list of dict with fields output_type, name and text. Exact contents and meaning depend on the cell type.

Return type:

list[dict]

save()#

Save the content of this Jupyter notebook.

class dataikuapi.dss.notebook.DSSNotebook(client, project_key, notebook_name, state=None)#

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

unload(session_id=None)#

Stop this Jupyter notebook and release its resources.

get_state()#

Get the metadata associated to this Jupyter notebook.

get_sessions()#

Get the list of running sessions of this Jupyter notebook.

get_object_discussions()#

Get a handle to manage discussions on the notebook.

Returns:

the handle to manage discussions

Return type:

dataikuapi.dss.discussion.DSSObjectDiscussions

class dataikuapi.dss.admin.DSSGlobalApiKey(client, key, id_)#

A global API key on the DSS instance

delete()#

Delete the api key

Note

This call requires an API key with admin rights

get_definition()#

Get the API key’s definition

Note

This call requires an API key with admin rights

Note

If the secure API keys feature is enabled, the secret key of this API key will not be present in the returned dict

Returns:

the API key definition, as a dict. The dict additionally contains the definition of the permissions attached to the key.

Return type:

dict

set_definition(definition)#

Set the API key’s definition

Note

This call requires an API key with admin rights

Important

You should only set_definition() using an object that you obtained through get_definition(), not create a new dict. You may not use this method to update the ‘key’ field.

Usage example

# make an API key able to create projects
key = client.get_global_api_key('my_api_key_secret')
definition = key.get_definition()
definition["globalPermissions"]["mayCreateProjects"] = True
key.set_definition(definition)
Parameters:

definition (dict) – the definition for the API key

class dataikuapi.dss.admin.DSSGlobalApiKeyListItem(client, data)#

An item in a list of global API keys.

Important

Do not instantiate directly, use dataikuapi.DSSClient.list_global_api_keys() instead.

to_global_api_key()#

Gets a handle corresponding to this item

Return type:

DSSGlobalApiKey

property id#

Get the identifier of the API key

Return type:

string

property user_for_impersonation#

Get the user associated to the API key

Return type:

string

property key#

Get the API key

If the secure API keys feature is enabled, this key field will not be available

Return type:

string

property label#

Get the label of the API key

Return type:

string

property description#

Get the description of the API key

Return type:

string

property created_on#

Get the timestamp of when the API key was created

Return type:

datetime.datetime

property created_by#

Get the login of the user who created the API key

Return type:

string

class dataikuapi.dss.admin.DSSGlobalUsageSummary(data)#

The summary of the usage of the DSS instance.

Important

Do not instantiate directly, use dataikuapi.DSSClient.get_global_usage_summary() instead.

property raw#

Get the usage summary structure

The summary report has top-level fields per object type, like projectSummaries or datasets, each containing counts, usually a all global count, then several XXXXByType dict with counts by object sub-type (for example, for datasets the sub-type would be the type of the connection they’re using)

Return type:

dict

property projects_count#

Get the number of projects on the instance

Return type:

int

property total_datasets_count#

Get the number of datasets on the instance

Return type:

int

property total_recipes_count#

Get the number of recipes on the instance

Return type:

int

property total_jupyter_notebooks_count#

Get the number of code nobteooks on the instance

Return type:

int

property total_sql_notebooks_count#

Get the number of sql notebooks on the instance

Return type:

int

property total_scenarios_count#

Get the number of scenarios on the instance

Return type:

int

property total_active_with_trigger_scenarios_count#

Get the number of active scenarios on the instance

Return type:

int

class dataikuapi.dss.admin.DSSPersonalApiKey(client, key, id_)#

A personal API key on the DSS instance.

Important

Do not instantiate directly, use dataikuapi.DSSClient.get_personal_api_key() instead.

get_definition()#

Get the API key’s definition

Returns:

the personal API key definition, as a dict. The login of the user of this personal key is in a user field.

Return type:

dict

set_definition(definition)#

Set the API key’s definition

Note

Only the label and description of the key can be updated.

Important

You should only set_definition() using an object that you obtained through get_definition(), not create a new dict. You may not use this method to update the ‘key’ field.

Usage example

# update an API key label
key = client.get_personal_api_key('my_api_key_id')
definition = key.get_definition()
definition["label"] = "My New Label"
key.set_definition(definition)
Parameters:

definition (dict) – the definition for the API key

delete()#

Delete the API key

class dataikuapi.dss.admin.DSSPersonalApiKeyListItem(client, data)#

An item in a list of personal API key.

to_personal_api_key()#

Gets a handle corresponding to this item

Return type:

DSSPersonalApiKey

property id#

Get the identifier of the API key

Return type:

string

property user#

Get the user associated to the API key

Return type:

string

property key#

Get the API key

If the secure API keys feature is enabled, this key field will not be available

Return type:

string

property label#

Get the label of the API key

Return type:

string

property description#

Get the description of the API key

Return type:

string

property created_on#

Get the timestamp of when the API key was created

Return type:

datetime.datetime

property created_by#

Get the login of the user who created the API key

Return type:

string