Page MenuHomePhabricator

Investigate how to improve MediaModeration output [16H]
Closed, ResolvedPublic

Description

Context

Upon running the mediamoderation maintenance script
mwscript extensions/MediaModeration/maintenance/ModerateExistingFiles.php [...]
to scan images on commons T258603: Scan all images on Wikimedia Commons
it is difficult to understand the status of the the script and related jobs that it intiates. @mepps and @eigyan reported that the script was not working, but that it did not provide useful progress or error output at the shell running the script. All the operator can tell from the cli is that the script is running in the foreground, but not if it is doing useful work or if it is stalled. Also, there are a number of 'post-script run' steps that the person executing the script must perform to try to ascertain the status of the process. It would be great to find ways to provide some of that manually-gathered information directly from the script output as well.

Questions to answer
  1. What are the the organizational units of processing within the code that should have status output?
    • examples:
      • batches for the job runner
      • buckets of images to check in the external apis
      • individual files that need checked
  2. For each item identified in question 1, what progress and/or status should be surfaced via the cli when running the script?
    • examples:
      • progress: number of batch jobs run/number of batch jobs requested; timestamp of last first file checked / timestamp of last file checked; number of files checked vs number requested, etc
      • task success/failure: job failed, file scan failed, etc
      • content moderation results: number of files that passed moderation, number of files that failed moderation due to matching known bad content
  3. For each item identified in question 1, what identifiers/fields/additional information can and should be included directly in the script output or used to look up information in other systems such as logstash or mwlog1002?
    • examples (to be clear, I don't know if these are available to the host running the script or not, so any items here should be checked to make sure they are actually available -- jason):
      • jobs: job id, job status, tracking id, exception
      • files: filenames, id, etc (I don't actually know what file info is available --jason)
      • api requests: request ids, response status, response message
  4. What would the steps be for proposed new Running the MediaModeration maintenance script instructions that would incorporate the new script output to guide the operator through running the script and understanding its status?
Answers

What are the the organizational units of processing within the code that should have status output?

  • Batches

For each item identified in question 1, what progress and/or status should be surfaced via the cli when running the script?

  • Indication for each batch that has started, for example, by outputting a "dot" (.) at the initiation of each batch, or perhaps an updated count of batches started depending on if any enhancements are implemented.
  • Optional enhancement: batch exception output

For each item identified in question 1, what identifiers/fields/additional information can and should be included directly in the script output or used to look up information in other systems such as logstash or mwlog1002?

  • None, we only need to indicate that a batch started.
  • Optional enhancement: timestamp for each batch start

What would the steps be for proposed new Running the MediaModeration maintenance script instructions that would incorporate the new script output to guide the operator through running the script and understanding its status?

  • No change.
Original Description

After starting the job, it's unclear what's happening.

Two things that would help:

  • Allow for console version for single file
  • Output job creation and give more feedback

Event Timeline

Petr said it does output the final timestamp at the very end, but I'm not seeing that in the code.

What I see is that all the processing happens in ModerateExistingFilesHelper whereas output is called in ModerateExistingFiles. If we wanted to do an output line per job, we would have to pull the iteration logic back into ModerateExistingFiles.
In terms of the final output of rows processed and timestamp, getSeveralOutput relies on $completed which is the negative of the outcome of processSeveral. However processSeveral returns the number of rows processed. That number is never used. It'd be possible to change the value of $completed but it was no longer mirror how it works in getSingleOutput, which is why I imagine it was written this way.

ARamirez_WMF renamed this task from Improve MediaModeration output to Investigate how to improve MediaModeration output [Spike].Feb 22 2022, 4:49 PM
ARamirez_WMF updated the task description. (Show Details)
ARamirez_WMF renamed this task from Investigate how to improve MediaModeration output [Spike] to Investigate how to improve MediaModeration output [16H].Feb 22 2022, 4:53 PM
ARamirez_WMF updated the task description. (Show Details)

@mepps is this Allow for console version for single file talking about a web console, a cli console, or something else?

ERayfield changed the task status from Open to In Progress.Mar 3 2022, 4:06 PM
ERayfield claimed this task.

@ERayfield suggests that we have a starting message then dots for each batch run then an ending message.

@jsn.sherman summarized:

What are the the organizational units of processing within the code that should have status output?

  • Batches

For each item identified in question 1, what progress and/or status should be surfaced via the cli when running the script?

  • That it has started.

For each item identified in question 1, what identifiers/fields/additional information can and should be included directly in the script output or used to look up information in other systems such as logstash or mwlog1002?

  • just that it started.

What would the steps be for proposed new Running the MediaModeration maintenance script instructions that would incorporate the new script output to guide the operator through running the script and understanding its status?

  • No change.

Change 769074 had a related patch set uploaded (by Mepps; author: Mepps):

[mediawiki/extensions/MediaModeration@master] Example of adding output to console script

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

@jsn.sherman Add null option to be able to run local tests.

  • code mvp is progress outputting one dot per batch start
  • potential enhancements:
    • exception output
    • timestamps for batch start
Madalina claimed this task.

Change 769074 abandoned by Kosta Harlan:

[mediawiki/extensions/MediaModeration@master] Example of adding output to console script

Reason:

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