The past few days, I've worked on T336630 and T336624, both of which describe failures I was seeing which other people weren't. In both cases, it turned out to be caused by something in my user-config.py. Many of these tests also rely on external resources (i.e. live testing against testwiki or metawiki). I come from a shop where our test environment was hermetic. That eliminated this kind of flakiness due to environmental differences. It's a great way to work, but I recognize that's not what we've got here, and not easy to get to that point.
Given all that, any suggestions on how I should set up a dev environment on my local machine to minimize this kind of problem in the future?
Also, once I figured out what was going on, I closed T336630 as "declined". Was that the right state for "I'm not going to do any more work on this because it turned out to be a problem with the test environment". Should I have used "invalid"? Something else?
Dear Hiring Manager,
I am writing to express my keen interest in the position you have
advertised for gaining real-time experience in Python.
I have experience working with Python on personal projects, which has
allowed me to gain a solid foundation in the language. I am confident in my
ability to quickly learn and adapt to new technologies and work
environments. I am a fast learner and I believe my knowledge of Python will
enable me to quickly integrate into your team and contribute to the ongoing
pywikibot project.
I would greatly appreciate the opportunity to gain real-time experience in
Python and work alongside experienced professionals in the field. Thank you
for your consideration, and I look forward to hearing from you soon.
Sincerely,
AlienTasks
Hi,
I don't think this is a bug, but despite the documentation, I can't find a solution to my problems…
=========
Problem 1
I'm trying to instantiate a `Page` based on its id, but I can't seem to find something that does… The closest to it seems to be "page_from_repository('Q'+pageId)", but I get
"pywikibot.exceptions.UnknownExtensionError: Wikibase is not implemented for [mywikifamily:fr]."
From there on, I don't know what to do.
=========
=========
Problem 2
I'm using a personal wiki, self hosted, where read is for registered users only :
> #Gestion des langues
> $wgPageLanguageUseDB = true ;
> $wgGroupPermissions['sysop']['pagelang'] = true;
>
> # The following permissions were set based on your choice in the installer
> $wgGroupPermissions['*']['edit'] = false; //pour formations = true
> $wgGroupPermissions['*']['read'] = false; //pour formations = true
> # Prevent new user registrations except by sysops
> $wgGroupPermissions['*']['createaccount'] = false;
When I try to connect (I have created a bot for myself, configured my wiki family, my user-config and my user-password). The system refuses :
"pywikibot.exceptions.NoUsernameError: Username '[blabla@blablaBot]' does not have read permissions on [mywikifamily:fr]."
Then, if I comment my access rights, everything works fine. Later on, if I uncomment my access rights, it still works fine. How could I configure my rights without resorting to that strange/dangerous workaround? I have spent hours on that and have not found a solution
=========
Sorry about those personal problems, which are not bugs, and which could be documented. But despite hours of searching, I haven't found out where they would be documented… Thanks to whoever takes the time to read this (let alone, reply…)
I've checked out /pywikibot/core.git. When I run the tests, I get a number of failures:
FAILED tests/http_tests.py::TestHttpStatus::test_follow_redirects - AssertionError: '//en.wikipedia.org/wiki/Main_Page' not found in 'https://en.wikipedia.org/wiki/Main%20Page'
FAILED tests/make_dist_tests.py::TestMakeDist::test_handle_args - AssertionError: '/Users/roy/dev/pywikibot/pywikibot-git/tests/make_dist_tests.py' != '/Users/roy/dev/pywikibot/venv/bin/pytest'
FAILED tests/make_dist_tests.py::TestMakeDist::test_handle_args_empty - AssertionError: '/Users/roy/dev/pywikibot/pywikibot-git/tests/make_dist_tests.py' != '/Users/roy/dev/pywikibot/venv/bin/pytest'
FAILED tests/page_tests.py::TestShortLink::test_create_short_link - pywikibot.exceptions.NoUsernameError: ERROR: username for meta:meta is undefined.
FAILED tests/script_tests.py::TestScriptSimulate::test_category - AssertionError: 'Traceback (most recent call last)' unexpectedly found in 'ERROR: An error occurred for uri https://en.wikipedia.org/w/api.php\nERROR: Traceback (most recent call last...
FAILED tests/script_tests.py::TestScriptSimulate::test_category_redirect - AssertionError: 'Traceback (most recent call last)' unexpectedly found in 'Checking hard-redirect category pages.\nERROR: An error occurred for uri https://en.wikipedia.org/w/api.php\...
FAILED tests/site_detect_tests.py::MediaWikiSiteTestCase::test_proofreadwiki - pywikibot.exceptions.ClientError: (403) Request forbidden -- authorization will not help
I'm trying to get up to speed on the pywikibot project culture. How many of these are known issues? Are they being worked on? Should I work on them?
I took a look in more detail at the first one (TestHttpStatus::test_follow_redirects). I'm not sure what this test is trying to do. It depends on how the requests library processes redirects and/or how en.wikipedia.org <http://en.wikipedia.org/> responds to escaped spaces in URLs, neither of which seem like anything that has to do with the pywikibot codebase, so I don't understand what value this test is adding.
Hi everyone,
My bot has started throwing the following error, and I'm wondering if
anyone has a clue about what might have changed. It's using the shared
stable version on ToolForge, which I believe was updated to 8.0.3. today.
TIA for any help.
File "/data/project/william-avery-bot/wikipythonics/cleanseRefs.py", line
118, in treat_page
self.current_page.editEntity(summary=summary)
File
"/data/project/shared/pywikibot/stable/pywikibot/page/_decorators.py", line
55, in wrapper
handle(func, self, *args, **kwargs)
File
"/data/project/shared/pywikibot/stable/pywikibot/page/_decorators.py", line
34, in handle
func(self, *args, **kwargs)
File "/data/project/shared/pywikibot/stable/pywikibot/page/_wikibase.py",
line 680, in editEntity
super().editEntity(data, **kwargs)
File "/data/project/shared/pywikibot/stable/pywikibot/page/_wikibase.py",
line 313, in editEntity
updates = self.repo.editEntity(
File
"/data/project/shared/pywikibot/stable/pywikibot/site/_decorators.py", line
92, in callee
return fn(self, *args, **kwargs)
File "/data/project/shared/pywikibot/stable/pywikibot/site/_datasite.py",
line 311, in editEntity
params['token'] = self.tokens['csrf']
File
"/data/project/shared/pywikibot/stable/pywikibot/site/_tokenwallet.py",
line 57, in __getitem__
raise KeyError(
KeyError: "Invalid token 'csrf' for user 'William Avery Bot' on
wikidata:wikidata wiki."
Hello everyone,
*Summary*
The Developer Advocacy team is excited to share with you a new set of
educational materials you can use to learn and teach others about Pywikibot
[1]. These new materials are based on content originally presented as part
of the Small wiki toolkits initiative [2]. Please read and share these
materials, give feedback in Phabricator [3] or on Talk pages, or edit the
pages directly if you find errors. This will help improve the materials for
these workshops as well as workshops planned for the future.
*Long version*
Last year, the Small wiki toolkits initiative held monthly technical
workshops about using, building, and hosting bots [4].
In response to feedback received from participants [5], this year the
Developer Advocacy team launched an initiative (Phabricator task: [6]) to
develop on-wiki learning and training materials based on the previous
workshops. The goal of these materials is to make it easier for you to
learn about Pywikibot and teach others in your community about it. Drafts
for two workshops [7] are now ready for your review:
- How to run basic scripts using Pywikibot
- How to host a bot on Toolforge
Materials for each workshop come in two formats:
1. Self-study guide
- explains how to learn a given subject on your own
- links to different resources on wikis and other sites without duplicating
them.
2. Workshop organizer's handbook
- teaches you how to teach the subject to others
- explains how to prepare a workshop that you can run during a hackathon or
a conference. If you've ever wanted to give a talk about Pywikibot but
didn't have the time to design it, the handbook should help.
*How to get involved*
Please read the linked materials and provide feedback in Phabricator or on
talk pages. Is this the right format for learners and trainers? Did we miss
anything? Are there sections that are difficult to follow or make no sense?
Please let us know. Your input will help inform the next steps for the
development of the remaining materials.
If you want to contribute any changes or corrections, you can do so either
directly on the pages, or by leaving comments on talk pages or in
Phabricator. Thank you for your help!
On behalf of the Developer Advocacy team,
Kamil Bach
[1] https://www.mediawiki.org/wiki/Manual:Pywikibot/Workshop_Materials
[2] https://meta.wikimedia.org/wiki/Small_wiki_toolkits/Workshops
[3] https://phabricator.wikimedia.org/T327282
[4] https://meta.wikimedia.org/wiki/Small_wiki_toolkits/Workshops
[5] https://meta.wikimedia.org/wiki/Small_wiki_toolkits/Workshops/Report
[6] https://phabricator.wikimedia.org/T327282
[7] https://www.mediawiki.org/wiki/Manual:Pywikibot/Workshop_Materials
--
Kamil Bach (they/them)
Technical Writer
Wikimedia Foundation
Hi,
I wrote a module which handles Flagged Revisions in huwiki.
https://hu.wikipedia.org/wiki/Szerkeszt%C5%91:BinBot/huwiki/flaggedrevs.py
It has a function called cosmeticable(page) to tell if a page is eligible
for cosmetic changes according to huwiki rules.
It also has a CosmeticableFilterPageGenerator which yields only
cosmeticable pages. But it may not have a command-line argument as it
is not in the framework.
Now, what is the way to tell Pywikibot that cosmetic changes should be done
only on pages where the function returns True or which are from this
pagegenerator?
I don't want to modify the core system on my device, because it will be
disrupted when refreshing and is not distributable to other users.
In eneral, is there a way to use own _global_ command-line arguments?
--
Bináris
Tl;dr: is there a place for Wikipedia-related code? What do we do for code
reusability?
I proposed a Page method in https://phabricator.wikimedia.org/T328769.
This would have shown if an article is a biography (it is about a person).
My idea was opposed because the codebase of BasePage and APIPage is not
Wikipedia-related, and some developers don't want to see any
Wikipedia-specific code in it.
OK, let's say, this is a valid argument. Let's call it *code purity*.
On the other hand, Pywikibot is mostly developed by Wikipedians, mostly
used in Wikipedia, and biographies form a primary scope of Wikipedia. I
definitely think that biographies SHOULD be subclassed to have a lot of
methods that are useful for a lot of Wikipedias and bot owners. If they
write this code for themselves again and again, that's a waste.
Now I definitely will use this feature. What can I do?
First idea is to subclass Page in my code. That is the natural solution. Of
course, when I publish my scripts, others won't be able to use them, and I
won't be able to use others' scripts as they are, because I need this
subclass. Let's call this point od view *code reusability* which is
generally kept an important thing in the world of programming.
Now, what we do (see the above task) is that we throw away code reusability
for the sake of code purity. Is that OK?
I am honestly curious, where the place of Wikipedia is in this framework.
What I WILL do in the present situation: write a module called huwiki and
don't bother other Wikipedias and place my code into this module. It will
contain functions that take the page as parameter (not nice, not natural, I
don't like it, but this is the only way if I cannot subclass) and nice
pagegenerators, all for Hungarian Wikipedia alone, because I need them.
Is that really what we want?
Please help to find the place of Wikipedia-related code.
--
Bináris
Without the screenshot this time....
> On Mar 28, 2023, at 2:01 PM, Roy Smith <roy(a)panix.com> wrote:
>
> Hmmm. What I'm doing requires Page.expand_text(), which looks like it does a Page.get() followed by a Site.expand_text(), and it's the later which actually takes most of the time. That becomes an action=expandtemplates API call <https://www.mediawiki.org/w/api.php?action=help&modules=expandtemplates>, which I don't see any way to batch.
>
>
>
>
> <Screen Shot 2023-03-28 at 1.55.55 PM.png>
>
>> On Mar 28, 2023, at 1:04 PM, Kunal Mehta <legoktm(a)debian.org <mailto:legoktm@debian.org>> wrote:
>>
>> Hi,
>>
>> On 3/27/23 15:57, Roy Smith wrote:
>>> I need to issue a bunch of Page.get() requests in parallel.
>>
>> Please don't. From <https://www.mediawiki.org/wiki/API:Etiquette#Request_limit <https://www.mediawiki.org/wiki/API:Etiquette#Request_limit>>:
>>
>> "Making your requests in series rather than in parallel, by waiting for one request to finish before sending a new request, should result in a safe request rate."
>>
>> Instead of making parallel requests, you should make batched requests, which is how the preloading stuff Xqt mentioned works.
>>
>> -- Kunal / Legoktm
>> _______________________________________________
>> pywikibot mailing list -- pywikibot(a)lists.wikimedia.org <mailto:pywikibot@lists.wikimedia.org>
>> Public archives at https://lists.wikimedia.org/hyperkitty/list/pywikibot@lists.wikimedia.org/m… <https://lists.wikimedia.org/hyperkitty/list/pywikibot@lists.wikimedia.org/m…>
>> To unsubscribe send an email to pywikibot-leave(a)lists.wikimedia.org <mailto:pywikibot-leave@lists.wikimedia.org>
>>
>