Page MenuHomePhabricator

Expose mathoid warnings via restbase
Closed, ResolvedPublic

Description

In https://gerrit.wikimedia.org/r/#/c/mediawiki/services/mathoid/+/447558/3/test/features/math/simple.js the warning feature was implemented. In https://gerrit.wikimedia.org/r/#/c/mediawiki/extensions/Math/+/442124/ the warnings are displayed as tracking categories. However, in the middle, I guess in restbase the information is lost. For testcase

curl -X POST "https://en.wikipedia.org/api/rest_v1/media/math/check/chem" -d "type=chem&q=\ce {pH=-\log _{10}[H+]}"
{"success":true,"checked":"{\\ce {pH=-\\log _{10}[H]}}","requiredPackages":["mhchem"],"identifiers":["p","H","H"],"endsWithDot":false}

I do not see a warning. I guess somewhere in this file
https://github.com/wikimedia/restbase/blame/master/v1/mathoid.yaml
or close to this file one need to specify that the warning field is preserved.

I do not exactly know how to do that. @mobrovac @Pchelolo @Clarakosi any idea?

Event Timeline

Restricted Application added subscribers: Liuxinyu970226, Aklapper. · View Herald TranscriptJun 4 2019, 9:30 PM
mobrovac edited subscribers, added: akosiaris; removed: Aklapper.

There's something weird in the Mathoid deployment here. When I issue the same request from inside production directly to Mathoid, the warnings are not returned either:

$ curl 'http://mathoid.discovery.wmnet:10042/texvcinfo' -XPOST -H'Content-Type: application/json' -d'{"q":"\\ce {pH=-\\log _{10}[H+]}", "type":"chem"}'
{"success":true,"checked":"{\\ce {pH=-\\log _{10}[H+]}}","requiredPackages":["mhchem"],"identifiers":["p","H","H"],"endsWithDot":false}

This is not the case locally, where I do get warnings for this query. It seems that the latest version of Mathoid is not deployed in production. I will take a moment and see with @akosiaris why that is the case.

There is a second issue here, which we will encounter once the above is resolved. Namely, RESTBase stores the results of the checks, which means that these warnings will appear only for new formulae. What we can do there is go over all of the stored formulae and re-issue the requests for them to get the latest content.

mobrovac claimed this task.Jun 5 2019, 9:26 AM

The first part of the issue has been fixed; Mathoid's code is up to date now. However, the results will only be publicly visible for new formulae. I'll run a dump of all of the formulae in storage next week.

Great thank you. I just confirmed that it works for new formulae.

curl -X POST "https://en.wikipedia.org/api/rest_v1/media/math/check/chem" -d "type=chem&q=\ce {pH=-\log _{10}[H+]+20190606}"
{"success":true,"checked":"{\\ce {pH=-\\log _{10}[H]20190606}}","requiredPackages":["mhchem"],"identifiers":["p","H","H"],"endsWithDot":false,"warnings":[{"type":"mhchem-deprecation","details":{"error":{"message":"Expected [a-zA-Z] but \" \" found.","expected":[{"type":"class","parts":[["a","z"],["A","Z"]],"inverted":false,"ignoreCase":false}],"found":" ","location":{"start":{"offset":13,"line":1,"column":14},"end":{"offset":14,"line":1,"column":15}},"name":"SyntaxError"},"success":false,"warnings":[],"status":"S","details":"SyntaxError: Expected [a-zA-Z] but \" \" found.","offset":13,"line":1,"column":14}}]}
mobrovac closed this task as Resolved.Jun 8 2019, 9:08 AM
mobrovac triaged this task as Medium priority.

All of the formulae have been rechecked, so warnings should now be emitted for all requests. Since we updated Mathoid to the latest code, I have also regenerated all of the renders to match the current expectations.

Fun fact: we have 10M unique formulae in storage! :)