Skip to content

Commit a8cf85a

Browse files
Thibaud Baaslpenet
authored andcommitted
FM: Review feedback on InstanceSettingsTemplates
1 parent 9e2b9bb commit a8cf85a

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

dataikuapi/fm/instancesettingstemplates.py

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,23 @@ def with_setup_actions(self, setup_actions):
3838
self.data["setupActions"] = setup_actions
3939
return self
4040

41-
def with_license(self, license):
42-
self.data["license"] = license
41+
def with_license(self, license_file_path=None, license_string=None):
42+
"""
43+
Override global license
44+
45+
:param str license_file_path: Optional, load the license from a json file
46+
:param str license_string: Optional, load the license from a json string
47+
"""
48+
if license_file_path is not None:
49+
with open(license_file_path) as json_file:
50+
license = json.load(json_file)
51+
elif license_string is not None:
52+
license = json.loads(license_string)
53+
else:
54+
raise ValueError(
55+
"a valid license_file_path or license_string needs to be provided"
56+
)
57+
self.data["license"] = json.dumps(license, indent=2)
4358
return self
4459

4560

@@ -211,7 +226,7 @@ def add_setup_action(self, setup_action):
211226
:param object setup_action: a :class:`dataikuapi.fm.instancesettingstemplates.FMSetupAction`
212227
"""
213228
self.ist_data["setupActions"].append(setup_action)
214-
self.save()
229+
return self
215230

216231

217232
class FMSetupAction(dict):

0 commit comments

Comments
 (0)