From 36ea10f1f47af35192d7b2866d082d2294fbe86e Mon Sep 17 00:00:00 2001 From: spicquenot Date: Thu, 15 Jul 2021 19:38:43 +0200 Subject: [PATCH 1/3] gh dss integration added govern check policy when creating api deployer infra --- dataikuapi/dss/apideployer.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/dataikuapi/dss/apideployer.py b/dataikuapi/dss/apideployer.py index 5f96c7b7..5675fea1 100644 --- a/dataikuapi/dss/apideployer.py +++ b/dataikuapi/dss/apideployer.py @@ -81,19 +81,21 @@ def list_infras(self, as_objects=True): else: return l - def create_infra(self, infra_id, stage, type): + def create_infra(self, infra_id, stage, type, govern_check_policy="NO_CHECK"): """ Creates a new infrastructure on the API Deployer and returns the handle to interact with it. :param str infra_id: Unique Identifier of the infra to create :param str stage: Infrastructure stage. Stages are configurable on each API Deployer :param str type: STATIC or KUBERNETES + :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 :rtype: :class:`DSSAPIDeployerInfra` """ settings = { "id": infra_id, "stage": stage, "type": type, + "govern_check_policy": govern_check_policy, } self.client._perform_json("POST", "/api-deployer/infras", body=settings) return self.get_infra(infra_id) From 3f4b9f47054e3ecd0263541a9326766f988c86a0 Mon Sep 17 00:00:00 2001 From: spicquenot Date: Tue, 20 Jul 2021 11:06:20 +0200 Subject: [PATCH 2/3] gh dss integration added ignore warning flag and added get governance status endpoint --- dataikuapi/dss/apideployer.py | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/dataikuapi/dss/apideployer.py b/dataikuapi/dss/apideployer.py index 5675fea1..1f0c6751 100644 --- a/dataikuapi/dss/apideployer.py +++ b/dataikuapi/dss/apideployer.py @@ -36,7 +36,7 @@ def get_deployment(self, deployment_id): """ return DSSAPIDeployerDeployment(self.client, deployment_id) - def create_deployment(self, deployment_id, service_id, infra_id, version): + def create_deployment(self, deployment_id, service_id, infra_id, version, ignore_warnings=False): """ Creates a deployment and returns the handle to interact with it. The returned deployment 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): :param str service_id: Identifier of the API Service to target :param str infra_id: Identifier of the deployment infrastructure to use :param str version_id: Identifier of the API Service version to deploy + :param boolean ignore_warnings: ignore warnings concerning the governance status of the model version(s) to deploy :rtype: :class:`DSSAPIDeployerDeployment` """ settings = { @@ -53,7 +54,7 @@ def create_deployment(self, deployment_id, service_id, infra_id, version): "infraId" : infra_id, "version" : version } - self.client._perform_json("POST", "/api-deployer/deployments", body=settings) + self.client._perform_json("POST", "/api-deployer/deployments", params={"ignoreWarnings": ignore_warnings}, body=settings) return self.get_deployment(deployment_id) def list_stages(self): @@ -310,6 +311,16 @@ def get_status(self): return DSSAPIDeployerDeploymentStatus(self.client, self.deployment_id, light, heavy) + def get_governance_status(self, version=""): + """ + Returns the governance status about this deployment if applicable + It covers all the embedded model versions + + :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. + :rtype: dict InforMessages containing the governance status + """ + return self.client._perform_json("POST", "/api-deployer/deployments/%s/governance-status" % (self.deployment_id), params={ "version": version }) + def get_settings(self): """ Gets the settings of this deployment. If you want to modify the settings, you need to @@ -383,12 +394,15 @@ def set_single_version(self, version): "generation": version } - def save(self): + def save(self, ignore_warnings=False): """ Saves back these settings to the deployment + + :param boolean ignore_warnings: ignore warnings concerning the governance status of the model version(s) to deploy """ self.client._perform_empty( "PUT", "/api-deployer/deployments/%s/settings" % (self.deployment_id), + params = { "ignoreWarnings" : ignore_warnings }, body = self.settings) From 0ea2b43bf4f72aea8280d260d418fa1c9e6774ab Mon Sep 17 00:00:00 2001 From: spicquenot Date: Thu, 12 Aug 2021 10:20:18 +0200 Subject: [PATCH 3/3] governance status fix endpoint --- dataikuapi/dss/apideployer.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dataikuapi/dss/apideployer.py b/dataikuapi/dss/apideployer.py index 1f0c6751..8e11f3f8 100644 --- a/dataikuapi/dss/apideployer.py +++ b/dataikuapi/dss/apideployer.py @@ -319,7 +319,7 @@ def get_governance_status(self, version=""): :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. :rtype: dict InforMessages containing the governance status """ - return self.client._perform_json("POST", "/api-deployer/deployments/%s/governance-status" % (self.deployment_id), params={ "version": version }) + return self.client._perform_json("GET", "/api-deployer/deployments/%s/governance-status" % (self.deployment_id), params={ "version": version }) def get_settings(self): """