Page MenuHomePhabricator

Lingua Libre development environment
Closed, ResolvedPublic24 Estimated Story Points

Description

Set up a development environment for Lingua Libre. This should include:

  • Running the services locally.
  • Being able to test during development.
    • Mocking requests to external services (Commons etc.) AND/OR
    • Using beta wikis

Instructions can be found in the repo.

Related Objects

Event Timeline

We managed to get it running locally. So far we were able to login in using Oauth against the beta cluster.

Apart from some general issues with installing the libraries and dependencies we didn't encounter that many issues. All the URLs seem to be hard coded to go to Commons, so to get things working with beta Commons we had to hack in a few places (see below). There may be more places that need changing for other functionality.

One thing we encountered was that there was no logging for the backend when there was a server error. For development it would help a lot if you could see those even if they are turned into error responses.

We've probably come far enough to start looking at T423394: Create "Profile" view, though we'll probably encounter more things relevant to this task.

Patch for beta Commons
diff --git a/customauth/views.py b/customauth/views.py
index 78612f3..1e2fe0a 100644
--- a/customauth/views.py
+++ b/customauth/views.py
@@ -43,7 +43,7 @@ class WikimediaOAuthCallbackView(APIView):
             refresh_token = data["refresh_token"]
             token_type = data["token_type"]
 
-            url = "https://commons.wikimedia.org/w/api.php"
+            url = "https://commons.wikimedia.beta.wmcloud.org/w/api.php"
             params = {
                 "action": "query",
                 "format": "json",
diff --git a/lingualibre/authentication.py b/lingualibre/authentication.py
index f5741a0..c5adc1b 100644
--- a/lingualibre/authentication.py
+++ b/lingualibre/authentication.py
@@ -15,7 +15,7 @@ class CustomAuthentication(BaseAuthentication):
         access_token = authorization_header.split()[-1]
 
         try:
-            url = "https://commons.wikimedia.org/w/api.php"
+            url = "https://commons.wikimedia.beta.wmcloud.org/w/api.php"
             params = {
                 "action": "query",
                 "format": "json",
diff --git a/lingualibre/settings.py b/lingualibre/settings.py
index d248f7e..9c2f677 100644
--- a/lingualibre/settings.py
+++ b/lingualibre/settings.py
@@ -151,7 +151,7 @@ AUTHENTICATION_BACKENDS = "lingualibre/authentication.CustomAuthentication"
 
 AUTH_USER_MODEL = "user_profile.User"
 
-WIKIMEDIA_OAUTH_TOKEN_URL = "https://commons.wikimedia.org/w/rest.php/oauth2/access_token"
+WIKIMEDIA_OAUTH_TOKEN_URL = "https://commons.wikimedia.beta.wmcloud.org/w/rest.php/oauth2/access_token"
 WIKIMEDIA_OAUTH_CLIENT_ID = config.get("WIKIMEDIA_OAUTH", "CLIENT_ID")
 WIKIMEDIA_OAUTH_CLIENT_SECRET = config.get("WIKIMEDIA_OAUTH", "CLIENT_SECRET")

We ran into some issues with beta Commons timing out for the authentication requests. If this happens repeatedly we may have to figure out something else, like having a mock Oauth server.