Skip to content

Commit c643875

Browse files
committed
More ML API
1 parent 5cc5faa commit c643875

File tree

5 files changed

+553
-31
lines changed

5 files changed

+553
-31
lines changed

dataikuapi/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@
33
from .apinode_client import APINodeClient
44
from .apinode_admin_client import APINodeAdminClient
55

6-
from .dss.recipe import GroupingRecipeCreator, JoinRecipeCreator, StackRecipeCreator, WindowRecipeCreator, SyncRecipeCreator, SamplingRecipeCreator, SQLQueryRecipeCreator, CodeRecipeCreator, SplitRecipeCreator, SortRecipeCreator, TopNRecipeCreator, DistinctRecipeCreator, DownloadRecipeCreator
6+
from .dss.recipe import GroupingRecipeCreator, JoinRecipeCreator, StackRecipeCreator, WindowRecipeCreator, SyncRecipeCreator, SamplingRecipeCreator, SQLQueryRecipeCreator, CodeRecipeCreator, SplitRecipeCreator, SortRecipeCreator, TopNRecipeCreator, DistinctRecipeCreator, DownloadRecipeCreator, PredictionScoringRecipeCreator, ClusteringScoringRecipeCreator
77

88
from .dss.admin import DSSUserImpersonationRule, DSSGroupImpersonationRule

dataikuapi/dss/apiservice.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,26 @@
1+
import json
2+
3+
class DSSAPIServiceSettings(object):
4+
def __init__(self, client, project_key, service_id, settings):
5+
self.client = client
6+
self.project_key = project_key
7+
self.service_id = service_id
8+
self.settings = settings
9+
10+
def add_prediction_endpoint(self, endpoint_id, saved_model_id):
11+
self.settings["endpoints"].append({
12+
"id" : endpoint_id,
13+
"type" : "STD_PREDICTION",
14+
"modelRef": saved_model_id
15+
})
16+
17+
def save(self):
18+
"""Saves back these settings to the API Service"""
19+
print("SAVING: %s" % json.dumps(self.settings, indent=2))
20+
self.client._perform_empty(
21+
"PUT", "/projects/%s/apiservices/%s/settings" % (self.project_key, self.service_id),
22+
body = self.settings)
23+
124

225
class DSSAPIService(object):
326
"""
@@ -8,6 +31,13 @@ def __init__(self, client, project_key, service_id):
831
self.project_key = project_key
932
self.service_id = service_id
1033

34+
def get_settings(self):
35+
"""Gets the settings of this API Service"""
36+
settings = self.client._perform_json(
37+
"GET", "/projects/%s/apiservices/%s/settings" % (self.project_key, self.service_id))
38+
39+
return DSSAPIServiceSettings(self.client, self.project_key, self.service_id, settings)
40+
1141
def list_packages(self):
1242
"""
1343
List the packages of this API services

0 commit comments

Comments
 (0)