Page MenuHomePhabricator

ORES hook integration with EventBus
Open, NormalPublic

Description

The first client of the ORES hooks inside mediawiki would be the EventBus, but I could imagine them to be useful for a lot of extensions. Let's discuss the possibilities and the exact API here.

The first hook might be something like RevisionRecordScoreSaved, however, given that @Halfak said about user scoring and potentially more entities scoring the name. of the hook is up for discussion.

This is a placeholder task for us to discuss, we will expand the description as we go.

Event Timeline

Pchelolo created this task.Aug 13 2018, 7:20 PM
Pchelolo renamed this task from O to ORES hooks.Aug 13 2018, 7:29 PM
Pchelolo updated the task description. (Show Details)
Pchelolo updated the task description. (Show Details)
Ladsgroup added a comment.EditedAug 15 2018, 9:09 PM

Name of mediawiki hooks should have been prefixed by the name of the extension that introduces it so the dependencies would be clearer but beside that, it seems like a great idea.

fdans moved this task from Incoming to Radar on the Analytics board.Aug 16 2018, 3:41 PM

Ok, how about:

/**
  * Called after a RevisionRecord ORES score was saved to the database.
  *
  * @param RevisionRecord $revision the RevisionRecord that has been scored. 
  * @param array $scores scores in the form returned by ORES service. 
  * For the response schema see https://ores.wikimedia.org/v3/scores/enwiki/?model_info=score_schema
  */
ORESRevisionRecordScoreSaved( RevisionRecord $revision, array $scores )

(The actual URI to put there is for enwiki, so we might think what exactly to put in there, or add 'replace with your wiki of interest' comment, or create a 'global' complete schema for everything you could possibly expect)

There is one thing: ORES extension hooks into RC changes and not revision creations so it can't have such hook but it can be something like this:

/**
  * Called after a RecentChange entry ORES score was saved to the database.
  *
  * @param RecentChange $rc the RecentChange that has been scored. 
  * @param array $scores scores in the form returned by ORES service. 
  * For the response schema see https://ores.wikimedia.org/v3/scores/enwiki/?model_info=score_schema
  */
ORESRecentChangeScoreSaved( RecentChange $rc, array $scores )

Returning the score scheme will be a little bit hard because the code base parse it behind an interface so it's decoupled from the hook handler but I might find a way around it or just return some score schema and you hook onto that?

ORESRecentChangeScoreSaved( RecentChange $rc, array $scores )

This hook will be executed from the FetchScoreJob since that's where we have the scores to pass into it, and the RC id is not passed to the job, only the revision id... BTW, just wondering, what will this do for log RC? What will be scored for log RC?

Returning the score scheme will be a little bit hard because the code base parse it behind an interface so it's decoupled from the hook handler but I might find a way around it or just return some score schema and you hook onto that?

I believe we can just return whatever ORES is returning, that's why I've mentioned that schema.

This hook will be executed from the FetchScoreJob since that's where we have the scores to pass into it, and the RC id is not passed to the job, only the revision id... BTW, just wondering, what will this do for log RC? What will be scored for log RC?

Yeah, you're right. Let's do it that way, I don't mind about logs, we just ignore them in the extension.

I believe we can just return whatever ORES is returning, that's why I've mentioned that schema.

Sure thing.

awight renamed this task from ORES hooks to ORES hook integration with EventBus.Aug 22 2018, 4:24 PM
awight moved this task from Untriaged to New development on the Scoring-platform-team board.
Harej triaged this task as Normal priority.Mar 26 2019, 9:23 PM
Harej moved this task from New development to Ready to go on the Scoring-platform-team board.
Restricted Application added a project: User-Ladsgroup. · View Herald TranscriptApr 11 2019, 3:08 PM

Change 503017 had a related patch set uploaded (by Ladsgroup; owner: Ladsgroup):
[mediawiki/extensions/ORES@master] Add ORESRecentChangeScoreSavedHook

https://gerrit.wikimedia.org/r/503017

Change 503017 merged by jenkins-bot:
[mediawiki/extensions/ORES@master] Add ORESRecentChangeScoreSavedHook

https://gerrit.wikimedia.org/r/503017

@Pchelolo This is done in our side. Feel free to take it over and add hooks for your usecases :)