Last active
June 20, 2018 21:08
-
-
Save chrismatthieu/8e3a5fa489bddd489857efac0fba37e4 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!" |
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
Get ready to experience awesomeness! | |
> creating result-dataset | |
zdpuAvXPd5jjMTbVuBeN8LVbTyGFVVKwdXjUiN7mKXtLerj3b | |
> creating split-status | |
zdpuAsa6AJL5kuvWxxN4BRng8qqrgyif7NjzKVaTavs9W9FQ6 | |
> creating split-task.json | |
{ "input": { "dataset": 2 }, "taskDefinition": { "runner": { "type": "docker-json-runner", "manifest": { "*": { "image": "computes/fibonacci-sum-split:latest" } } }, "result": { "action": "set", "destination": { "dataset": { "/": "zdpuAvXPd5jjMTbVuBeN8LVbTyGFVVKwdXjUiN7mKXtLerj3b" }, "path": "split/results" } } }, "status": { "/": "zdpuAsa6AJL5kuvWxxN4BRng8qqrgyif7NjzKVaTavs9W9FQ6" } } | |
> adding task to Computes FS | |
cat split-task-auto.json | ipfs dag put > split-task.hash | |
added | |
> adding task to Lattice | |
cat split-task.hash | computes-cli task enqueue | |
Added task: zdpuAv3sXHX4H3gRfhFLwxREismE621qXAhZW6qLPGL6yHqzB | |
> checking status of queues | |
computes-cli queue dump | jq | |
{ | |
"__meta__": { | |
"computes": { | |
"seed": "18FB2F73-DE06-4D6E-BF2A-4BB86AD96A3A" | |
} | |
}, | |
"assigned": [ | |
"zdpuAotNcnAoPYiDHydTNFRotmvxXiVAz3mrkVkvcUYCZbuPY", | |
"zdpuAuSJ9dT4RmcvZCShAz9Bn2xthhdeKysmdhoZQ7K9H9NgL", | |
"zdpuAkeSXxtFudh9QEsYsqHY4cRTjZpCu6L59E6LaDfm47Qso", | |
"zdpuB1mCDM9xg4coBoxzJFBHdagapAo4ZjVTeymZraKj4MPTJ", | |
"zdpuAqLyQadxWrvzpP65RhsTvxa8ecsrALWLH1tAC3pZBbsaD" | |
], | |
"available": [ | |
"zdpuAuSJ9dT4RmcvZCShAz9Bn2xthhdeKysmdhoZQ7K9H9NgL", | |
"zdpuAkeSXxtFudh9QEsYsqHY4cRTjZpCu6L59E6LaDfm47Qso", | |
"zdpuAqLyQadxWrvzpP65RhsTvxa8ecsrALWLH1tAC3pZBbsaD", | |
"zdpuAotNcnAoPYiDHydTNFRotmvxXiVAz3mrkVkvcUYCZbuPY", | |
"zdpuB1mCDM9xg4coBoxzJFBHdagapAo4ZjVTeymZraKj4MPTJ", | |
"zdpuAv3sXHX4H3gRfhFLwxREismE621qXAhZW6qLPGL6yHqzB" | |
], | |
"completed": [ | |
"zdpuB1mCDM9xg4coBoxzJFBHdagapAo4ZjVTeymZraKj4MPTJ", | |
"zdpuAkeSXxtFudh9QEsYsqHY4cRTjZpCu6L59E6LaDfm47Qso", | |
"zdpuAuSJ9dT4RmcvZCShAz9Bn2xthhdeKysmdhoZQ7K9H9NgL", | |
"zdpuAqLyQadxWrvzpP65RhsTvxa8ecsrALWLH1tAC3pZBbsaD", | |
"zdpuAotNcnAoPYiDHydTNFRotmvxXiVAz3mrkVkvcUYCZbuPY" | |
] | |
} | |
> checking for results | |
cat result-dataset.hash | computes-cli dataset dumplatest | |
Computing ... {"__meta__":{"computes":{"seed":"4aeec6cd-d9f1-43b3-951e-5f5b32744efc"}}} | |
Computing ... {"__meta__":{"computes":{"seed":"4aeec6cd-d9f1-43b3-951e-5f5b32744efc"}}} | |
Computing ... {"__meta__":{"computes":{"seed":"4aeec6cd-d9f1-43b3-951e-5f5b32744efc"}}} | |
Computing ... {"__meta__":{"computes":{"seed":"4aeec6cd-d9f1-43b3-951e-5f5b32744efc"}}} | |
Computing ... {"__meta__":{"computes":{"seed":"4aeec6cd-d9f1-43b3-951e-5f5b32744efc"}}} | |
Computing ... {"__meta__":{"computes":{"seed":"4aeec6cd-d9f1-43b3-951e-5f5b32744efc"}}} | |
{ | |
"__meta__": { | |
"computes": { | |
"seed": "4aeec6cd-d9f1-43b3-951e-5f5b32744efc", | |
"tasks": { | |
"related": [ | |
"zdpuAv3sXHX4H3gRfhFLwxREismE621qXAhZW6qLPGL6yHqzB" | |
] | |
} | |
} | |
}, | |
"split": { | |
"results": [ | |
1, | |
2 | |
] | |
} | |
} | |
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