Simple Task

A Simple Task

🚧

Assumptions Ahead

These examples assume you are using the permissive whitelist. If you restrict the whitelist, these examples will need to be modified.

πŸ“˜

Minimum Version Required

These examples assume you are running v14.1.1 or later. Older versions of Computes will not run these examples correctly.

Let's run a very simple task. First make sure you've looked at Getting Started with Computes and have the IPFS and Computes daemon running on your machine.

This task will simply take an input value and split it into an array of numbers.

1. Copy This File

{
  "input": {
    "dataset": 2
  },
  "taskDefinition": {
    "runner": {
      "type": "docker-json-runner",
      "manifest": {
        "*": {
          "image": "computes/fibonacci-sum-split:latest"
        }
      }
    },
    "result": {
      "action": "set",
      "destination": {
        "dataset": { 
          "init": "simple-task-results"
        },
        "path": "split/results"
      }
    }
  },
  "status": {
    "init": "split-task-status"
  }
}

Before we are able to run this task, we'll need to fill in some of those values.

A Dataset is a repository of data that allows Computes clients to collect input/output in a distributed way. A task status is also a Dataset.

2. Add split-task.json to IPFS

Add the task to IPFS so we can enqueue it.

cat split-task.json | ipfs dag put > split-task.hash

3. Enqueue the Task

Enqueue the task so it can be run by Computes.

cat split-task.hash | computes-cli task enqueue

4. Check the results

You may periodically run this command to see if the results are in. In this case we should see some data under split/results and map/results. When the task is complete, you'll see an array of numbers in the results. We'll explain more in Chained Task.

cat split-task.hash | computes-cli task dataset

Expected Results:

{
  "split": {
    "results": [
      1,
      2
    ]
  }
}

No response? Check task status for errors

cat split-task.hash | computes-cli task status

What’s Next