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

Add __repr__ implementation for database models #2441

Merged
merged 1 commit into from
Feb 28, 2023
Merged
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
9 changes: 9 additions & 0 deletions src/argilla/server/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ class UserWorkspace(Base):
user: Mapped["User"] = relationship(viewonly=True)
workspace: Mapped["Workspace"] = relationship(viewonly=True)

def __repr__(self):
return f"UserWorkspace(id={str(self.id)!r}, workspace_id={str(self.workspace_id)!r}, user_id={str(self.user_id)!r}, inserted_at={str(self.inserted_at)!r}, updated_at={str(self.updated_at)!r})"


class Workspace(Base):
__tablename__ = "workspaces"
Expand All @@ -60,6 +63,9 @@ class Workspace(Base):
secondary="users_workspaces", back_populates="workspaces", order_by=UserWorkspace.inserted_at.asc()
)

def __repr__(self):
return f"Workspace(id={str(self.id)!r}, name={self.name!r}, inserted_at={str(self.inserted_at)!r}, updated_at={str(self.updated_at)!r})"


class User(Base):
__tablename__ = "users"
Expand All @@ -77,3 +83,6 @@ class User(Base):
workspaces: Mapped[List["Workspace"]] = relationship(
secondary="users_workspaces", back_populates="users", order_by=UserWorkspace.inserted_at.asc()
)

def __repr__(self):
return f"User(id={str(self.id)!r}, first_name={self.first_name!r}, last_name={self.last_name!r}, username={self.username!r}, inserted_at={str(self.inserted_at)!r}, updated_at={str(self.updated_at)!r})"