Skip to content

Commit feafa0a

Browse files
committed
Add a small helper to easily update project variables
1 parent bc97339 commit feafa0a

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

dataikuapi/dss/project.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -568,6 +568,21 @@ def set_variables(self, obj):
568568
self.client._perform_empty(
569569
"PUT", "/projects/%s/variables/" % self.project_key, body=obj)
570570

571+
572+
def update_variables(self, variables, type="standard"):
573+
"""
574+
Updates a set of variables for this project
575+
576+
:param variables dict: a dict of variable name -> value to set. Keys of the dict must be strings.
577+
Values in the dict can be strings, numbers, booleans, lists or dicts
578+
:param type str: Can be "standard" to update regular variables or "local" to update local-only
579+
variables that are not part of bundles for this project
580+
"""
581+
582+
current_variables = self.get_variables()
583+
current_variables[type].update(variables)
584+
self.set_variables(current_variables)
585+
571586
########################################################
572587
# API Services
573588
########################################################

0 commit comments

Comments
 (0)