Skip to content
This repository was archived by the owner on Apr 15, 2022. It is now read-only.

Commit 63ea350

Browse files
author
Ben Epstein
authored
Merge pull request #117 from splicemachine/DBAAS-5102
DBAAS-5102: create a route for GET /training-set-feature
2 parents ec2838e + ea7074f commit 63ea350

File tree

2 files changed

+27
-14
lines changed

2 files changed

+27
-14
lines changed

splicemachine/features/feature_store.py

Lines changed: 26 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -439,8 +439,8 @@ def describe_feature_sets(self) -> None:
439439

440440
print('Available feature sets')
441441
for desc in r:
442-
fset = FeatureSet(**desc["feature_set"])
443-
features = [Feature(**feature) for feature in desc["features"]]
442+
features = [Feature(**feature) for feature in desc.pop('features')]
443+
fset = FeatureSet(**desc)
444444
print('-' * 23)
445445
self._feature_set_describe(fset, features)
446446

@@ -462,8 +462,8 @@ def describe_feature_set(self, schema_name: str, table_name: str) -> None:
462462
if not descs: raise SpliceMachineException(
463463
f"Feature Set {schema_name}.{table_name} not found. Check name and try again.")
464464
desc = descs[0]
465-
fset = FeatureSet(**desc["feature_set"])
466-
features = [Feature(**feature) for feature in desc["features"]]
465+
features = [Feature(**feature) for feature in desc.pop("features")]
466+
fset = FeatureSet(**desc)
467467
self._feature_set_describe(fset, features)
468468

469469
def _feature_set_describe(self, fset: FeatureSet, features: List[Feature]):
@@ -483,8 +483,8 @@ def describe_training_views(self) -> None:
483483

484484
print('Available training views')
485485
for desc in r:
486-
tcx = TrainingView(**desc["training_view"])
487-
features = [Feature(**f) for f in desc["features"]]
486+
features = [Feature(**f) for f in desc.pop('features')]
487+
tcx = TrainingView(**desc)
488488
print('-' * 23)
489489
self._training_view_describe(tcx, features)
490490

@@ -500,8 +500,8 @@ def describe_training_view(self, training_view: str) -> None:
500500
descs = r
501501
if not descs: raise SpliceMachineException(f"Training view {training_view} not found. Check name and try again.")
502502
desc = descs[0]
503-
tcx = TrainingView(**desc['training_view'])
504-
feats = [Feature(**f) for f in desc['features']]
503+
feats = [Feature(**f) for f in desc.pop('features')]
504+
tcx = TrainingView(**desc)
505505
self._training_view_describe(tcx, feats)
506506

507507
def _training_view_describe(self, tcx: TrainingView, feats: List[Feature]):
@@ -529,15 +529,16 @@ def get_training_set_from_deployment(self, schema_name: str, table_name: str):
529529

530530
r = make_request(self._FS_URL, Endpoints.TRAINING_SET_FROM_DEPLOYMENT, RequestType.GET, self._basic_auth,
531531
{ "schema": schema_name, "table": table_name })
532-
metadata = r["metadata"]
533532

533+
metadata = r['metadata']
534534
sql = r['sql']
535-
features = metadata['FEATURES'].split(',')
536-
tv_name = metadata['NAME']
537-
start_time = metadata['TRAINING_SET_START_TS']
538-
end_time = metadata['TRAINING_SET_END_TS']
535+
536+
tv_name = metadata['name']
537+
start_time = metadata['training_set_start_ts']
538+
end_time = metadata['training_set_end_ts']
539+
539540
tv = TrainingView(**r['training_view']) if 'training_view' in r else None
540-
features = [Feature(**f) for f in r["features"]]
541+
features = [Feature(**f) for f in r['features']]
541542

542543
if self.mlflow_ctx:
543544
self.link_training_set_to_mlflow(features, start_time, end_time, tv)
@@ -564,6 +565,17 @@ def get_deployments(self, schema_name: str = None, table_name: str = None, train
564565
"""
565566
return make_request(self._FS_URL, Endpoints.DEPLOYMENTS, RequestType.GET, self._basic_auth,
566567
{ 'schema': schema_name, 'table': table_name, 'name': training_set })
568+
569+
def get_training_set_features(self, training_set: str = None):
570+
"""
571+
Returns a list of all features from an available Training Set, as well as details about that Training Set
572+
:param training_set: training set name
573+
:return: TrainingSet as dict
574+
"""
575+
r = make_request(self._FS_URL, Endpoints.TRAINING_SET_FEATURES, RequestType.GET, self._basic_auth,
576+
{ 'name': training_set })
577+
r['features'] = [Feature(**f) for f in r['features']]
578+
return r
567579

568580
def _retrieve_model_data_sets(self, schema_name: str, table_name: str):
569581
"""

splicemachine/features/utils/http_utils.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ class Endpoints:
3636
FEATURE_VECTOR: str = "feature-vector"
3737
FEATURE_VECTOR_SQL: str = "feature-vector-sql"
3838
TRAINING_SETS: str = "training-sets"
39+
TRAINING_SET_FEATURES: str = "training-set-features"
3940
TRAINING_SET_FROM_DEPLOYMENT: str = "training-set-from-deployment"
4041
TRAINING_SET_FROM_VIEW: str = "training-set-from-view"
4142
TRAINING_VIEWS: str = "training-views"

0 commit comments

Comments
 (0)