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

#44 Sampling tasks from user data #115

Merged
merged 4 commits into from
Dec 28, 2022
Merged

#44 Sampling tasks from user data #115

merged 4 commits into from
Dec 28, 2022

Conversation

mjagkow
Copy link
Collaborator

@mjagkow mjagkow commented Dec 28, 2022

Tasks are now sampled randomly from user-uploaded data.

  • Queries to fetch random post threads and conversations
  • Moved "frontend task message" id to WorkPackage
  • Added references for thread_id, parent_post_id to WorkPackage
  • Added "ack" and "done" flags to WorkPackage
  • PostReaction FK changed to WorkPackage
  • Added depth and children_count to Post

resolves #44

@@ -31,3 +31,5 @@ class Post(SQLModel, table=True):
)
payload_type: str = Field(nullable=False, max_length=200)
payload: PayloadContainer = Field(sa_column=sa.Column(payload_column_type(PayloadContainer), nullable=True))
depth: int = Field(sa_column=sa.Column(sa.Integer, default=0, server_default=sa.text("0"), nullable=False))
Copy link
Collaborator

Choose a reason for hiding this comment

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

do we really need all these attributes?
it seems like sqlmodel might do the right thing with depth: int = 0 without any field definition at all, no?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

There was an issue adding default boolean value (ack, done), the value did not propagate properly to existing rows. Solution was to specify server_default, so I did it the same way to other columns.

@yk
Copy link
Collaborator

yk commented Dec 28, 2022

LGTM, but I'll leave the review to @andreaskoepf bc more familiar with this code

Copy link
Collaborator

@andreaskoepf andreaskoepf left a comment

Choose a reason for hiding this comment

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

My thoughts:

  1. depth and children_count are incrementally calculated, e.g. we must from now on not directly delete elements from post without going through python code that updates the parent element.
  2. regarding sampling & order by random() I have read different reports about its performance online (some say it "performs a full table scan and also ordering. Therefore this method is not preferred for tables with large number of rows because of performance reasons." ..) Postgres also supports TABLESAMPLE, which is probably faster.

In general we will need very soon a more sophisticated sampling function that takes a weights into account.

@andreaskoepf
Copy link
Collaborator

linking #44

@andreaskoepf andreaskoepf merged commit c4d5b58 into LAION-AI:main Dec 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Make user-submitted data available for new tasks
4 participants