Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add more __repr__ methods #4676

Merged
merged 1 commit into from
Oct 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
10 changes: 10 additions & 0 deletions sdk/python/feast/feature_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,16 @@ def version(self) -> str:
"""Returns the version of the current Feast SDK/CLI."""
return get_version()

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
Loading