Skip to content
Prev Previous commit
Next Next commit
Fix
Signed-off-by: Kevin Zhang <kzhang@tecton.ai>
  • Loading branch information
kevjumba committed Apr 13, 2022
commit 53f3439231070170a32eb11af0455bb0704c2e25
48 changes: 19 additions & 29 deletions sdk/python/feast/data_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,7 @@ class RequestSource(DataSource):
"""

name: str
schema: Union[Dict[str, ValueType], List[Field]]
schema: List[Field]

def __init__(
self,
Expand All @@ -477,7 +477,19 @@ def __init__(
"Please use List[Field] instead for the schema",
DeprecationWarning,
)
self.schema = schema
schemaList = []
for key, valueType in schema.items():
schemaList.append(
Field(name=key, dtype=VALUE_TYPES_TO_FEAST_TYPES[valueType])
)
self.schema = schemaList
elif isinstance(schema, List):
self.schema = schema
else:
raise Exception(
"Schema type must be either dictionary or list, not "
+ str(type(schema))
)

def validate(self, config: RepoConfig):
pass
Expand All @@ -499,35 +511,13 @@ def __eq__(self, other):
or self.tags != other.tags
):
return False
else:
if isinstance(self.schema, List) and isinstance(other.schema, List):
for field1, field2 in zip(self.schema, other.schema):
if field1 != field2:
return False
return True
elif isinstance(self.schema, Dict) and isinstance(other.schema, Dict):
for key, value in self.schema.items():
if key not in other.schema:
return False
elif value != other.schema[key]:
return False
return True
elif isinstance(self.schema, Dict) and isinstance(other.schema, List):
dict_schema = self.schema
list_schema = other.schema
elif isinstance(self.schema, List) and isinstance(other.schema, Dict):
dict_schema = other.schema
list_schema = self.schema

temp_schema = {}
for field in list_schema:
temp_schema[field.name] = field.dtype
for name, value in dict_schema.items():
if name not in temp_schema:
return False
elif VALUE_TYPES_TO_FEAST_TYPES[value.value] != temp_schema[name]:
if isinstance(self.schema, List) and isinstance(other.schema, List):
for field1, field2 in zip(self.schema, other.schema):
if field1 != field2:
return False
return True
else:
return False

@staticmethod
def from_proto(data_source: DataSourceProto):
Expand Down
1 change: 0 additions & 1 deletion sdk/python/feast/field.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
from feast.protos.feast.core.Feature_pb2 import FeatureSpecV2 as FieldProto
from feast.protos.feast.types.Value_pb2 import ValueType
from feast.types import FeastType, from_value_type
from feast.value_type import ValueType


class Field:
Expand Down
5 changes: 5 additions & 0 deletions sdk/python/feast/on_demand_feature_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,11 @@ def get_request_data_schema(self) -> Dict[str, ValueType]:
schema.update(new_schema)
elif isinstance(request_source.schema, Dict):
Comment thread
kevjumba marked this conversation as resolved.
Outdated
schema.update(request_source.schema)
else:
raise Exception(
"Request source schema is not correct type: "
+ str(type(request_source.schema))
)
return schema

def get_transformed_features_df(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
from feast.types import FeastType, PrimitiveFeastType
from tests.integration.feature_repos.universal.entities import location
from feast.field import Field
from feast.data_source import DataSource, RequestSource

def driver_feature_view(
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was this not being used anywhere?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think my rebase must have accidentally deleted it, i added it back.

data_source: DataSource,
Expand Down