Skip to content

Commit 3e2b87b

Browse files
authored
Merge pull request #157 from dataiku/perso/spic/dss-gh-integration
Govern integration in DSS
2 parents 51a981e + 0ea2b43 commit 3e2b87b

File tree

1 file changed

+20
-4
lines changed

1 file changed

+20
-4
lines changed

dataikuapi/dss/apideployer.py

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ def get_deployment(self, deployment_id):
3636
"""
3737
return DSSAPIDeployerDeployment(self.client, deployment_id)
3838

39-
def create_deployment(self, deployment_id, service_id, infra_id, version):
39+
def create_deployment(self, deployment_id, service_id, infra_id, version, ignore_warnings=False):
4040
"""
4141
Creates a deployment and returns the handle to interact with it. The returned deployment
4242
is not yet started and you need to call :meth:`~DSSAPIDeployerDeployment.start_update`
@@ -45,6 +45,7 @@ def create_deployment(self, deployment_id, service_id, infra_id, version):
4545
:param str service_id: Identifier of the API Service to target
4646
:param str infra_id: Identifier of the deployment infrastructure to use
4747
:param str version_id: Identifier of the API Service version to deploy
48+
:param boolean ignore_warnings: ignore warnings concerning the governance status of the model version(s) to deploy
4849
:rtype: :class:`DSSAPIDeployerDeployment`
4950
"""
5051
settings = {
@@ -53,7 +54,7 @@ def create_deployment(self, deployment_id, service_id, infra_id, version):
5354
"infraId" : infra_id,
5455
"version" : version
5556
}
56-
self.client._perform_json("POST", "/api-deployer/deployments", body=settings)
57+
self.client._perform_json("POST", "/api-deployer/deployments", params={"ignoreWarnings": ignore_warnings}, body=settings)
5758
return self.get_deployment(deployment_id)
5859

5960
def list_stages(self):
@@ -81,19 +82,21 @@ def list_infras(self, as_objects=True):
8182
else:
8283
return l
8384

84-
def create_infra(self, infra_id, stage, type):
85+
def create_infra(self, infra_id, stage, type, govern_check_policy="NO_CHECK"):
8586
"""
8687
Creates a new infrastructure on the API Deployer and returns the handle to interact with it.
8788
8889
:param str infra_id: Unique Identifier of the infra to create
8990
:param str stage: Infrastructure stage. Stages are configurable on each API Deployer
9091
:param str type: STATIC or KUBERNETES
92+
:param str govern_check_policy: PREVENT, WARN, or NO_CHECK depending if the deployer will check wether the saved model versions deployed on this infrastructure has to be managed and approved in Dataiku Govern
9193
:rtype: :class:`DSSAPIDeployerInfra`
9294
"""
9395
settings = {
9496
"id": infra_id,
9597
"stage": stage,
9698
"type": type,
99+
"govern_check_policy": govern_check_policy,
97100
}
98101
self.client._perform_json("POST", "/api-deployer/infras", body=settings)
99102
return self.get_infra(infra_id)
@@ -308,6 +311,16 @@ def get_status(self):
308311

309312
return DSSAPIDeployerDeploymentStatus(self.client, self.deployment_id, light, heavy)
310313

314+
def get_governance_status(self, version=""):
315+
"""
316+
Returns the governance status about this deployment if applicable
317+
It covers all the embedded model versions
318+
319+
:param str version: (Optional) The specific package version of the published service to get status from. If empty, consider all the versions used in the deployment generation mapping.
320+
:rtype: dict InforMessages containing the governance status
321+
"""
322+
return self.client._perform_json("GET", "/api-deployer/deployments/%s/governance-status" % (self.deployment_id), params={ "version": version })
323+
311324
def get_settings(self):
312325
"""
313326
Gets the settings of this deployment. If you want to modify the settings, you need to
@@ -381,12 +394,15 @@ def set_single_version(self, version):
381394
"generation": version
382395
}
383396

384-
def save(self):
397+
def save(self, ignore_warnings=False):
385398
"""
386399
Saves back these settings to the deployment
400+
401+
:param boolean ignore_warnings: ignore warnings concerning the governance status of the model version(s) to deploy
387402
"""
388403
self.client._perform_empty(
389404
"PUT", "/api-deployer/deployments/%s/settings" % (self.deployment_id),
405+
params = { "ignoreWarnings" : ignore_warnings },
390406
body = self.settings)
391407

392408

0 commit comments

Comments
 (0)