MediaWiki-Docker/Extension/WikiLambda

This page instructs you to install Extension:WikiLambda inside MediaWiki-Docker.

Follow the Quickstart instructions at MediaWiki-Docker page. Once MediaWiki is running and available at http://localhost:8080, then continue with instructions on this page.

All commands should be run in the directory where you installed MediaWiki. All mentioned files are also located there.

Clone the repository and its sub-moduleEdit

git clone "https://gerrit.wikimedia.org/r/mediawiki/skins/Vector" skins/Vector
git clone --recurse-submodules --remote-submodules https://gerrit.wikimedia.org/r/mediawiki/extensions/WikiLambda extensions/WikiLambda

If you plan on using gerrit or authenticating with ssh rather than https, it is recommended you get the code with an SSH key instead. Follow these instructions to do so.

If your Git version is older than 2.23, --remote-submodules will not be available. Use git submodule update --remote instead.

Add our composer dependenciesEdit

Extend MediaWiki's composer dependencies to use ours by adding a composer.local.json file in your mediawiki/ directory with the following:

{
    "extra": {
        "merge-plugin": {
            "include": [
                "extensions/WikiLambda/composer.json"
            ]
        }
    }
}

… and then run:

docker-compose exec mediawiki composer update

Modify LocalSettings.phpEdit

If not already there, add this to the end of LocalSettings.php.

wfLoadSkin( 'Vector' );
wfLoadExtension( 'WikiLambda' );

Run maintenance scriptsEdit

docker-compose exec mediawiki php maintenance/update.php

OptionalEdit

CheckEdit

You can check whether this worked by navigating to http://localhost:8080/wiki/Special:CreateZObject, or to http://localhost:8080/wiki/Special:ApiSandbox and looking for wikilambda_fetch in the action dropdown. If they are there, all is well.

Adding the servicesEdit

To add the orchestrator and executor back-end services, first copy the contents of the services block in WikiLambda's docker-compose.sample.yml file to the analogous `services` block in your mediawiki/docker-compose.override.yml file. Replace the <TAG> entries in the stanza you just copied with the latest builds from the Docker registry for the orchestrator and the evaluator.

You can automatically test your installation by editing your local copy of ApiFunctionCallTest.php to remove @group: Broken, and running the PHPUnit test suite as described in the MediaWiki install instructions, or by using the following command:

      docker-compose exec mediawiki php tests/phpunit/phpunit.php extensions/WikiLambda/tests/phpunit/integration/API/ApiFunctionCallTest.php

You can manually evaluate a function call by navigating to http://localhost:8080/wiki/Special:EvaluateFunctionCall, selecting a function from the wiki, and choosing your inputs. If successful, the function response will be presented, having traversed the orchestrator and the evaluator to be run in one of the code executors.

You can also visit http://localhost:8080/wiki/Special:ApiSandbox and try out one or more tests as follows:

  • In the action drop-down menu, select wikilambda_function_call
  • Click on {} Examples, and select any of the listed examples
  • Click the blue Make request button
  • In the Results box, look for the word "success".

🎉 Congratulations! 🎉

Special configurationsEdit

Having the services with different configurationEdit

If you wish to use the orchestrator or evaluator under a different name or port, or your checkout of MediaWiki is not in a directory called 'mediawiki', you must over-ride the $wgWikiLambdaOrchestratorLocation or $wgWikiLambdaEvaluatorLocation configuration values from their defaults in your LocalSettings file.

For example, if you MediaWiki checkout is called 'core', you should add:

$wgWikiLambdaOrchestratorLocation = 'core_function-orchestrator_1:6254';

Building local versions of the servicesEdit

If you would instead like to use a local version of the function orchestrator or evaluator, e.g. because you wish to make local development changes and test them, there are three steps:

  1. Ensure that you are using version 2.x or above (i.e., not 1.x) of docker-compose. (If you have 1.x, you will need to upgrade, or, if using Docker Dashboard, you may be able to select a preference for "Use Composer v2".)
  2. Install Blubber: https://wikitech.wikimedia.org/wiki/Blubber/Download#Blubber_as_a_(micro)Service
  3. Clone the service you wish to alter:
    1. (For the orchestrator): git clone --recurse-submodules --remote-submodules ssh://gerrit.wikimedia.org:29418/mediawiki/services/function-orchestrator function-orchestrator
    2. (For the evaluator): git clone --recurse-submodules --remote-submodules ssh://gerrit.wikimedia.org:29418/mediawiki/services/function-evaluator function-evaluator
  4. From the root of the service you wish to alter, run either:
    • (For the orchestrator): blubber .pipeline/blubber.yaml development | docker build -t local-orchestrator -f - .
    • (For the evaluator): blubber .pipeline/blubber.yaml development | docker build -t local-evaluator -f - .
  5. Then update your mediawiki/docker-compose.override.yml file to change the service stanza to point to your new local image, with image: local-orchestrator:latest or image: local-evaluator:latest.