Skip to content

Commit

Permalink
Add more __repr__ methods
Browse files Browse the repository at this point in the history
  • Loading branch information
emgeee committed Oct 21, 2024
1 parent 58e03d1 commit 4f42e18
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 5 deletions.
14 changes: 14 additions & 0 deletions sdk/python/feast/entity.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,20 @@ def __init__(
self.created_timestamp = None
self.last_updated_timestamp = None

def __repr__(self):
return (
f"Entity(\n"
f" name={self.name!r},\n"
f" value_type={self.value_type!r},\n"
f" join_key={self.join_key!r},\n"
f" description={self.description!r},\n"
f" tags={self.tags!r},\n"
f" owner={self.owner!r},\n"
f" created_timestamp={self.created_timestamp!r},\n"
f" last_updated_timestamp={self.last_updated_timestamp!r}\n"
f")"
)

def __hash__(self) -> int:
return hash((self.name, self.join_key))

Expand Down
12 changes: 9 additions & 3 deletions sdk/python/feast/feature.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,18 @@ def __lt__(self, other):
return self.name < other.name

def __repr__(self):
# return string representation of the reference
return f"{self.name}-{self.dtype}"
return (
f"Feature(\n"
f" name={self._name!r},\n"
f" dtype={self._dtype!r},\n"
f" description={self._description!r},\n"
f" labels={self._labels!r}\n"
f")"
)

def __str__(self):
# readable string of the reference
return f"Feature<{self.__repr__()}>"
return f"Feature<{self.name}: {self.dtype}>"

@property
def name(self):
Expand Down
15 changes: 14 additions & 1 deletion sdk/python/feast/feature_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
Tuple,
Union,
cast,
override,
)

import pandas as pd
Expand Down Expand Up @@ -81,7 +82,8 @@
GetOnlineFeaturesResponse,
)
from feast.protos.feast.types.EntityKey_pb2 import EntityKey
from feast.protos.feast.types.Value_pb2 import RepeatedValue, Value
from feast.protos.feast.types.Value_pb2 import RepeatedValue
from feast.protos.feast.types.Value_pb2 import Value
from feast.protos.feast.types.Value_pb2 import Value as ValueProto
from feast.repo_config import RepoConfig, load_repo_config
from feast.repo_contents import RepoContents
Expand Down Expand Up @@ -175,6 +177,17 @@ def version(self) -> str:
"""Returns the version of the current Feast SDK/CLI."""
return get_version()

@override
def __repr__(self) -> str:
return (
f"FeatureStore(\n"
f" repo_path={self.repo_path!r},\n"
f" config={self.config!r},\n"
f" registry={self._registry!r},\n"
f" provider={self._provider!r}\n"
f")"
)

@property
def registry(self) -> BaseRegistry:
"""Gets the registry of this feature store."""
Expand Down
9 changes: 8 additions & 1 deletion sdk/python/feast/field.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,14 @@ def __lt__(self, other):
return self.name < other.name

def __repr__(self):
return f"Field(name='{self.name}', dtype={self.dtype}, description='{self.description}' tags={self.tags})"
return (
f"Field(\n"
f" name={self.name!r},\n"
f" dtype={self.dtype!r},\n"
f" description={self.description!r},\n"
f" tags={self.tags!r}\n"
f")"
)

def __str__(self):
return f"Field(name={self.name}, dtype={self.dtype}, tags={self.tags})"
Expand Down

0 comments on commit 4f42e18

Please sign in to comment.