Created
June 20, 2018 21:05
-
-
Save chrismatthieu/2a435d5a4d7e740b13f850e3500fc02a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# https://github.com/computes/help/wiki/First-Task | |
function poll { | |
pollResults=`cat result-dataset.hash | computes-cli dataset dumplatest` | |
if [[ $pollResults != *"tasks"* ]]; then | |
echo "Computing ... $pollResults" | |
sleep 1 | |
poll | |
else | |
echo $pollResults | jq | |
fi | |
} | |
echo "Get ready to experience awesomeness!" | |
echo "" | |
echo "> creating result-dataset" | |
computes-cli dataset create --generate-uuid > result-dataset.hash | |
results=`cat result-dataset.hash` | |
echo $results | |
echo "> creating split-status" | |
computes-cli dataset create --generate-uuid > split-status.hash | |
status=`cat split-status.hash` | |
echo $status | |
echo "" | |
echo "> creating split-task.json" | |
FILE="./split-task-auto.json" | |
/bin/cat <<EOM >$FILE | |
{ | |
"input": { | |
"dataset": 2 | |
}, | |
"taskDefinition": { | |
"runner": { | |
"type": "docker-json-runner", | |
"manifest": { | |
"*": { | |
"image": "computes/fibonacci-sum-split:latest" | |
} | |
} | |
}, | |
"result": { | |
"action": "set", | |
"destination": { | |
"dataset": { "/": "$results" }, | |
"path": "split/results" | |
} | |
} | |
}, | |
"status": { | |
"/": "$status" | |
} | |
} | |
EOM | |
echo `cat split-task-auto.json` | |
echo "" | |
echo "> adding task to Computes FS" | |
echo "cat split-task-auto.json | ipfs dag put > split-task.hash" | |
cat split-task-auto.json | ipfs dag put > split-task.hash | |
echo "added" | |
echo "> adding task to Lattice" | |
echo "cat split-task.hash | computes-cli task enqueue" | |
cat split-task.hash | computes-cli task enqueue | |
echo "" | |
echo "> checking status of queues" | |
echo "computes-cli queue dump | jq" | |
computes-cli queue dump | jq | |
echo "" | |
echo "> checking for results" | |
echo "cat result-dataset.hash | computes-cli dataset dumplatest" | |
# sleep 5 | |
poll | |
echo "" | |
echo "Congratulations! You have just run your first decentralized compute!" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment