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: adding __repr__ method to CompactionMetrics #2236

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 8 additions & 0 deletions python/python/lance/lance/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,14 @@ class CompactionMetrics:
fragments_added: int
files_removed: int
files_added: int

def __repr__(self):
return f"""
Fragments Removed: {self.fragments_removed}
Fragments Added: {self.fragments_added}
Files Removed: {self.files_removed}
Files Added: {self.files_added}
"""
Comment on lines +36 to +42
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think function implementations are meant to be put into .pyi files, which are type stubs.

CompactionMetrics is implemented in Rust here:

pub struct PyCompactionMetrics {

Could you implement the method there in Rust? Here is an example Rust implementation of a __repr__ method:

pub fn __repr__(&self) -> PyResult<String> {
Ok(format!(
"CompactionPlan(read_version={}, tasks=<{} compaction tasks>)",
self.0.read_version(),
self.num_tasks()
))
}

Copy link
Author

Choose a reason for hiding this comment

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

Thanks for getting back, I really appreciate the support. This is my first time contributing to open-source project. It'll try to implement this and get back.


class LanceFileWriter:
def __init__(self, path: str, schema: pa.Schema): ...
Expand Down