Plugins#
- class dataikuapi.dss.plugin.DSSPlugin(client, plugin_id)#
A plugin on the DSS instance.
Important
Do not instantiate directly, use
dataikuapi.DSSClient.get_plugin()
- get_settings()#
Get the plugin-level settings.
Note
This call requires an API key with either:
DSS admin permissions
permission to develop plugins
tied to a user with admin privileges on the plugin
- Returns:
a handle on the settings
- Return type:
- get_project_settings(project_key)#
Get the project-level settings.
Note
This call requires an API key with either:
DSS admin permissions
permission to develop plugins
tied to a user with admin privileges on the plugin
- Returns:
a handle on the project-level settings
- Return type:
DSSPluginProjectSettings
- create_code_env(python_interpreter=None, conda=False)#
Start the creation of the code env of the plugin.
Note
This call requires an API key with either:
DSS admin permissions
permission to develop plugins
tied to a user with admin privileges on the plugin
If not passing any value to python_interpreter, the default defined by the plugin will be used.
Usage example:
# create a default code env for the plugin plugin = client.get_plugin('the-plugin-id') future = plugin.create_code_env() creation = future.wait_for_result() # take the name of the new code env env_name = creation["envName"] # set it as the current plugin code env settings = plugin.get_settings() settings.set_code_env(env_name) settings.save()
- Parameters:
python_interpreter (string) – which version of python to use. Possible values: PYTHON27, PYTHON34, PYTHON35, PYTHON36, PYTHON37, PYTHON38, PYTHON39, PYTHON310, PYTHON311
conda (boolean) – if True use conda to create the code env, if False use virtualenv and pip.
- Returns:
a handle on the operation
- Return type:
- update_code_env()#
Start an update of the code env of the plugin.
Note
This call requires an API key with either:
DSS admin permissions
permission to develop plugins
tied to a user with admin privileges on the plugin
Usage example:
# update the plugin code env after updating the plugin plugin = client.get_plugin('the-plugin-id') future = plugin.update_code_env() future.wait_for_result()
- Returns:
a handle on the operation
- Return type:
- update_from_zip(fp)#
Update the plugin from a plugin archive (as a file object).
Note
This call requires an API key with either:
DSS admin permissions
permission to develop plugins
tied to a user with admin privileges on the plugin
- Parameters:
fp (file-like) – A file-like object pointing to a plugin archive zip
- start_update_from_zip(fp)#
Update the plugin from a plugin archive (as a file object). Returns immediately with a future representing the process done asynchronously
Note
This call requires an API key with either:
DSS admin permissions
permission to develop plugins
tied to a user with admin privileges on the plugin
- update_from_store()#
Update the plugin from the Dataiku plugin store.
Note
This call requires an API key with either:
DSS admin permissions
permission to develop plugins
tied to a user with admin privileges on the plugin
Usage example:
# update a plugin that was installed from the store plugin = client.get_plugin("my-plugin-id") future = plugin.update_from_store() future.wait_for_result()
- Returns:
a handle on the operation
- Return type:
- update_from_git(repository_url, checkout='master', subpath=None)#
Updates the plugin from a Git repository.
Note
DSS must be setup to allow access to the repository.
Note
This call requires an API key with either:
DSS admin permissions
permission to develop plugins
tied to a user with admin privileges on the plugin
Usage example:
# update a plugin that was installed from git plugin = client.get_plugin("my-plugin-id") future = plugin.update_from_git("git@github.com:myorg/myrepo") future.wait_for_result()
- Parameters:
repository_url (string) – URL of a Git remote
checkout (string) – branch/tag/SHA1 to commit. For example “master”
subpath (string) – Optional, path within the repository to use as plugin. Should contain a ‘plugin.json’ file
- Returns:
a handle on the operation
- Return type:
- list_usages(project_key=None)#
Get the list of usages of the plugin.
Note
This call requires an API key with either:
DSS admin permissions
permission to develop plugins
tied to a user with admin privileges on the plugin
- Parameters:
project_key (string) – optional key of project where to look for usages. Default is None and looking in all projects.
- Return type:
- delete(force=False)#
Delete a plugin.
Note
This call requires an API key with either:
DSS admin permissions
permission to develop plugins
tied to a user with admin privileges on the plugin
- Parameters:
force (boolean) – if True, plugin will be deleted even if usages are found or errors occurred during usages analysis. Default: False.
- Return type:
- list_files()#
Get the hierarchy of files in the plugin.
Note
Dev plugins only
Note
This call requires an API key with either:
DSS admin permissions
permission to develop plugins
tied to a user with admin privileges on the plugin
- Returns:
list of files or directories, each one a dict. Directories have a children field for recursion. Each dict has fields name and path (the path from the root of the plugin files)
- Return type:
dict
- get_file(path)#
Get a file from the plugin folder.
Note
Dev plugins only
Note
This call requires an API key with either:
DSS admin permissions
permission to develop plugins
tied to a user with admin privileges on the plugin
Usage example:
# read the code env desc of a plugin plugin = client.get_plugin("my-plugin-name") with plugin.get_file('code-env/python/desc.json') as fp: desc = json.load(fp)
- Parameters:
path (string) – the path of the file, relative to the root of the plugin
- Returns:
the file’s content
- Return type:
file-like
- put_file(path, f)#
Update a file in the plugin folder.
Note
Dev plugins only
Note
This call requires an API key with either:
DSS admin permissions
permission to develop plugins
tied to a user with admin privileges on the plugin
- Parameters:
f (file-like) – the file contents, as a file-like object
path (string) – the path of the file, relative ot the root of the plugin
- rename_file(path, new_name)#
Rename a file/folder in the plugin.
Note
Dev plugins only
- Parameters:
path (string) – the path of the file/folder, relative ot the root of the plugin
new_name (string) – the new name of the file/folder
- move_file(path, new_path)#
Move a file/folder in the plugin.
Note
Dev plugins only
Note
This call requires an API key with either:
DSS admin permissions
permission to develop plugins
tied to a user with admin privileges on the plugin
- Parameters:
path (string) – the path of the file/folder, relative ot the root of the plugin
new_path (string) – the new path relative at the root of the plugin
- class dataikuapi.dss.plugin.DSSPluginSettings(client, plugin_id, settings)#
The settings of a plugin.
Important
Do not instantiate directly, use
DSSPlugin.get_settings()
.- set_code_env(code_env_name)#
Set the name of the code env to use for this plugin.
- Parameters:
code_env_name (string) – name of a code env
- list_parameter_sets()#
List the parameter sets defined in this plugin.
- Return type:
list[
DSSPluginParameterSet
]
- get_parameter_set(parameter_set_name)#
Get a parameter set in this plugin.
- Parameters:
parameter_set_name (string) – name of the parameter set
- Returns:
a handle on the parameter set
- Return type:
- class dataikuapi.dss.plugin.DSSPluginParameterSet(plugin_settings, desc, settings, presets)#
A parameter set in a plugin.
Important
Do not instantiate directly, use
DSSPluginSettings.get_parameter_set()
or :meth:`DSSPluginSettings.list_parameter_sets().The values in this class can be modified directly, and changes will be taken into account when calling
DSSPluginSettings.save()
- property definable_inline#
Whether presets for this parameter set can be defined directly in the form of the datasets, recipes, …
- Return type:
bool
- property definable_at_project_level#
Whether presets for this parameter set can be defined at the project level
- Return type:
bool
- class dataikuapi.dss.plugin.DSSPluginUsage(data)#
Information on a usage of an element of a plugin.
Important
Do no instantiate directly, use
dataikuapi.dss.plugin.DSSPlugin.list_usages()
- property element_kind#
Get the type of the plugin component.
- Returns:
a kind of plugin component, like ‘python-clusters’, ‘python-connectors’, ‘python-fs-providers’, ‘webapps’, …
- Return type:
string
- property element_type#
Get the identifier of the plugin component.
- Return type:
string
- property object_id#
Get the identifier of the object using the plugin component.
- Return type:
string
- property object_type#
Get the type of the object using the plugin component.
- Returns:
a type of DSS object, like ‘CLUSTER’, ‘DATASET’, ‘RECIPE’, …
- Return type:
string
- property project_key#
Get the project key of the object using the plugin component.
- Return type:
string
- class dataikuapi.dss.plugin.DSSMissingType(data)#
Information on a type not found while analyzing usages of a plugin.
Missing types can occur when plugins stop defining a given component, for example during development, and DSS object still use the now-removed component.
Important
Do no instantiate directly, use
dataikuapi.dss.plugin.DSSPlugin.list_usages()
- property missing_type#
Get the type of the plugin component.
- Return type:
string
- property object_id#
Get the identifier of the object using the plugin component.
- Return type:
string
- property object_type#
Get the type of the object using the plugin component.
- Returns:
a type of DSS object, like ‘CLUSTER’, ‘DATASET’, ‘RECIPE’, …
- Return type:
string
- property project_key#
Get the project key of the object using the plugin component
- Return type:
string
- class dataikuapi.dss.plugin.DSSPluginUsages(data)#
Information on the usages of a plugin.
Important
Do no instantiate directly, use
dataikuapi.dss.plugin.DSSPlugin.list_usages()
Some custom types may not be found during usage analysis, typically when a plugin was removed but is still used. This prevents some detailed analysis and may hide some uses. This information is provided in
missing_types()
.- get_raw()#
Get the raw plugin usages.
- Returns:
a summary of the usages, as a dict with fields usages and missingTypes.
- Return type:
dict
- property usages#
Get the list of usages of components of the plugin.
- Returns:
list of usages, each a
DSSPluginUsage
- Return type:
list
- property missing_types#
Get the list of usages of missing components of the plugin.
- Returns:
list of missing component types, each a
DSSMissingType
- Return type:
list
- maybe_used()#
Whether the plugin maybe in use.
- Returns:
True if usages were found, False if errors were encountered during analysis
- Return type:
boolean
- class dataikuapi.dss.macro.DSSMacro(client, project_key, runnable_type, definition=None)#
A macro on the DSS instance.
Important
Do not instantiate directly, use
dataikuapi.dss.project.DSSProject.get_macro()
- get_definition()#
Get the macro definition.
Note
The adminParams field is empty unless the authentication of the API client covers admin rights.
- Returns:
the definition (read-only), as a dict. The fields mimic the contents of the runnable.json file of the macro.
- Return type:
dict
- run(params=None, admin_params=None, wait=True)#
Run the macro from the project
Note
If the authentication of the api client does not have admin rights, admin params are ignored.
Usage example:
# list all datasets on a connection. connection_name = 'filesystem_managed' macro = project.get_macro('pyrunnable_builtin-macros_list-datasets-using-connection') run_id = macro.run(params={'connection': connection_name}, wait=True) # the result of this builtin macro is of type RESULT_TABLE result = macro.get_result(run_id, as_type="json") for record in result["records"]: print("Used by %s" % record[0])
- Parameters:
params (dict) – parameters to the macro run (defaults to {})
admin_params (dict) – admin parameters to the macro run (defaults to {})
wait (boolean) – if True, the call blocks until the run is finished
- Returns:
a run identifier to use with
abort()
,get_status()
andget_result()
- Return type:
string
- abort(run_id)#
Abort a run of the macro.
- Parameters:
run_id (string) – a run identifier, as returned by
run()
- get_status(run_id)#
Poll the status of a run of the macro.
Note
Once the run is done, when
get_result()
is called, the run ceases to exist. Afterwardsget_status()
will answer that the run doesn’t exist.- Parameters:
run_id (string) – a run identifier, as returned by
run()
- Returns:
the status, as a dict. Whether the run is still ongoing can be assessed with the running field.
- Return type:
dict
- get_result(run_id, as_type=None)#
Retrieve the result of a run of the macro.
Note
If the macro is still running, an Exception is raised.
The type of the contents of the result to expect can be checked using
get_definition()
, in particular the “resultType” field.- Parameters:
run_id (string) – a run identifier, as returned by
run()
methodas_type (string) – if not None, one of ‘string’ or ‘json’. Use ‘json’ when the type of result advertised by the macro is RESULT_TABLE or JSON_OBJECT.
- Returns:
the contents of the result of the macro run, as a file-like is as_type is None; as a str if as_type is “string”; as an object if as_type is “json”.
- Return type:
file-like, or string