Making sure a web service adapter is installed

×

Status message

New Feature: Guest Login function added to facilitate site exploration without registering. Try it out!

A previous blog post explained in detail how to install a web service adapter on Araport (see Installing a web service adapter on Araport). Here we will go through the process of installing a web service adapter and then making sure that it has been properly installed. The example adapter will have some errors so it doesn't install properly at first. We will use 'curl' commands within a Unix terminal to accomplish this task.

Let's start by firing up a bash shell in the terminal. We will then setup some environment variables to simplify the 'curl' commands which allow us to interact with Adama (note that this is no longer a valid token).

$ export API=https://api.araport.org/community/v0.3
$ export NAMESPACE=eriksf-dev
$ export TOKEN=b779cc78ea5675a789184bb68d4155d2
$ export BEARER="Authorization: Bearer $TOKEN"
$
$ curl -Lk -X POST -H "$BEARER" -F "git_repository=https://github.com/Arabidopsis-Information-Portal/meyerslab.git" -F "metadata=services/strand" $API/$NAMESPACE/services
{
    "message": "registration started",
    "result": {
        "list_url": "https://api.araport.org/community/v0.3/eriksf-dev/strand_v0.1/list",
        "notification": "",
        "search_url": "https://api.araport.org/community/v0.3/eriksf-dev/strand_v0.1/search",
        "state_url": "https://api.araport.org/community/v0.3/eriksf-dev/strand_v0.1"
    },
    "status": "success"
}

OK. We have received a status of 'success'. Does this mean that the adapter is properly installed? Not yet. Let's check the status by using the state_url that was returned above.

$ curl -Lk -X GET -H "$BEARER" https://api.araport.org/community/v0.3/eriksf-dev/strand_v0.1
{
    "result": {
        "msg": "Error: register failed (see \"logs\" attribute)\n\nLogs:\nWorker of type query v0.1.5 starting\nListening in queue eriksf-dev.strand_v0.1\n*** WORKER STARTED\nNone\n*** WORKER ERROR\n*** WORKER ERROR\nTraceback (most recent call last):\n  File \"/root/worker.py\", line 270, in \n    main()\n  File \"/root/worker.py\", line 265, in main\n    run_worker(args.adapter_type, args)\n  File \"/root/worker.py\", line 244, in run_worker\n    worker.run()\n  File \"/root/worker.py\", line 82, in run\n    self.module = find_main_module()\n  File \"/root/worker.py\", line 221, in find_main_module\n    return importlib.import_module(module_name)\n  File \"/usr/lib/python2.7/importlib/__init__.py\", line 37, in import_module\n    __import__(name)\nImportError: No module named strand.main\n",
        "service": null,
        "slot": "error",
        "stage": 5,
        "total_stages": 6
    },
    "status": "success"
}

Oops! This means that there was an error registering the adapter and it has NOT been installed. We've corrected the error (unimportant what it was) so now let's try and install the adapter again.

$ curl -Lk -X POST -H "$BEARER" -F "git_repository=https://github.com/Arabidopsis-Information-Portal/meyerslab.git" -F "metadata=services/strand" $API/$NAMESPACE/services
{
    "message": "registration started",
    "result": {
        "list_url": "https://api.araport.org/community/v0.3/eriksf-dev/strand_v0.1/list",
        "notification": "",
        "search_url": "https://api.araport.org/community/v0.3/eriksf-dev/strand_v0.1/search",
        "state_url": "https://api.araport.org/community/v0.3/eriksf-dev/strand_v0.1"
    },
    "status": "success"
}

And again we'll check the status of the adapter using the state_url.

$ curl -Lk -X GET -H "$BEARER" https://api.araport.org/community/v0.3/eriksf-dev/strand_v0.1
{
    "result": {
        "service": {
            "authors": [],
            "code_dir": "/tmp/tmpdr0vMA/user_code",
            "description": "Strand values used in all meyerslab websites/dbs",
            "endpoints": {
                "/search": {
                    "description": "Strand values used in all meyerslab websites/dbs",
                    "summary": "Small RNA basic metadata"
                }
            },
            "git_branch": "",
            "git_repository": "https://github.com/Arabidopsis-Information-Portal/meyerslab.git",
            "icon": "../logo.png",
            "json_path": "",
            "language": "python",
            "main_module": "services.strand.main.py",
            "metadata": "services/strand",
            "name": "strand",
            "namespace": "eriksf-dev",
            "notify": "",
            "registration_timestamp": "2016-03-09 16:12:18.860264",
            "requirements": [],
            "self": "https://api.araport.org/community/v0.3/eriksf-dev/strand_v0.1",
            "sources": [],
            "tags": [],
            "timeout": 30,
            "type": "query",
            "url": "http://mpss.danforthcenter.org/",
            "users": {
                "admin": [
                    "POST",
                    "PUT",
                    "DELETE"
                ],
                "araport/eriksf@carbon.super": [
                    "POST",
                    "PUT",
                    "DELETE"
                ]
            },
            "validate_request": false,
            "validate_response": false,
            "version": 0.1,
            "whitelist": {
                "129.114.97.1": {},
                "129.114.97.2": {},
                "129.116.84.203": {},
                "172.17.42.1": {},
                "mpss.danforthcenter.org": {}
            },
            "workers": [
                "79f64699511ab736c23fbf2baa10650925419eb420a21d0339091eea6dd01e93"
            ]
        }
    },
    "status": "success"
}

Great! Now we know that the adapter has been installed properly. A lot of the data that is returned here you will recognize from the metadata.yml file.

A final thing to note is that the API explorer on the Araport website is not a good place to use for checking Adama updates. The application is cached for performance reasons so it will NOT reflect the changes to Adama immediately (it will take a couple of minutes to refresh).