Code Studios#
For usage information and examples, please see Code Studios.
- class dataikuapi.dss.codestudio.DSSCodeStudioObject(client, project_key, code_studio_id)#
A handle to manage a code studio in a project
Important
Do not instantiate directly, use
dataikuapi.dss.project.DSSProject.get_code_studio()
ordataikuapi.dss.project.DSSProject.create_code_studio()
instead- delete()#
Delete the code studio
- get_settings()#
Get the code studio’s definition
Usage example
# list code studios of some user for code_studio in project.list_code_studios(as_type="objects"): settings = code_studio.get_settings() if settings.owner == 'the_user_login': print("User owns code studio %s from template %s" % (settings.name, settings.template_id))
- Returns:
a handle to inspect the code studio definition
- Return type:
- get_status()#
Get the code studio’s state
Usage example
# print list of currently running code studios for code_studio in project.list_code_studios(as_type="objects"): status = code_studio.get_status() if status.state == 'RUNNING': settings = code_studio.get_settings() print("Code studio %s from template %s is running" % (settings.name, settings.template_id))
- Returns:
a handle to inspect the code studio state
- Return type:
- stop()#
Stop a running code studio
- Returns:
a future to wait on the stop, or None if already stopped
- Return type:
- restart()#
Start or restart a code studio
- Returns:
a future to wait on the start
- Return type:
- check_conflicts(zone)#
Checks whether the files in a zone of the code studio have conflicting changes with what the DSS instance has.
Usage example
# stop a code studio if there's no conflict in any zone status = code_studio.get_status() conflict_count = 0 for zone in status.get_zones(as_type="names"): conflicts = code_studio.check_conflicts(zone) conflict_count += len(conflicts.added) conflict_count += len(conflicts.modified) conflict_count += len(conflicts.deleted) if conflict_count == 0: code_studio.stop().wait_for_result()
- Parameters:
zone (string) – name of the zone to check (see
dataikuapi.dss.codestudio.DSSCodeStudioObjectStatus.get_zones()
)- Returns:
a summary of the conflicts that were found.
- Return type:
- pull_from_code_studio(zone)#
Copies the files from a zone of the code studio to the DSS instance
- Parameters:
zone (str) – name of the zone to pull (see
dataikuapi.dss.codestudio.DSSCodeStudioObjectStatus.get_zones()
)
- push_to_code_studio(zone)#
Copies the files from the DSS instance to a zone of the code studio
- Parameters:
zone (str) – name of the zone to push (see
dataikuapi.dss.codestudio.DSSCodeStudioObjectStatus.get_zones()
)- Returns:
a dictionary of {count: <number of files copied>, size: <total size copied>}
- Return type:
dict
- change_owner(new_owner)#
Allows to change the owner of the Code Studio
Note
You need to be either admin or owner of the Code Studio in order to change the owner.
- Parameters:
new_owner (str) – the id of the new owner
- Returns:
a handle on the updated code studio
- Return type:
- class dataikuapi.dss.codestudio.DSSCodeStudioObjectListItem(client, project_key, data)#
An item in a list of code studios.
Important
Do not instantiate this class, use
dataikuapi.dss.project.DSSProject.list_code_studios()
- to_code_studio()#
Get a handle to interact with this code studio
- Returns:
a handle on the code studio
- Return type:
- property name#
Get the name of the code studio
Note
The name is user-provided and not necessarily unique.
- Return type:
string
- property id#
Get the identifier of the code studio
Note
The id is generated by DSS upon creation and random.
- Return type:
string
- property owner#
Get the login of the owner of the code studio
- Return type:
string
- property template_id#
Get the identifier of the template that this code studio was created from
- Return type:
string
- property template_label#
Get the label of the template that this code studio was created from
- Return type:
string
- property template_description#
Get the description of the template that this code studio was created from
- Return type:
string
- class dataikuapi.dss.codestudio.DSSCodeStudioObjectSettings(client, project_key, code_studio_id, settings)#
Settings for a code studio
Important
Do not instantiate directly, use
dataikuapi.dss.codestudio.DSSCodeStudioObject.get_settings()
instead- get_raw()#
Gets all settings as a raw dictionary.
- Returns:
the settings, as a dict. The dict contains a templateId field indicating which code studio template was used to create this code studio.
- Return type:
dict
- property id#
Get the identifier of the code studio.
Note
The id is generated by DSS upon creation and random.
- Return type:
string
- property name#
Get the name of the code studio.
Note
The name is user-provided and not necessarily unique.
- Return type:
string
- property template_id#
Get the identifier of the template that the code studio was created from.
- Return type:
string
- property lib_name#
Get the name of the folder resource files of the code studio are stored in.
The path to the resources files is then “<dss_data_dir>/lib/code_studio/<project_key>/<lib_name>/”
- Return type:
string
- property owner#
Get the login of the owner of the code studio.
Only the owner of a code studio can use it. Administrators of the project can merely stop/start code studios, not use them.
- Return type:
string
- class dataikuapi.dss.codestudio.DSSCodeStudioObjectStatus(client, project_key, code_studio_id, status)#
Handle to inspect the status of a code studio
Important
Do not instantiate directly, use
dataikuapi.dss.codestudio.DSSCodeStudioObject.get_status()
instead- get_raw()#
Gets the status as a raw dict.
Note
Some fields are only defined when the code studio is running. For instance, exposed and syncedZones are empty when the code studio is not running.
- Returns:
the dict contains a state field indicating whether the code studio is STOPPED, STARTING, RUNNING or STOPPING. If RUNNING, then the dict holds additional information about the zones that can be synchronized inside the pod, and the ports of the pod that are exposed.
- Return type:
dict
- property state#
Get the current state of the code studio.
Possible values are STOPPED, STARTING, RUNNING, STOPPING
- Return type:
string
- property last_state_change#
Get the timestamp of the last change of the state.
- Returns:
a datetime, or None if the code studio was never started
- Return type:
datetime.datetime
- get_zones(as_type='names')#
Get the list of the zones synchronized inside the code studio
- Parameters:
as_type (string) – if set to “names”, then return a list of zone identifiers; if set to “objects”, then return a list of zone definitions
- Returns:
the list of zones, each one either a string (if as_type is “names), or a dict of with a id field.
- Return type:
list
- class dataikuapi.dss.codestudio.DSSCodeStudioObjectConflicts(zone, conflicts)#
Summary of the conflicts on zones of a code studio.
Note
Only conflicting files are listed, that is, files added, modified or deleted in the code studio for which the corresponding file in the DSS instance has been also added, modified or deleted.
- get_raw()#
Get the raw conflicts summary.
- Returns:
a summary of the conflicts that were found, as a dict. The top-level field is the zone checked, or ‘error’ if it wasn’t found. The dict should contain summary information about the count of changes, and commitFrom and commitTo hashes to identify the state of the files on the DSS instance at the time of the last sync to the code studio pod and now.
- Return type:
dict
- property is_error#
Whether fetching the conflicts failed.
Typically this can happen if the name of the zone(s) for which the conflicts where requested is invalid.
- Return type:
boolean
- property authors#
Get the authors of changes to the files.
- Returns:
a list of logins of users who modified the conflicting files in the DSS instance.
- Return type:
list[string]
- property added#
Get the list of files added in the code studio.
- Returns:
a list of paths to files that were added in the code studio and conflict with changes on the DSS instance.
- Return type:
list[string]
- property modified#
Get the list of files modified in the code studio.
- Returns:
a list of paths to files that were modified in the code studio and conflict with changes on the DSS instance.
- Return type:
list[string]
- property deleted#
Get the list of files deleted in the code studio.
- Returns:
a list of paths to files that were deleted in the code studio and conflict with changes on the DSS instance.
- Return type:
list[string]
- class dataikuapi.dss.admin.DSSCodeStudioTemplateListItem(client, data)#
An item in a list of code studio templates.
Important
Do not instantiate directly, use
dataikuapi.DSSClient.list_code_studio_templates()
- to_code_studio_template()#
Get the handle corresponding to this code studio template
- Return type:
- property label#
Get the label of the template
- Return type:
string
- property id#
Get the identifier of the template
- Return type:
string
- property build_for_configs#
Get the list of container configurations this template is built for
- Returns:
a list of configuration name
- Return type:
list[string]
- property last_built#
Get the timestamp of the last build of the template
- Returns:
a timestamp, or None if the template was never built
- Return type:
datetime.datetime
- class dataikuapi.dss.admin.DSSCodeStudioTemplate(client, template_id)#
A handle to interact with a code studio template on the DSS instance
Important
Do not instantiate directly, use
dataikuapi.DSSClient.get_code_studio_template()
.- get_settings()#
Get the template’s settings.
- Returns:
a
DSSCodeStudioTemplateSettings
object to interact with code studio template settings- Return type:
- build(disable_docker_cache=False)#
Build or rebuild the template.
Note
This call needs an API key which has an user to impersonate set, or a personal API key.
- Parameters:
disable_docker_cache (boolean) – if True, the image is build with the option –no-cache (optional, defaults to False)
- Returns:
a handle to the task of building the image
- Return type:
- class dataikuapi.dss.admin.DSSCodeStudioTemplateSettings(client, template_id, settings)#
The settings of a code studio template
Important
Do not instantiate directly, use
DSSCodeStudioTemplate.get_settings()
- get_raw()#
Gets all settings as a raw dictionary.
- Returns:
a reference to the raw settings, as a dict (not a copy). The dict contains a type field and the actual template settings in a params field.
- Return type:
dict
- get_built_for_all_container_confs()#
Whether the template an image for each container config
- Return type:
boolean
- get_built_container_confs()#
Get the list of container configs for which the template builds an image (if not all)
- Returns:
a list of container configuration names
- Return type:
list[string]
- set_built_container_confs(*configs, **kwargs)#
Set the list of container configs for which the template 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
- save()#
Saves the settings of the code studio template