Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to speed up Pywikibot?

I've built some report tools using Pywikibot. As things are growing it now takes up to 2 hours to finish the reports so I'm looking to speed things up. Main ideas:

  • Disable throttling, the script is read-only, so page.get(throttle=False) handles this
  • Cache
  • Direct database access

Unfortunately I can't find much documentation about caching and db access. Only way seems to dive into the code, and well, there's limited information about database access in user-config.py. If there is any, where can I find good documentation about pywikibot caching and direct db access?

And, are there other ways to speed things up?

like image 661
kqw Avatar asked Sep 10 '15 12:09

kqw


4 Answers

Use PreloadingGenerator so that pages are loaded in batches. Or MySQLPageGenerator if you use direct DB access.

See examples here.

like image 127
Tgr Avatar answered Nov 13 '22 00:11

Tgr


I'm using "-pt:1" option in the command to make one edit per second.

I'm currently running the command

python pwb.py category add -pt:1 -file:WX350.txt -to:"Taken with Sony DSC-WX350"

https://www.mediawiki.org/wiki/Manual:Pywikibot/Global_Options

like image 37
Fructibus Avatar answered Nov 13 '22 02:11

Fructibus


Looks like pagegenerators is indeed a good way to speed up things. The best documentation for that is directly in the source.

Even in there it's not directly clear where to put the MySQL connection details. (Will update this hopefully.)

like image 1
kqw Avatar answered Nov 13 '22 00:11

kqw


  • Disable throttling, the script is read-only, so page.get(throttle=False) handles this

"throttle" parameter of Page.get() is not supported since Pywikibot 2.0 (formerly known as rewrite) and was removed in 5.0.0. Pywikibot 2.0+ has not activated a get throttle by default. Decreasing putthrottle is only for putting a page to the wiki and may be restricted by local policies. Never touch maxlag parameter which is server related.

If you are using multiple sites the first run needs a lot of time until all site objects are cached. PreloadingGenerator can be be used for bulk load of page contents but decreases speed if meta data are required only. In summary speeding up your script depends on you implementation and your need.

like image 1
xqt Avatar answered Nov 13 '22 02:11

xqt