Code envs#
For usage information and examples, see Code envs
- class dataikuapi.dss.admin.DSSCodeEnv(client, env_lang, env_name)#
A code env on the DSS instance.
Important
Do not instantiate directly, use
dataikuapi.DSSClient.get_code_env()
instead.- delete()#
Delete the code env
Note
This call requires an API key with Manage all code envs permission
- get_definition()#
Get the code env’s definition
Caution
Deprecated, use
get_settings()
insteadNote
This call requires an API key with Create code envs or Manage all code envs permission
- Returns:
the code env definition
- Return type:
dict
- set_definition(env)#
Set the code env’s definition. The definition should come from a call to
get_definition()
Caution
Deprecated, use
get_settings()
thenDSSDesignCodeEnvSettings.save()
orDSSAutomationCodeEnvSettings.save()
insteadFields that can be updated in design node:
env.permissions, env.usableByAll, env.desc.owner
env.specCondaEnvironment, env.specPackageList, env.externalCondaEnvName, env.desc.installCorePackages, env.desc.corePackagesSet, env.desc.installJupyterSupport, env.desc.yarnPythonBin, env.desc.yarnRBin env.desc.envSettings, env.desc.allContainerConfs, env.desc.containerConfs, env.desc.allSparkKubernetesConfs, env.desc.sparkKubernetesConfs
Fields that can be updated in automation node (where {version} is the updated version):
env.permissions, env.usableByAll, env.owner, env.envSettings
env.{version}.specCondaEnvironment, env.{version}.specPackageList, env.{version}.externalCondaEnvName, env.{version}.desc.installCorePackages, env.{version}.corePackagesSet, env.{version}.desc.installJupyterSupport env.{version}.desc.yarnPythonBin, env.{version}.desc.yarnRBin, env.{version}.desc.allContainerConfs, env.{version}.desc.containerConfs, env.{version}.desc.allSparkKubernetesConfs, env.{version}.{version}.desc.sparkKubernetesConfs
Note
This call requires an API key with Create code envs or Manage all code envs permission
Important
You should only
set_definition()
using an object that you obtained throughget_definition()
, not create a new dict.- Parameters:
data (dict) – a code env definition
- Returns:
the updated code env definition
- Return type:
dict
- get_version_for_project(project_key)#
Resolve the code env version for a given project
Note
Version will only be non-empty for versioned code envs actually used by the project
- Parameters:
project_key (string) – project to get the version for
- Returns:
the code env version full reference for the version of the code env that the project use, as a dict. The dict should contains a version field holding the identifier of the version and a bundleId field for the identifier of the active bundle in the project.
- Return type:
dict
- get_settings()#
Get the settings of this code env.
Important
You must use
DSSCodeEnvSettings.save()
on the returned object to make your changes effective on the code env.# Example: setting the required packagd codeenv = client.get_code_env("PYTHON", "code_env_name") settings = codeenv.get_settings() settings.set_required_packages("dash==2.0.0", "bokeh<2.0") settings.save() # then proceed to update_packages()
- Return type:
- set_jupyter_support(active)#
Update the code env jupyter support
Note
This call requires an API key with Create code envs or Manage all code envs permission
- Parameters:
active (boolean) – True to activate jupyter support, False to deactivate
- update_packages(force_rebuild_env=False)#
Update the code env packages so that it matches its spec
Note
This call requires an API key with Create code envs or Manage all code envs permission
- Parameters:
force_rebuild_env (boolean) – whether to rebuild the code env from scratch
- Returns:
list of messages collected during the operation. Fields are:
anyMessage : whether there is at least 1 message
success, warning, error and fatal : whether there is at least one message of the corresponding category
messages : list of messages. Each message is a dict, with at least severity and message sufields.
- Return type:
dict
- update_images(env_version=None)#
Rebuild the docker image of the code env
Note
This call requires an API key with admin rights
- Parameters:
env_version (string) – (optional) version of the code env. Applies only to versioned code envs.
- Returns:
list of messages collected during the operation. Fields are:
anyMessage : whether there is at least 1 message
success, warning, error and fatal : whether there is at least one message of the corresponding category
messages : list of messages. Each message is a dict, with at least severity and message sufields.
- Return type:
dict
- list_usages()#
List usages of the code env in the instance
- Returns:
a list of objects where the code env is used. Each usage has is a dict with at least:
envUsage : type of usage. Possible values: PROJECT, RECIPE, NOTEBOOK, PLUGIN, SCENARIO, SCENARIO_STEP, SCENARIO_TRIGGER, DATASET_METRIC, DATASET_CHECK, DATASET, WEBAPP, REPORT, API_SERVICE_ENDPOINT, SAVED_MODEL, MODEL, CODE_STUDIO_TEMPLATE
projectKey and objectId : identifier of the object where the code env is used
- Return type:
list[dict]
- list_logs()#
List logs of the code env in the instance
- Returns:
a list of log descriptions. Each log description as a dict with at least a name field for the name of the log file.
- Return type:
list[dict]
- get_log(log_name)#
Get the logs of the code env
- Parameters:
log_name (string) – name of the log to fetch
- Returns:
the raw log
- Return type:
string
- class dataikuapi.dss.admin.DSSDesignCodeEnvSettings(codeenv, settings)#
Base settings class for a DSS code env on a design node.
Important
Do not instantiate directly, use
DSSCodeEnv.get_settings()
instead.Use
save()
to save your changes- get_raw()#
Get the raw code env settings
The structure depends on the type of code env. The data consists of the definition as it is persisted on disk, the lists of requested packages and resource script (if relevant).
- Returns:
code env settings
- Return type:
dict
- built_for_all_spark_kubernetes_confs()#
Whether the code env creates an image for each managed Spark over Kubernetes config
- property env_lang#
Get the language of the code env
- Returns:
a language (possible values: PYTHON, R)
- Return type:
string
- property env_name#
Get the name of the code env
- Return type:
string
- get_built_container_confs()#
Get the list of container configs for which the code env builds an image (if not all)
- Returns:
a list of container configuration names
- Return type:
list[string]
- get_built_for_all_container_confs()#
Whether the code env creates an image for each container config
- Return type:
boolean
- get_built_spark_kubernetes_confs()#
Get the list of managed Spark over Kubernetes configs for which the code env builds an image (if not all)
- Returns:
a list of spark configuration names
- Return type:
list[string]
- get_required_conda_spec(as_list=False)#
Get the list of required conda packages, as a single string
- Parameters:
as_list (boolean) – if True, return the spec as a list of lines; if False, return as a single multiline string
- Returns:
a list of packages specifications
- Return type:
list[string] or string
- get_required_packages(as_list=False)#
Get the list of required packages, as a single string
- Parameters:
as_list (boolean) – if True, return the spec as a list of lines; if False, return as a single multiline string
- Returns:
a list of packages specifications
- Return type:
list[string] or string
- save()#
Save the changes to the code env’s settings
- set_built_container_confs(*configs, **kwargs)#
Set the list of container configs for which the code env builds an image
- Parameters:
all (boolean) – if True, an image is built for each config
configs (list[string]) – list of configuration names to build images for
- set_built_spark_kubernetes_confs(*configs, **kwargs)#
Set the list of managed Spark over Kubernetes configs for which the code env builds an image
- Parameters:
all (boolean) – if True, an image is built for each config
configs (list[string]) – list of configuration names to build images for
- set_required_conda_spec(*spec)#
Set the list of required conda packages
- Parameters:
spec (list[string]) – a list of packages specifications
- set_required_packages(*packages)#
Set the list of required packages
- Parameters:
packages (list[string]) – a list of packages specifications
- class dataikuapi.dss.admin.DSSAutomationCodeEnvSettings(codeenv, settings)#
Base settings class for a DSS code env on an automation node.
Important
Do not instantiate directly, use
DSSCodeEnv.get_settings()
instead.Use
save()
to save your changes- get_raw()#
Get the raw code env settings
The structure depends on the type of code env. The data consists of the definition as it is persisted on disk, and the identifiers of the versions of the code env, or the spec of the unique version if the code env is not versioned. To access the lists of requested packages or resource scripts. Use
get_version()
.- Returns:
code env settings
- Return type:
dict
- get_version(version_id=None)#
Get a specific code env version (for versioned envs) or the single version
- Parameters:
version_id (string) – for versioned code env, identifier of the desired version
- Returns:
the settings of a code env version
- Return type:
- built_for_all_spark_kubernetes_confs()#
Whether the code env creates an image for each managed Spark over Kubernetes config
- property env_lang#
Get the language of the code env
- Returns:
a language (possible values: PYTHON, R)
- Return type:
string
- property env_name#
Get the name of the code env
- Return type:
string
- get_built_container_confs()#
Get the list of container configs for which the code env builds an image (if not all)
- Returns:
a list of container configuration names
- Return type:
list[string]
- get_built_for_all_container_confs()#
Whether the code env creates an image for each container config
- Return type:
boolean
- get_built_spark_kubernetes_confs()#
Get the list of managed Spark over Kubernetes configs for which the code env builds an image (if not all)
- Returns:
a list of spark configuration names
- Return type:
list[string]
- save()#
Save the changes to the code env’s settings
- set_built_container_confs(*configs, **kwargs)#
Set the list of container configs for which the code env builds an image
- Parameters:
all (boolean) – if True, an image is built for each config
configs (list[string]) – list of configuration names to build images for
- set_built_spark_kubernetes_confs(*configs, **kwargs)#
Set the list of managed Spark over Kubernetes configs for which the code env builds an image
- Parameters:
all (boolean) – if True, an image is built for each config
configs (list[string]) – list of configuration names to build images for
- class dataikuapi.dss.admin.DSSAutomationCodeEnvVersionSettings(codeenv_settings, version_settings)#
Base settings class for a DSS code env version on an automation node.
Important
Do not instantiate directly, use
DSSAutomationCodeEnvSettings.get_version()
instead.Use
save()
on theDSSAutomationCodeEnvSettings
to save your changes- get_raw()#
Get the raw code env version settings
The structure depends on the type of code env. The dict contains a versionId field, and the definition of the code env requirements.
- Returns:
code env settings
- Return type:
dict
- get_required_conda_spec(as_list=False)#
Get the list of required conda packages, as a single string
- Parameters:
as_list (boolean) – if True, return the spec as a list of lines; if False, return as a single multiline string
- Returns:
a list of packages specifications
- Return type:
list[string] or string
- get_required_packages(as_list=False)#
Get the list of required packages, as a single string
- Parameters:
as_list (boolean) – if True, return the spec as a list of lines; if False, return as a single multiline string
- Returns:
a list of packages specifications
- Return type:
list[string] or string
- set_required_conda_spec(*spec)#
Set the list of required conda packages
- Parameters:
spec (list[string]) – a list of packages specifications
- set_required_packages(*packages)#
Set the list of required packages
- Parameters:
packages (list[string]) – a list of packages specifications