Page MenuHomePhabricator

Provide an API to filter functions by input/output types which can return functions usable by the prototype
Closed, ResolvedPublic

Description

Description

We want users to be able to search among functions that take the following input types:

  • strings
  • types with parsers
  • enums

And output the following:

  • strings
  • types with renderers
Details

How to filter by input types:

  • strings: wikilambda_zobject_join:
    • where wlzo_key=Z8K1 and wlzo_related_object=Z6
  • types with parser: wikilambda_zobject_join
    • where wlzo_key=Z8K2 and wlzo_related_object=X, and
    • wlzo_main_zid=X and wlzo_key=Z4K6 non empty
  • enums: Impossible to know from secondary tables. Some alternative options:
    • Option 1: Types that have instances. This means that we would also filter among functions that have input types as implementations, testers, types. There are few types with instances that will appear in function inputs that are not enums. Also, the output filter would restrict those. For example Z881, Z882 or Z883 take types as inputs, and types have instances. However, because their output is Z4, they would be filtered out.
    • Option 2: Add renderer functions to all enum types. Enums have their own behavior in the front-end (selector with instances); also the string renderer field in the front-end only is shown when the type has both renderer and parser. If we created a renderer function for all enum types which just prints their identity, functions that have enum inputs would be shown in the "types with renderer" queries.
    • Option 3: Add info about enums in the secondary tables. There is no good place to put this with current tables. Maybe adding additional rows for instances of enums into the wikilambda_zobject_join (see below)

How to filter by output type:

  • strings: wikilambda_zobject_join
    • where wlzo_key=Z8K2 and wlzo_related_object=Z6
  • types with renderer: wikilambda_zobject_join
    • where wlzo_key=Z8K1 and wlzo_related_object=X, and
    • wlzo_main_zid=X and wlzo_key=Z4K5 non empty

Performance

TODO

wikilambda_zobject_join to track enums

E.g. Z20000 and Z20001 are instances of Z10000, which is an enum type:

wlzo_main_zidwlzo_main_typewlzo_keywlzo_related_zobjectwlzo_related_type
Z20000Z10000"instanceofenum" or NULLZ10000Z4
Z20001Z10000"instanceofenum" or NULLZ10000Z4

Completion checklist

Related Objects

StatusSubtypeAssignedTask
OpenNone
ResolvedJdforrester-WMF
ResolvedJdforrester-WMF
ResolvedJdforrester-WMF
ResolvedJdforrester-WMF
ResolvedJdforrester-WMF
ResolvedJdforrester-WMF
ResolvedJdforrester-WMF
DeclinedNone
Resolved Sharvaniharan
ResolvedAAlhazwani-WMF
ResolvedAAlhazwani-WMF
Resolvedgengh
Resolvedgengh
Resolved Marostegui

Event Timeline

Change #1105019 had a related patch set uploaded (by Genoveva Galarza; author: Genoveva Galarza):

[mediawiki/extensions/WikiLambda@master] [WIP] Add renderers/parsers and instances of enums to wikilambda_zobject_join table

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

Change #1105019 merged by jenkins-bot:

[mediawiki/extensions/WikiLambda@master] Add renderers/parsers and instances of enums to wikilambda_zobject_join table

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

Change #1105890 had a related patch set uploaded (by Genoveva Galarza; author: Genoveva Galarza):

[mediawiki/extensions/WikiLambda@master] [WIP] Build API that can filter for functions that have stringifiable inputs/outputs

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

Change #1105890 merged by jenkins-bot:

[mediawiki/extensions/WikiLambda@master] Build API that can filter for functions that have renderable inputs/outputs

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

A few comments about the translatable messages that are added to api/en.json here:

  • They mention "parser function" and "renderer function". Perhaps this should say "reading function" and "display function"? These are the terms used in other messages, for example wikilambda-parser-unexpected-result-error and wikilambda-renderer-unexpected-result-error. If I understand correctly, they refer to the same things, and if they do, the terminology should be consistent. In addition, "parser function" has a different, and pretty well-known meaning in the MediaWiki world.
  • On Telegram, @GrounderUK suggested that perhaps the word "renderable" could be split for inputs and for outputs: "readable" and "displayable". I'm not sure that it's feasible because there is one API for both, but it did make some sense to me, so I thought that I should mention it.
  • In API messages, examples are written in <kbd> tags and, specific code, such as parameters and values, are written in <var> tags. So instead of 'Engl', there should probably be <kbd>Engl</kbd>, and input_type and output_type should be in <var>. And perhaps some instances of the word "renderable", if it refers to an API parameter name, should be in <var>, too.

I have a problem with Z11.

I don’t think we want to specify a display function for this but can’t we generally treat this as a string? (Or it’s a string if its Z11K1 has a code that is in some list, but we won’t know this when filtering “usable” functions.)

Or should we specify a display function for Z11 that appends a language code that can be erased when it matches some other language code in context?

But if, in effect, we consider Z11 to be a string, then we might also consider Z12 to be a Z11, if it is implicitly wrapped in “select by language” logic.

I have a problem with Z11.

I don’t think we want to specify a display function for this but can’t we generally treat this as a string? (Or it’s a string if its Z11K1 has a code that is in some list, but we won’t know this when filtering “usable” functions.)

Or should we specify a display function for Z11 that appends a language code that can be erased when it matches some other language code in context?

But if, in effect, we consider Z11 to be a string, then we might also consider Z12 to be a Z11, if it is implicitly wrapped in “select by language” logic.

I would prefer a display function that displays a raw string if in that language, otherwise displays an (XX) or something.

I've created a function that implements this, Z21583

Change #1110396 had a related patch set uploaded (by Genoveva Galarza; author: Genoveva Galarza):

[mediawiki/extensions/WikiLambda@master] Add performance improvements for complex filter function queries

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

Change #1116761 had a related patch set uploaded (by Genoveva Galarza; author: Genoveva Galarza):

[mediawiki/extensions/WikiLambda@master] Improve messages for wikilambdasearch_functions API documentation

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

Change #1116761 merged by jenkins-bot:

[mediawiki/extensions/WikiLambda@master] Improve messages for wikilambdasearch_functions API documentation

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