From e272b16568fc7574a3c364b707ee65a040b806ee Mon Sep 17 00:00:00 2001 From: Saar Cohen <66667568+theSaarco@users.noreply.github.com> Date: Thu, 29 Apr 2021 13:33:10 +0300 Subject: [PATCH] [Feature Store] Making features/entities optional in feature-set spec (#902) --- mlrun/api/db/sqldb/db.py | 10 +++++----- mlrun/api/schemas/feature_store.py | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/mlrun/api/db/sqldb/db.py b/mlrun/api/db/sqldb/db.py index 2a4347d3761..00329f5bb8b 100644 --- a/mlrun/api/db/sqldb/db.py +++ b/mlrun/api/db/sqldb/db.py @@ -1546,7 +1546,7 @@ def store_feature_set( session, FeatureSet, project, name, tag, uid ) - feature_set_dict = feature_set.dict() + feature_set_dict = feature_set.dict(exclude_none=True) if not existing_feature_set: # Check if this is a re-tag of existing object - search by uid only @@ -1600,7 +1600,7 @@ def _validate_and_enrich_record_for_creation( get_project_member().ensure_project(session, project) tag = new_object.metadata.tag or "latest" - object_dict = new_object.dict() + object_dict = new_object.dict(exclude_none=True) hash_key = fill_object_hash(object_dict, "uid", tag) if versioned: @@ -1654,7 +1654,7 @@ def patch_feature_set( f"Feature-set not found {feature_set_uri}" ) - feature_set_struct = feature_set_record.dict() + feature_set_struct = feature_set_record.dict(exclude_none=True) # using mergedeep for merging the patch content into the existing dictionary strategy = patch_mode.to_mergedeep_strategy() mergedeep.merge(feature_set_struct, feature_set_update, strategy=strategy) @@ -1832,7 +1832,7 @@ def store_feature_vector( session, FeatureVector, project, name, tag, uid ) - feature_vector_dict = feature_vector.dict() + feature_vector_dict = feature_vector.dict(exclude_none=True) if not existing_feature_vector: # Check if this is a re-tag of existing object - search by uid only @@ -1886,7 +1886,7 @@ def patch_feature_vector( f"Feature-vector not found {feature_vector_uri}" ) - feature_vector_struct = feature_vector_record.dict() + feature_vector_struct = feature_vector_record.dict(exclude_none=True) # using mergedeep for merging the patch content into the existing dictionary strategy = patch_mode.to_mergedeep_strategy() mergedeep.merge(feature_vector_struct, feature_vector_update, strategy=strategy) diff --git a/mlrun/api/schemas/feature_store.py b/mlrun/api/schemas/feature_store.py index f79e98a2b81..5174977b7a1 100644 --- a/mlrun/api/schemas/feature_store.py +++ b/mlrun/api/schemas/feature_store.py @@ -31,8 +31,8 @@ class Config: class FeatureSetSpec(ObjectSpec): - entities: List[Entity] - features: List[Feature] + entities: List[Entity] = [] + features: List[Feature] = [] class FeatureSet(BaseModel):