This is the Orchestrator of the Morpheo platform with the blockchain. We use the private and permissioned solution called Hyperledger Fabric. Morpheo chaincode corresponds to the set of smart contracts, which are used to orchestrate operations on the Morpheo platform. It is the translation of Morpheo Orchestrator with a blockchain solution.
Licence: CECILL 2.1 (compatible with GNU GPL)
Use the Morpheo-Fabric-Bootstrap to create a network to interact with the Orchestrator. Once the network is up, the chaincode is installed and instantiated, you can go inside the docker cli to interact with the Orchestrator. Below some interaction examples, do not forget to set the correct environment variable:
peer chaincode query -n mycc -c '{"Args":["queryObject", "algo_1"]}' -C $CHANNEL_NAME
peer chaincode query -n mycc -c '{"Args":["queryObjects", "algo"]}' -C $CHANNEL_NAME
peer chaincode invoke -o orderer.morpheo.co:7050 --tls true --cafile $ORDERER_CA -n mycc -c '{"Args":["registerProblem", "e568587d-572c-4714-8084-378ed50d1c52", "2", "0pa81bfc-b5f4-5ba2-b81a-b464248f02a1, 0kk81bfc-b5f4-5ba2-b81a-b464248f02e3"]}' -C $CHANNEL_NAME
peer chaincode invoke -o orderer.morpheo.co:7050 --tls true --cafile $ORDERER_CA -n mycc -c '{"Args":["registerItem", "algo", "0pa81baa-b5f4-5ba2-b81a-b464248f02d2", "problem_1", "mytopalgo"]}' -C $CHANNEL_NAME
peer chaincode invoke -o orderer.morpheo.co:7050 --tls true --cafile $ORDERER_CA -n mycc -c '{"Args":["registerItem", "data", "9pa81bfc-b5f8-5ba2-b81a-b464248f02d2", "problem_1", "psg"]}' -C $CHANNEL_NAME
peer chaincode query -n mycc -c '{"Args":["queryProblemItems", "data", "problem_1"]}' -C $CHANNEL_NAME
peer chaincode query -n mycc -c '{"Args":["queryStatusLearnuplet", "todo"]}' -C $CHANNEL_NAME
// replace algo_0 with correct key
peer chaincode query -n mycc -c '{"Args":["queryAlgoLearnuplet", "algo_0"]}' -C $CHANNEL_NAME
// replace learnuplet_0 with correct key
peer chaincode invoke -o orderer.morpheo.co:7050 --tls true --cafile $ORDERER_CA -n mycc -c '{"Args":["setUpletWorker", "learnuplet_0", "Arbeiter_12"]}' -C $CHANNEL_NAME
// replace learnuplet_0 with correct key
peer chaincode invoke -o orderer.morpheo.co:7050 --tls true --cafile $ORDERER_CA -n mycc -c '{"Args":["reportLearn", "learnuplet_0", "done", "0.82", "{\"data_3\": 0.78, \"data_4\": 0.88}", "{\"data_2\": 0.80}"]}' -C $CHANNEL_NAME
You can use the chaincode-docker-devmode
to more easily develop the chaincode, as detailed here
The ledger is a key value store.
To be able to make complex queries, such as querying all algorithms related to a problem, we use CompositeKey
.
We call an ObjectType
a type of element of the ledger (similar to a table in a relational database).
Data and algo are 2 ObjectTypes, which both derive from an Item structure:
type Item struct {
ObjectType string `json:"docType"`
StorageAddress string `json:"storageAddress"`
Problem string `json:"problem"`
Name string `json:"name"`
}
Keys: data_<uuid>
and algo_<uuid>
.
Associated composite keys: data~problem~key
and algo~problem~key
.
A problem derives from the Problem structure:
type Problem struct {
ObjectType string `json:"docType"`
StorageAddress string `json:"storageAddress"`
SizeTrainDataset int `json:"sizeTrainDataset"`
TestData []string `json:"testData"`
}
Keys: problem_<uuid>
.
A learnuplet derives from the Learnuplet structure:
type Learnuplet struct {
ObjectType string `json:"docType"`
Problem map[string]string `json:"problem"` // {problemKey: problemStorageAddress}
Algo map[string]string `json:"algo"` // {algoKey: algoStorageAddress}
ModelStartAddress string `json:"modelStartAddress"`
ModelEndAddress string `json:"modelEndAddress"`
TrainData map[string]string `json:"trainData"` // {data1Key: data1StorageAddress, ...}
TestData map[string]string `json:"testData"` // {data1Key: data1StorageAddress, ...}
Worker string `json:"worker"`
Status string `json:"status"`
Rank int `json:"rank"`
Perf float64 `json:"perf"`
TrainPerf map[string]float64 `json:"trainPerf"`
TestPerf map[string]float64 `json:"testPerf"`
}
Keys: learnuplet_<uuid>
.
Associated composite key: learnuplet~algo~key
.
Args:
objectKey
, such asdata_8fa81bfc-b5f4-4ba2-b81a-b464248f02d3
,learnuplet_ca3a5a53-9684-429f-9896-4f7c94f9def0
peer chaincode query -n mycc -c '{"Args":["queryObject", "learnuplet_ca3a5a53-9684-429f-9896-4f7c94f9def0"]}' -C $CHANNEL_NAME
Args:
objectType
, such asdata
,learnuplet
peer chaincode query -n mycc -c '{"Args":["queryObjects", "learnuplet"]}' -C $CHANNEL_NAME
Args:
itemType
:data
oralgo
problemKey
, such asproblem_8fa81bfc-b5f4-4ba2-b81a-b464248f02d3
peer chaincode query -n mycc -c '{"Args":["queryProblemItems", "data", "problem_8fa81bfc-b5f4-4ba2-b81a-b464248f02d3"]}' -C $CHANNEL_NAME
TODO: modify function to register several data at a time
Args:
itemType
:data
oralgo
storageAddress
, for now it corresponds to the uuid on Storage, such as0pa81bfc-b5f4-5ba2-b81a-b464248f02d2
problemKey
, such asproblem_2
itemName
, such asmysuperalgo
peer chaincode invoke -o orderer.morpheo.co:7050 --tls true --cafile $ORDERER_CA -n mycc -c '{"Args":["registerItem",
"algo", "0pa81bfc-b5f4-5ba2-b81a-b464248f02d2", "problem_1", "topalgo"]}' -C $CHANNEL_NAME
peer chaincode invoke -o orderer.morpheo.co:7050 --tls true --cafile $ORDERER_CA -n mycc -c '{"Args":["registerItem", "data", "9pa81bfc-b5f4-5ba2-b81a-b464248f02d2", "problem_1", "psg"]}' -C $CHANNEL_NAME
Args:
storageAddress
: address of the problem workflow on storagesizeTrainDataset
: number of train data per mini-batchtestData
: list of test data adresses on storage
peer chaincode invoke -o orderer.morpheo.co:7050 --tls true --cafile $ORDERER_CA -n mycc -c '{"Args":["registerProblem", "dda81bfc-b5f4-5ba2-b81a-b464248f02d2", "2", "0pa81bfc-b5f4-5ba2-b81a-b464248f02a1, 0pa81bfc-b5f4-5ba2-b81a-b464248f02e3"]}' -C $CHANNEL_NAME
Args:
status
:todo
,pending
,failed
, ordone
peer chaincode query -n mycc -c '{"Args":["queryStatusLearnuplet", "todo"]}' -C $CHANNEL_NAME
Args:
algoKey
: algo key of the algo of interest
peer chaincode query -n mycc -c '{"Args":["queryAlgoLearnuplet", "algo_f50844e0-90e7-4fb8-a2aa-3d7e49204584"]}' -C $CHANNEL_NAME
Args:
learnupletKey
, such aslearnuplet_f50844e0-90e7-4fb8-a2aa-3d7e49204584
worker
: worker identifier... to be defined
peer chaincode invoke -o orderer.morpheo.co:7050 --tls true --cafile $ORDERER_CA -n mycc -c '{"Args":["setUpletWorker", "learnuplet_f50844e0-90e7-4fb8-a2aa-3d7e49204584", "Arbeiter_12"]}' -C $CHANNEL_NAME
Args:
learnupletKey
, such aslearnuplet_f50844e0-90e7-4fb8-a2aa-3d7e49204584
status
:done
orfailed
perf
: performance of the model (performance on test data), such as0.99
trainPerf
: performances on each train data, such as{\"data_12\": 0.89, \"data_22\": 0.92, \"data_34\": 0.88, \"data_44\": 0.96}
testPerf
: performances on each test data, such as{\"data_2\": 0.82, \"data_4\": 0.94, \"data_6\": 0.88}
peer chaincode invoke -o orderer.morpheo.co:7050 --tls true --cafile $ORDERER_CA -n mycc -c '{"Args":["reportLearn", "learnuplet_f50844e0-90e7-4fb8-a2aa-3d7e49204584", "done", "0.82", "{\"data_3\": 0.78, \"data_4\": 0.88}", "{\"data_2\": 0.80}"]}' -C $CHANNEL_NAME
- register several data at a time