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
LB-225: Add support for importing data dumps. #274
Conversation
Added tests too. |
580b57a
to
7ecd7ae
Compare
Rebase, please |
ab1e9f3
to
ce03530
Compare
I would love opinions on the problem I mentioned in the OP. The stats dump currently cannot be imported alone, it needs a corresponding private dump.
|
Oh sorry, didn't see that question:
That is exactly how MB does it -- lets do that too. |
ce03530
to
6a63060
Compare
Rebased over #293 and added logic to only import user table from stats dump when needed. |
ee2c37d
to
a555f57
Compare
Also, Add more error catching and logging
a555f57
to
56a8231
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just one thing, the rest looks sane.
listenbrainz/db/dump.py
Outdated
pxz = subprocess.Popen(pxz_command, stdout=subprocess.PIPE) | ||
|
||
# create a transaction and start importing | ||
with db.engine.begin() as connection: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm glad you decided to do this in a transaction, which at first glance is the opposite of importing. :) However, there are subtle differences -- namely when importing you can't have a live site running. That isn't a valid or desired use case. Therefore there is no need to run inside a transaction -- in fact doing a full data import in a transaction could cause some interesting problems. So, please remove this transaction.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good now. It looks too good, actually. This means that alastairp will find something the second I merge this. :) 🚜 !!
Based off #272, so will need to be rebased after that.
There are a bunch of things more to do here, for example the stats table has a foreign key to the user table so the stats tables can't be imported alone, it needs a corresponding entry in the user table. Not sure how to solve this, other than sanitizing users and putting it in the stats dump too.