Jump to content

Nova Resource:Wikilabels/Deployment

From Wikitech

Hey There!

PyPI

Wikilabels has two repositories, the first one is the wikilabels and the other one is the wikilabels config, When significant changes made to the wikilabels itself, you need to increment its version. Try to follow PEP440 and Semvar.

Change the files in __init__.py and setup.py then push it into PyPI:

python setup.py sdist bdist_wheel upload

If you got GPG/PGP you can try adding sign to the list above to also sign the wheel and the sdist

Update config repo

In order to update the config repo. You need to update wikilabels submodule in (submodules/wikilabels/ directory) and also update the version of wikilabels in requirements.txt if needed. If the update touches configuration settings, make sure the config repo is correct and compatible.

Staging

Before going to labels.wmflabs.org, you need to go to staging (which exists in labels-staging.wmflabs.org) Note that the database for staging is different but mirrored from the production database so you can test it freely.

Merge your changed into master branch and then do:

fab stage

It'll deploy it to the staging. If everything is alright, go and test it manually in labels-staging.wmflabs.org/gadget/ and if everything looks okay to you. Deploy it to prod

Production

First, get a backup of the database just to be sure. Then, rebase the "deploy" branch with origin/master and push it into the config repo:

git checkout deploy
git rebase origin/master
git push -f origin deploy

Once it's done deploy it with:

fab deploy

And it'll be in the production. Test everything fully if they are working as expected (specially both in labels.wmflabs.org/gadget/ and wiki)

And update the gadget in:

Database modification

Currently number of functionalities to alter the database is limited and you need to run PostgreSQL commands directly in other case (for example if you want to change name of a campaign).

Remember create a back up before any action you want to make:

pg_dump -h wikilabels-database --user u_wikilabels u_wikilabels -W | gzip -c > 2016-07-11.sql.gz

(Enter the password, find it in the labs instance)

Logging in into the database:

psql -h wikilabels-database --user u_wikilabels u_wikilabels -W

Making new campaigns

Get name of the campaign and put revision file somewhere in your home directory. Here's an example:

/srv/wikilabels/venv/bin/wikilabels  new_campaign azwiki "Edit quality (20k random sample, 2015)" damaging_and_goodfaith DiffToPrevious 1 50

The it'll give you id of the the campaign. Use it here (instead of "40"):

tail -n+2 ~/azwiki.revisions_for_review.5k_2016.tsv | sed -r 's/([0-9]+)\t([^\t]+)\t(.+)/{"rev_id": \1, "needs_review": "\2", "reason": "\3"}/' | /srv/wikilabels/venv/bin/wikilabels task_inserts 40