Skip to content
Panayiotis edited this page Apr 3, 2016 · 4 revisions

# Running the algorithm on a single image and getting back the results as JSON

To do this you need to send a GET request to backend/src/api/internal/algorithm.php

Request:

GET backend/src/api/internal/algorithm.php?action=query&image_id=2344&scientist_dataset=false&store=false

Parameters

  • action : Must be set to query
  • image_id : The image id you want to get results for
  • store (Optional) : Whether to also store the results
  • scientist_dataset (Optional) : Whether to store in the scientist data table

Response:

{
   "result":{
      "classification":{
         "22":"1"
      },
      "evenness_species":0,
      "evenness_count":0
   }
}

# Start the algorithm on the whole database

To start the algorithm you need to send a POST request to backend/src/api/internal/algorithm.php with the action field set to run.

Parameters

  • action : Must be set to run
  • from_id (Optional) : Image ID to run FROM
  • to_id (Optional) : Image ID to run TO
  • scientist_dataset (Optional) : Whether to store in the scientist data table
  • settings (Optional): A settings object, otherwise don't set for the current scientist settings (Note: this will never update the default setings, see Updating Settings on how to do that)

Example:

    
    var settingsObj = {
        "consecutive_expected": 12,
        "votes_before_consensus": 15,
        "unreasonable_number_of_species_in_image": 10,
        "evenness_threshold_species": 0.69,
        "evenness_threshold_count": 0.7
    };

    $.ajax({
        url:     "../backend/src/api/internal/algorithm.php",
        type:    "POST",
        data:   {
                "action"  : "run",
                "from_id" : 1,
                "to_id" : 4000,
                "scientist_dataset" : true,
                "settings":  JSON.stringify(settingsObj)
                }
    });

Response:

{
   "success":true,
   "log":"Algorithm started."
}

The algorithm has now started in the BACKGROUND (as it takes some time to finish)

# Viewing the algorithm progress

To see how far is the progress of the algorithm, you can poll periodically the backend/src/api/internal/algorithm.php file using a GET request.

Request GET backend/src/api/internal/algorithm.php?action=status

Response

{
   "type":"algorithm",
   "started":true,
   "progress":"5000",
   "total":"42068"
}

Clone this wiki locally