Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Suggested Edits endpoints #1153

Closed
wants to merge 23 commits into from

Conversation

mdholloway
Copy link
Contributor

@mdholloway mdholloway commented Jun 21, 2019

Adds four new recommendation endpoints:

  • /data/recommendation/caption/addition/{target}
  • /data/recommendation/caption/translation/from/{source}/to/{target}
  • /data/recommendation/description/addition/{target}
  • /data/recommendation/description/translation/from/{source}/to/{target}

The caption suggestion endpoints are supported only for Commons domains,
and the description suggestion endpoints are supported only for Wikidata
domains. (This is enforced in the service configuration, and is not reflected here.)

Support for commons.wikimedia.org as a default project is added to
config.example.wikimedia.yaml for development and testing.

Support for recommendations endpoints is added to the wikidata.org
project in the example config.

Phab: https://phabricator.wikimedia.org/T224754

@mdholloway
Copy link
Contributor Author

@mateusbs17 This is an example of adding a basic endpoint or set of endpoints to RESTBase with no provision for Cassandra storage.

Copy link
Contributor

@d00rman d00rman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will need some more work. Namely, end points that have the source and target language cannot go under specific projects, e.g. what is the meaning of source and target if the end point is accessed via en.wp.org? In the same vein, blindly adding all of the recommendation end points to commons doesn't work either. What is the source language for end points that only expect the target to be provided by the client?

TL;DR: these end points need to be separated: one set should go under the global domain (those with both source and target) and another set should go under each project (those for which the target and/or source is known). Better yet, for end points that have both source and target, we should probably rework them so that the source is taken from the domain and then let the client specify the target (that's how it is currently done).

@d00rman d00rman added the API label Jun 24, 2019
@thesocialdev
Copy link
Contributor

thesocialdev commented Jun 25, 2019

@d00rman I'm gonna try to answer these questions.

[...] e.g. what is the meaning of source and target if the end point is accessed via en.wp.org?

It will return 400 - Unsupported domain

The allowed domains are:

description_allowed_domains:
        - www.wikidata.org
        - test.wikidata.org
        - wikidata.beta.wmflabs.org
caption_allowed_domains:
        - commons.wikimedia.org
        - test-commons.wikimedia.org
        - commons.wikimedia.beta.wmflabs.org

What is the source language for end points that only expect the target to be provided by the client?

I might be wrong, but the addition endpoints only need to know the target language which will get the new description/caption, the source doesn't matter since there is no manipulation of previously existing description/caption.

Better yet, for end points that have both source and target, we should probably rework them so that the source is taken from the domain and then let the client specify the target (that's how it is currently done).

That's something I'm don't know how to answer, probably @joewalsh have a better idea about the service architecture.

I might be missing something, but these endpoints are supposed to work exclusively with commons and there is no need to do language differentiation per client since the users need to have set multiple languages in the app

@Pchelolo
Copy link
Contributor

So, I guess we'd need a special project for commons now :(

@mdholloway
Copy link
Contributor Author

mdholloway commented Jun 25, 2019

There's nothing requiring us to use the wikidata and commons domains per se. We could just treat the domain as the target language, since there's a target language in every case. The source could be a path parameter. (Addition endpoints have no source language.)

IOW, they could look like:

  • /{target}.wikipedia.org/api/rest_v1/data/recommendation/description/addition
  • /{target}.wikipedia.org/api/rest_v1/data/recommendation/description/translation/from/{source}

The big drawback to using the wiki language subdomain as the target language is that it means we can't specify a language variant as the target. That would be unfortunate.

The same applies for the caption addition and translation endpoints, though Wikipedia domains would be a more awkward fit in that case, since the results are Commons file pages for files that aren't necessarily used on Wikipedias.

@mdholloway
Copy link
Contributor Author

The reason for preferring wikidata and commons for description and caption suggestions, respectively, is that those are the domains that the results most relate to.

@mdholloway mdholloway changed the title Add Suggested Edits endpoints to Recommendations Add Suggested Edits endpoints Jun 25, 2019
@d00rman
Copy link
Contributor

d00rman commented Jun 25, 2019

@mdholloway @mateusbs17 FYI, we have merged #1148, so now you can rebase and start working on this.

Adds four new recommendation endpoints:

- /data/recommendation/caption/addition/{target}
- /data/recommendation/caption/translation/from/{source}/to/{target}
- /data/recommendation/description/addition/{target}
- /data/recommendation/description/translation/from/{source}/to/{target}

The caption suggestion endpoints are supported only for Commons domains,
and the description suggestion endpoints are supported only for Wikidata
domains.

Support for commons.wikimedia.org as a default project is added to
config.example.wikimedia.yaml for development and testing.

Support for recommendations endpoints is added to the wikidata.org
project in the example config.

Phab: https://phabricator.wikimedia.org/T224754
1- Rebase.
2- Split recommend configurations and add into projects wikidata.wmf and
commons.wmf.
3- Create commons.wmf per copy of default.wmf and add recommend-caption
entries.
@thesocialdev
Copy link
Contributor

@Pchelolo and @d00rman I created v1/recommend-caption.yaml and v1/recommend-description.yaml instead of changing v1/recommend.yaml to add the endpoints to the projects where they are allowed, let me know if you have any concerns.

paths:
/{api:v1}:
x-modules:
- path: projects/v1/commons.wmf.yaml
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The point I've had on the meeting about being able not to create a commons project. We can just use the default project and add the recommned-captions right here in the config

@Pchelolo
Copy link
Contributor

The tests/features/specification/monitoring test suite has a list of domains we try out for local x-amples testing. Now that we have endpoints specific to commons and to wikidata, we need to add those domains to the list.

1- Remove commons from projects and add recommend-caption direct in the
config file
2- Add wikidata and commons to the monitoring test script as allowed
domains
@thesocialdev
Copy link
Contributor

I fixed the recommend.yaml but tests still fails. When accessing http://localhost:7231/wikidata.org/v1/?spec, it returns:

{
type: "https://mediawiki.org/wiki/HyperSwitch/errors/server_error",
title: "Site info fetch failed.",
method: "get",
detail: "SiteInfo is unavailable for wikidata.org",
uri: "/wikidata.org/v1/"
}

The last commit removes wikidata.org from the monitoring test just to make CI happy, any thoughts about that?

This depends on the work being done in PR wikimedia#1148.

Bug: T223953
@d00rman
Copy link
Contributor

d00rman commented Jun 26, 2019

@mateusbs17 the domain name is www.wikidata.org, not wikidata.org, that's why the site info fetch fails.

@thesocialdev
Copy link
Contributor

@mateusbs17 the domain name is www.wikidata.org, not wikidata.org, that's why the site info fetch fails.

Thanks, that was the problem indeed. Seems fixed, let me know if there is anything else.

Expose new talk endpoint in the wikipedia projects only, no cassandra
storage is needed, only regular Varnish layer. The endpoints are:

  /{domain}/v1/page/talk/{title}
  /{domain}/v1/page/talk/{title}/{revision}

Both return JSON with structured talk page.

Bug: T225733
1- Remove cache-control header
2- Add accept-language header
3- Remove unnedeed config
@mdholloway
Copy link
Contributor Author

OK, thanks for the update, @Pchelolo. @mateusbs17 please keep Joe up to date on what's happening with this.

options: '{{options.recommendation}}'
- path: projects/proxy.yaml
options: *proxy_options
/{api:sys}: *default_sys
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This portion actually needs to be transferred to the production config. Want me to do it or want me to show you how it's done @mateusbs17 ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, we need to update config.fronted.wikimedia.yaml similarly.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Went ahead and made a prod config change for you https://gerrit.wikimedia.org/r/c/mediawiki/services/restbase/deploy/+/519500

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same question.

- get_from_backend:
request:
uri: '{{options.host}}/{{domain}}/v1/caption/addition/{target}'
x-amples:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs x-monitor: true as well

- get_from_backend:
request:
uri: '{{options.host}}/{{domain}}/v1/caption/translation/from/{source}/to/{target}'
x-amples:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs x-monitor: true as well

- get_from_backend:
request:
uri: '{{options.host}}/{{domain}}/v1/description/addition/{target}'
x-amples:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs x-monitor: true as well

- get_from_backend:
request:
uri: '{{options.host}}/{{domain}}/v1/description/translation/from/{source}/to/{target}'
x-amples:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs x-monitor: true as well.

Actually. while you're at it, could you amend our tests to fail if there IS x-amples and no x-monitoring. Right about here: https://github.com/wikimedia/restbase/blob/master/test/features/specification/monitoring.js#L43

Copy link
Contributor

@d00rman d00rman Jun 27, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

x-monitor is actually not needed if it's value is supposed to be true. The default is x-monitor: true in service-checker

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

olala... that's the shitty part of having the checker reimplemented in node for testing. out tests need x-monitor

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Which config file should we now be using for ordinary testing? These now pass with x-monitor: true when using config.fullstack.test.yaml but only for beta cluster domains. But won't this put beta cluster domains on the Swagger doc page, even in production?

Also, I noticed that most endpoints have x-monitor: false in RESTBase. That's why I did likewise in the new PR before seeing this comment.

@thesocialdev
Copy link
Contributor

thesocialdev commented Jun 28, 2019

After adding x-monitor true it was possible to see that the x-amples tests don't work properly, the reason I found is related with the wmflabs host passed as options.

Even though I added the options to both wikidata and commons, some tests still get 404.

Adding the recommend-caption endpoints in the config file seems is
breaking on tests, it seems that the host for appeditortask is ignored,
this commit adds it to the default project.
@@ -96,3 +96,5 @@ paths:
- path: v1/javascript.yaml
options:
host: '{{options.mobileapps.host}}'
- path: v1/recommend-caption.yaml
options: '{{options.appeditortasks}}'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mmmm... Haven't we decided that this will only be exposed on commons?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mmmm... Haven't we decided that this will only be exposed on commons?

Er, that's news to me. Was that discussed in the sync meeting last week? The description suggestion endpoints don't make sense on Commons.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Never mind, misunderstood the comment ;)

@Pchelolo
Copy link
Contributor

Pchelolo commented Jul 1, 2019

As for x-amples... hm... Would the labs instance support beta commons and beta wikidata? You can expose those under beta domains and not specify domain in the test explicitly - that should work

thesocialdev and others added 2 commits July 1, 2019 18:14
@@ -29,6 +29,8 @@ default_project: &default_project
host: https://citoid-beta.wmflabs.org
recommendation:
host: https://recommendation-api-beta.wmflabs.org
appeditortasks:
host: https://app-editor-tasks.wmflabs.org
Copy link
Contributor

@Pchelolo Pchelolo Jul 1, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is this domain pointing too? it's a different instance of recommendation api service or what is this?

And if so, why are we pointing this to a different domain here?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's the labs instance @mdholloway was working on. I think this instance has a special setup for the endpoints to work with Extension:WikimediaEditorTasks, commons and wikidata.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm. but where would we point production too? To recommendation-api LVS? I think we need a bit more info from @mdholloway here.

Copy link
Contributor

@thesocialdev thesocialdev Jul 1, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm. but where would we point production too? To recommendation-api LVS? I think we need a bit more info from @mdholloway here.

Yes, the deployment followed the regular recommendation-api target machines. The limitations of the beta-cluster that made us create a new instance to perform the actions the Apps team needed for testing.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not entirely sure why the normal recommendation-api service can not handle these recommendations.. Since the normal recommendation-api.beta.wmflabs.org is as well completely under our control, why can't we make that one work and not create additional installations of the same thing?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhas cause the recommendation service installed in beta doesn't seem to work. Then we need to fix it and not create a separate installation.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should indeed point to the Beta Cluster. app-editor-tasks was just for prototyping and testing, particularly before the code was merged onto recommendation-api master.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Pointing to app-editor-tasks in this PR rather than BC like the others was probably just an error on my part.)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, OK, I see what's going on here. Yeah, we definitely don't want to introduce an appeditortasks service to RB. I'll update the PR.

@thesocialdev
Copy link
Contributor

thesocialdev commented Jul 1, 2019

As for x-amples... hm... Would the labs instance support beta commons and beta wikidata? You can expose those under beta domains and not specify domain in the test explicitly - that should work

That's something @mdholloway would know more about. I can't find the documented thing (e-mail/wiki page) that explains this labs setup.

EDIT: Extension:WikimediaEditorTasks/Testing_environment_setup

@mdholloway
Copy link
Contributor Author

I'm not able to force-push my updates, so I opened a new PR at #1159.

This is just an early-stage dev/testing instance. All testing here
should be performed against Recommendation API in the Beta Cluster.
@Pchelolo
Copy link
Contributor

Pchelolo commented Jul 3, 2019

ok, now we have 2 of these and also something clearly went wrong with git history here... we definitely can't merge this with broken history.

@mdholloway mdholloway closed this Jul 3, 2019
@mdholloway
Copy link
Contributor Author

Sorry for the mess. Cleaned up and rebased in #1160.

@thesocialdev You're not configured as a reviewer in this repo, so I can't add you, but your reviews are also welcome.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
5 participants