-
Notifications
You must be signed in to change notification settings - Fork 0
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
Simplify data collection #10
Draft
ysthakur
wants to merge
14
commits into
main
Choose a base branch
from
data-coll-db
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ysthakur
changed the title
Save comments and misses in SQLite DB
Simplify data collection
Dec 28, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR aims to simplify our data collection process by storing everything in an SQL database and using a less complicated process for randomly generating comment IDs to request.
Regarding choice of database, I used an SQLite database for now for simplicity, but that's temporary. We can switch to a Postgres database later (I just didn't want to put in the work before we figure out how to get 4CAT to read from our own DB). It will require updating some code, though (like using
%s
rather than?
for formatting SQL queries). It's not actually necessary to store stuff in an SQL database, and I could modify this PR to go back to using a CSV, but using SQLite does simplify things.The
out/
directory is no longer used because we don't have to worry about separating data from different runs. All data is now stored in adata.db
file right in thedata-collection
directory. The logs for each run go into thelogs
folder, in a file named in the format%Y-%m-%d-%H-%M-%S.log
.For requesting comments now, I gave up on making it deterministic and switched to the following easy method:
I initially checked if any of the generate IDs were duplicates by looking in the database, but this was slow. Instead, I made the
id
column the primary key for both thecomments
andmisses
tables. Now, each time we want to insert a comment/missed ID, we can useINSERT OR IGNORE
and it won't add the comment/miss if it's a duplicate. The problem withINSERT OR IGNORE
is that it ignores all conflicts, not just primary key duplicates, but I think that's fine. This approach ended up being faster.I threw in a script (
csv_to_db.py
) that can take comments.csv and missed-ids.txt files from the old data collector and put that data into a data.db file. We can just import all the data we've collected so far and continue collecting based off of that.I also made it so the data collector no longer needs to talk to the web dashboard. The web dashboard goes through the database on its own, so it's totally separate. That said, as we collect more comments, updating the web dashboard frequently might not be feasible, so we might have to go back to having it get updates from the data collector. This changes sacrifices performance for simplicity.