Skip to content

Commit 9b322c0

Browse files
authored
Merge pull request #220 from dataiku/feature/sc-81874-add-a-method-to-un-set-a-dataset-as-a-feature
Feature store public API
2 parents ef2ca0a + 369802c commit 9b322c0

File tree

3 files changed

+73
-0
lines changed

3 files changed

+73
-0
lines changed

dataikuapi/dss/dataset.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -737,6 +737,25 @@ def add_time_partitioning_dimension(self, dim_name, period="DAY"):
737737
def add_raw_schema_column(self, column):
738738
self.settings["schema"]["columns"].append(column)
739739

740+
@property
741+
def is_feature_group(self):
742+
"""
743+
Indicates whether the Dataset is defined as a Feature Group, available in the Feature Store.
744+
745+
:rtype: bool
746+
"""
747+
return self.settings["featureGroup"]
748+
749+
def set_feature_group(self, status):
750+
"""
751+
(Un)sets the dataset as a Feature Group, available in the Feature Store.
752+
Changes of this property will be applied when calling :meth:`save` and require the "Manage Feature Store" permission.
753+
754+
:param status: whether the dataset should be defined as a feature group
755+
:type status: bool
756+
"""
757+
self.settings["featureGroup"] = status
758+
740759
def save(self):
741760
self.dataset.client._perform_empty(
742761
"PUT", "/projects/%s/datasets/%s" % (self.dataset.project_key, self.dataset.dataset_name),

dataikuapi/dss/feature_store.py

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
from dataikuapi.dss.dataset import DSSDataset
2+
3+
4+
class DSSFeatureGroupListItem(object):
5+
def __init__(self, client, project_key, name):
6+
self.client = client
7+
self.project_key = project_key
8+
self.name = name
9+
10+
@property
11+
def id(self):
12+
return self.project_key + "." + self.name
13+
14+
def get_as_dataset(self):
15+
"""
16+
Gets the feature group as a dataset
17+
18+
:return: a handle on the dataset
19+
:rtype: :class:`dataikuapi.dss.dataset.DSSDataset`
20+
"""
21+
return DSSDataset(self.client, self.project_key, self.name)
22+
23+
24+
class DSSFeatureStore(object):
25+
def __init__(self, client):
26+
"""
27+
A handle on the Feature Store.
28+
Do not create this class directly, use :meth:`DSSClient.get_feature_store`
29+
"""
30+
self.client = client
31+
32+
def list_feature_groups(self):
33+
"""
34+
Get a list of feature groups on which the user has at least read permissions
35+
36+
:return: list of feature groups
37+
:rtype: list of :class:`dataikuapi.feature_store.DSSFeatureGroupListItem`
38+
"""
39+
items = self.client._perform_json("GET", "/feature-store/feature-groups")
40+
return [DSSFeatureGroupListItem(self.client, item["projectKey"], item["name"]) for item in items]

dataikuapi/dssclient.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from requests import exceptions
55
from requests.auth import HTTPBasicAuth
66

7+
from .dss.feature_store import DSSFeatureStore
78
from .dss.notebook import DSSNotebook
89
from .dss.future import DSSFuture
910
from .dss.projectfolder import DSSProjectFolder
@@ -1118,6 +1119,19 @@ def get_object_discussions(self, project_key, object_type, object_id):
11181119
"""
11191120
return DSSObjectDiscussions(self, project_key, object_type, object_id)
11201121

1122+
########################################################
1123+
# Feature Store
1124+
########################################################
1125+
def get_feature_store(self):
1126+
"""
1127+
Get a handle to interact with the Feature Store.
1128+
1129+
:return: a handle on the feature store
1130+
:rtype: :class:`dataikuapi.feature_store.DSSFeatureStore`
1131+
"""
1132+
return DSSFeatureStore(self)
1133+
1134+
11211135
class TemporaryImportHandle(object):
11221136
def __init__(self, client, import_id):
11231137
self.client = client

0 commit comments

Comments
 (0)