MatmaRex / patchdemo

This repository has been moved to GitLab: https://gitlab.wikimedia.org/repos/ci-tools/patchdemo
https://gitlab.wikimedia.org/repos/ci-tools/patchdemo
MIT License
25 stars 21 forks source link

feat: add ORES extension to list of available extensions #560

Closed isaranto closed 1 year ago

isaranto commented 1 year ago

Bug: T319170

MatmaRex commented 1 year ago

Looks like this doesn't quite work and it might be tricky to get it working, since ORES depends on some external services.

I tried this patch out (deployed to https://patchdemo.wmflabs.org temporarily), and the maintenance script fails as follows:

Processing 2 revisions
RuntimeException from line 142 of /srv/patchdemo-wikis/efb7ef308c/w/extensions/ORES/includes/ORESService.php: Failed to make ORES request to [https://ores.wikimedia.org/v3/scores/patchdemo_efb7ef308c/?models=damaging%7Cgoodfaith&revids=1%7C151&format=json], There was a problem during the HTTP request: 404 Not Found
#0 /srv/patchdemo-wikis/efb7ef308c/w/extensions/ORES/includes/Services/ScoreFetcher.php(57): ORES\ORESService->request()
#1 /srv/patchdemo-wikis/efb7ef308c/w/extensions/ORES/maintenance/PopulateDatabase.php(116): ORES\Services\ScoreFetcher->getScores()
#2 /srv/patchdemo-wikis/efb7ef308c/w/extensions/ORES/maintenance/PopulateDatabase.php(87): ORES\Maintenance\PopulateDatabase->processScores()
#3 /srv/patchdemo-wikis/efb7ef308c/w/maintenance/includes/MaintenanceRunner.php(681): ORES\Maintenance\PopulateDatabase->execute()
#4 /srv/patchdemo-wikis/efb7ef308c/w/maintenance/doMaintenance.php(100): MediaWiki\Maintenance\MaintenanceRunner->run()
#5 /srv/patchdemo-wikis/efb7ef308c/w/extensions/ORES/maintenance/PopulateDatabase.php(128): require_once('/srv/patchdemo-...')
#6 {main}

So it's trying to call out to some Wikimedia production service, which obviously doesn't know anything about a random Patchdemo wiki.

The extension itself can be installed (https://patchdemo.wmflabs.org/wikis/6073ff3893/wiki/Special:Version#mw-version-ext-other-ORES), but without the service set up, it doesn't seem to do anything.

isaranto commented 1 year ago

I think it would be ok as I can point it towards a dummy service (specify a different url for ores) that has a patchdemo wiki, that is only if I can know the patchdemo_efb7ef308c string beforehand (or ssh into the machine afterwards and change it)

MatmaRex commented 1 year ago

It's the database name for the newly created wiki, and different for each one… Maybe that won't be a problem though. I'm not sure how complex the dummy service needs to be to work, but maybe we could just serve a file like https://patchdemo.wmflabs.org/dummy-ores.php, you'd implement whatever code is needed in there, and we'd set $wgOresBaseUrl = "https://patchdemo.wmflabs.org/dummy-ores.php/", so that all ORES service queries would be served by that file? (if needed, you can get the full path in PHP code using $_SERVER['REQUEST_URI'], and extract the parameters from that)

isaranto commented 1 year ago

For my purpose I can just change this in the code and instead of making a request to https://ores.wikimedia.org/v3/scores/patchdemo_efb7ef308c/?models=damaging%7Cgoodfaith&revids=1%7C151&format=json in will make a request to https://ores.wikimedia.org/v3/scores/MY_HARDCODED_WIKI_ID/?models=damaging%7Cgoodfaith&revids=1%7C151&format=json Since I'm not interested in the actual results just try to get some it is more than fine. If the rest is ok, we could merge this and I'll figure things out in my patch.

MatmaRex commented 1 year ago

I guess that's okay. This means that if you try to create a demo wiki with the ORES extension selected, but without a custom patch, it will fail. It's unselected by default though, so I don't mind that.

MatmaRex commented 1 year ago

Closed by f5173609db13b189f415b8393e885d1d52eb6ad3 (I had some issues with squashing the pull request in the GitHub interface)