Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions HISTORY.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@ Changelog
==========



13.0.0 (2024-06-26)
---------------------

* Initial release for DSS 13.0.0

12.6.4 (2024-06-12)
---------------------

Expand Down
16 changes: 16 additions & 0 deletions dataikuapi/apinode_admin_client.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import json

from .apinode_admin.service import APINodeService
from .apinode_admin.auth import APINodeAuth
from .utils import DataikuException
Expand Down Expand Up @@ -102,3 +104,17 @@ def clear_model_cache(self):
Clear the model cache
"""
self._perform_empty("DELETE", "model-cache")

def clean_unused_services_and_generations(self):
"""
Deletes disabled services, unused generations and unused code environments
"""
resp = self._perform_json("DELETE", "services-clean-unused")
print(json.dumps(resp, indent=4))

def clean_code_env_cache(self):
"""
Deletes unused code envs from cache
"""
resp = self._perform_json("DELETE", "cached-code-envs")
print(json.dumps(resp, indent=4))
53 changes: 52 additions & 1 deletion dataikuapi/dss/apideployer.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def create_infra(self, infra_id, stage, type, govern_check_policy="NO_CHECK"):

: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, K8S, AZURE_ML, SAGEMAKER or VERTEX_AI
:param str type: STATIC, K8S, AZURE_ML, SAGEMAKER, SNOWPARK or VERTEX_AI
:param str govern_check_policy: PREVENT, WARN, or NO_CHECK depending if the deployer will check whether the saved model versions deployed on this infrastructure has to be managed and approved in Dataiku Govern
:rtype: :class:`DSSAPIDeployerInfra`
"""
Expand Down Expand Up @@ -150,6 +150,9 @@ def get_service(self, service_id):
"""
return DSSAPIDeployerService(self.client, service_id)




###############################################
# Infrastructures
###############################################
Expand Down Expand Up @@ -397,6 +400,54 @@ def get_open_api(self):
return DSSAPIDeployerDeploymentOpenApi(open_api)


def run_test_queries(self, endpoint_id=None, test_queries=None):
"""
Runs test queries on a deployment and returns results as a dict

:param str endpoint_id: Mandatory if the deployment has multiple endpoints
:param list test_queries: Queries as str, formatted as [{"q": {"features": {"feat_1": "value", ...}}, {...}, ... ].
If left to None, the test queries of the current version of the service will be used.
:rtype: dict

Usage example

.. code-block:: python

import dataiku

client = dataiku.api_client()
deployer = client.get_apideployer()
deployment = deployer.get_deployment('service14');

test_queries = [{'q': {'features': {
'Pclass': '200',
'Sex': 'male',
'Age': '22',
'Embarked': 'S'
}}}]

# run existing test queries on deployement endpoint (if unique, else error)
test_queries_result = deployment.run_test_queries()

# run specified test queries on deployement "survived" endpoint
test_queries_result = deployment.run_test_queries(endpoint_id="survived", test_queries=test_queries)

# run existing test queries on deployement "survived" endpoint
test_queries_result = deployment.run_test_queries(endpoint_id="survived")

# run specified test queries on deployement endpoint (if unique, else error)
test_queries_result = deployment.run_test_queries(test_queries=test_queries)

"""
settings = {}
if endpoint_id is not None:
settings["endpointIdParam"] = endpoint_id
if test_queries is not None:
settings["testQueriesParam"] = json.dumps(test_queries)

return self.client._perform_json("POST", "/api-deployer/deployments/%s/actions/run-test-queries" % self.deployment_id, params=settings)


class DSSAPIDeployerDeploymentSettings(object):
"""
The settings of an API Deployer deployment.
Expand Down
Empty file.
Loading