Plugins¶
The API offers methods to:
Install plugins
Uninstall plugins and list their usages
Update plugins
Read and write plugin settings
Create and update plugin code envs
Installing plugins¶
From a Zip file¶
with open("myplugin.zip", "r") as f:
client.install_plugin_from_archive(f)
See install_plugin_from_archive()
for more details.
From the Dataiku plugin store¶
future = client.install_plugin_from_store("googlesheets")
future.wait_for_result()
See install_plugin_from_store()
for more details.
From a Git repository¶
future = client.install_plugin_from_git("[email protected]:myorg/myrepo")
future.wait_for_result()
See install_plugin_from_git()
for more details.
Uninstalling plugins¶
Listing usages of a plugin¶
plugin = client.get_plugin('my-plugin-id')
usages = plugin.list_usages()
See list_usages()
for more details.
Managing code envs¶
plugin = client.get_plugin("myplugin")
# Start creating the code env, and wait for it to be done
future = plugin.create_code_env()
result = future.wait_for_result()
# NB: If the plugin requires Python 3.6 for example, you will use something like:
# plugin.create_code_env(python_interpreter="PYTHON36")
# Now the code env is created, but we still need to configure the plugin to use it
settings = plugin.get_settings()
settings.set_code_env(result["envName"])
settings.save()
Handling settings¶
plugin = client.get_plugin("myplugin")
# Obtain the current settings
settings = plugin.get_settings()
raw_settings = settings.get_raw()
# Modify the settings
# ...
# And save them back
settings.save()
Reference documentation¶
-
class
dataikuapi.dss.plugin.
DSSPlugin
(client, plugin_id)¶ A plugin on the DSS instance
-
get_settings
()¶ Return the plugin-level settings
- Returns
-
create_code_env
(python_interpreter=None, conda=False)¶ Starts the creation of the code env of the plugin
- Returns
a
dataikuapi.dssfuture.DSSFuture
-
update_code_env
()¶ Starts an update of the code env of the plugin
- Returns
-
update_from_zip
(fp)¶ Updates the plugin from a plugin archive (as a file object)
- Parameters
fp (object) – A file-like object pointing to a plugin archive zip
-
update_from_git
(repository_url, checkout='master', subpath=None)¶ Updates the plugin from a Git repository. DSS must be setup to allow access to the repository.
- Parameters
repository_url (str) – URL of a Git remote
checkout (str) – branch/tag/SHA1 to commit. For example “master”
subpath (str) – Optional, path within the repository to use as plugin. Should contain a ‘plugin.json’ file
- Returns
-
list_usages
(project_key=None)¶ Get the list of usages of the plugin.
- Parameters
project_key (str) – optional key of project where to look for usages. Default is None and looking in all projects.
- Returns
-
delete
(force=False)¶ Delete a plugin.
If not forced (default), pre-deletion checks will be run (as by
prepare_delete()
and the deletion will be performed if and only if no usage of the plugin is detected and no error occurred during usages analysis.- Parameters
force (bool) – if True, plugin will be deleted even if usages are found or errors occurred during usages
analysis. Default is False. :return: a
dataikuapi.dssfuture.DSSFuture
-
list_files
()¶ Get the hierarchy of files in the plugin (dev plugins only)
-
get_file
(path)¶ Get a file from the plugin folder (dev plugins only)
- Parameters
path (str) – the path of the file, relative to the root of the plugin
- Returns
a file-like object containing the file’s content
-
put_file
(path, f)¶ Update a file in the plugin folder (dev plugins only)
- Parameters
f (file-like) – the file contents, as a file-like object
path (str) – the path of the file, relative ot the root of the plugin
-
rename_file
(path, new_name)¶ Rename a file/folder in the plugin
- Parameters
path (str) – the path of the file/folder, relative ot the root of the plugin
new_name (str) – the new name of the file/folder
-
move_file
(path, new_path)¶ Move a file/folder in the plugin
- Parameters
path (str) – the path of the file/folder, relative ot the root of the plugin
new_path (str) – the new path relative at the root of the plugin
-
-
class
dataikuapi.dss.plugin.
DSSPluginSettings
(client, plugin_id, settings)¶ The settings of a plugin.
-
get_raw
()¶ Returns the raw settings object
-
set_code_env
(code_env_name)¶ Sets the name of the code env to use for this plugin
-
save
()¶ Saves the settings to DSS
-
-
class
dataikuapi.dss.plugin.
DSSPluginUsage
(data)¶ Information on a usage of an element of a plugin.
Has the following properties: - element_kind: webapps, python-formats,… - element_type: type name of the element - object_id: id of the object using the plugin element. Can be None. - object_type: type of the object using the plugin element. Can be None. - project_key: project key of the object using the plugin element. Can be None.
-
class
dataikuapi.dss.plugin.
DSSMissingType
(data)¶ Information on a type not found while analyzing usages of a plugin.
Has the following properties: - missing type: the missing type - object_id: id of the object depending on the missing type. Can be None. - object_type: type of the object depending on the missing type. Can be None. - project_key: project key of the object depending on the missing type. Can be None.
-
class
dataikuapi.dss.plugin.
DSSPluginUsages
(data)¶ Information on the usages of a plugin.
Has the following properties: - usages (list of
DSSPluginUsage
) - missing_types (a list ofDSSMissingType
).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 plugin usages as a dictionary. :rtype: dict
-
maybe_used
()¶ Returns true if the plugin maybe in use, as usages of the plugin were found, or errors encountered during analysis. :return:
-