Skip to content
This repository was archived by the owner on Sep 6, 2022. It is now read-only.

Commit c5cd878

Browse files
authored
Merge pull request #125 from SubstraFoundation/snake_case
Snake case
2 parents db594f9 + 22e3d64 commit c5cd878

14 files changed

+467
-478
lines changed

EXAMPLES.md

Lines changed: 292 additions & 292 deletions
Large diffs are not rendered by default.

chaincode/data_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ func TestGetTestDatasetKeys(t *testing.T) {
134134
err := json.Unmarshal(resp.Payload, &payload)
135135
assert.NoError(t, err)
136136

137-
v, ok := payload["testDataSampleKeys"]
137+
v, ok := payload["test_data_sample_keys"]
138138
assert.True(t, ok, "payload should contains the test dataSample keys")
139139
assert.Contains(t, v, testDataSampleHash2, "testDataSampleKeys should contain the test dataSampleHash")
140140
assert.NotContains(t, v, testDataSampleHash1, "testDataSampleKeys should not contains the train dataSampleHash")

chaincode/input.go

Lines changed: 52 additions & 52 deletions
Large diffs are not rendered by default.

chaincode/input_aggregate.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ package main
1616

1717
// inputAggregatetuple is the representation of input args to register an aggregate Tuple
1818
type inputAggregatetuple struct {
19-
AlgoKey string `validate:"required,len=64,hexadecimal" json:"algoKey"`
20-
InModels []string `validate:"omitempty,dive,len=64,hexadecimal" json:"inModels"`
21-
ComputePlanID string `validate:"omitempty" json:"computePlanID"`
19+
AlgoKey string `validate:"required,len=64,hexadecimal" json:"algo_key"`
20+
InModels []string `validate:"omitempty,dive,len=64,hexadecimal" json:"in_models"`
21+
ComputePlanID string `validate:"omitempty" json:"compute_plan_id"`
2222
Metadata map[string]string `validate:"lte=100,dive,keys,lte=50,endkeys,lte=100" json:"metadata"`
2323
Rank string `validate:"omitempty" json:"rank"`
2424
Tag string `validate:"omitempty,lte=64" json:"tag"`

chaincode/input_composite.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@ package main
1616

1717
// inputCompositeTraintuple is the representation of input args to register a composite Traintuple
1818
type inputCompositeTraintuple struct {
19-
AlgoKey string `validate:"required,len=64,hexadecimal" json:"algoKey"`
20-
InHeadModelKey string `validate:"required_with=InTrunkModelKey,omitempty,len=64,hexadecimal" json:"inHeadModelKey"`
21-
InTrunkModelKey string `validate:"required_with=InHeadModelKey,omitempty,len=64,hexadecimal" json:"inTrunkModelKey"`
22-
OutTrunkModelPermissions inputPermissions `validate:"required" json:"OutTrunkModelPermissions"`
23-
DataManagerKey string `validate:"required,len=64,hexadecimal" json:"dataManagerKey"`
24-
DataSampleKeys []string `validate:"required,unique,gt=0,dive,len=64,hexadecimal" json:"dataSampleKeys"`
25-
ComputePlanID string `validate:"omitempty" json:"computePlanID"`
19+
AlgoKey string `validate:"required,len=64,hexadecimal" json:"algo_key"`
20+
InHeadModelKey string `validate:"required_with=InTrunkModelKey,omitempty,len=64,hexadecimal" json:"in_head_model_key"`
21+
InTrunkModelKey string `validate:"required_with=InHeadModelKey,omitempty,len=64,hexadecimal" json:"in_trunk_model_key"`
22+
OutTrunkModelPermissions inputPermissions `validate:"required" json:"out_trunk_model_permissions"`
23+
DataManagerKey string `validate:"required,len=64,hexadecimal" json:"data_manager_key"`
24+
DataSampleKeys []string `validate:"required,unique,gt=0,dive,len=64,hexadecimal" json:"data_sample_keys"`
25+
ComputePlanID string `validate:"omitempty" json:"compute_plan_id"`
2626
Rank string `validate:"omitempty" json:"rank"`
2727
Tag string `validate:"omitempty,lte=64" json:"tag"`
2828
Metadata map[string]string `validate:"lte=100,dive,keys,lte=50,endkeys,lte=100" json:"metadata"`
@@ -34,6 +34,6 @@ type inputCompositeAlgo struct {
3434

3535
type inputLogSuccessCompositeTrain struct {
3636
inputLog
37-
OutHeadModel inputHash `validate:"required" json:"outHeadModel"`
38-
OutTrunkModel inputHashDress `validate:"required" json:"outTrunkModel"`
37+
OutHeadModel inputHash `validate:"required" json:"out_head_model"`
38+
OutTrunkModel inputHashDress `validate:"required" json:"out_trunk_model"`
3939
}

chaincode/ledger.go

Lines changed: 53 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -46,41 +46,41 @@ type StatusUpdater interface {
4646
// Objective is the representation of one of the element type stored in the ledger
4747
type Objective struct {
4848
Name string `json:"name"`
49-
AssetType AssetType `json:"assetType"`
50-
DescriptionStorageAddress string `json:"descriptionStorageAddress"`
49+
AssetType AssetType `json:"asset_type"`
50+
DescriptionStorageAddress string `json:"description_storage_address"`
5151
Metrics *HashDressName `json:"metrics"`
5252
Owner string `json:"owner"`
53-
TestDataset *Dataset `json:"testDataset"`
53+
TestDataset *Dataset `json:"test_dataset"`
5454
Permissions Permissions `json:"permissions"`
5555
Metadata map[string]string `json:"metadata"`
5656
}
5757

5858
// DataManager is the representation of one of the elements type stored in the ledger
5959
type DataManager struct {
6060
Name string `json:"name"`
61-
AssetType AssetType `json:"assetType"`
62-
OpenerStorageAddress string `json:"openerStorageAddress"`
61+
AssetType AssetType `json:"asset_type"`
62+
OpenerStorageAddress string `json:"opener_storage_address"`
6363
Type string `json:"type"`
6464
Description *HashDress `json:"description"`
6565
Owner string `json:"owner"`
66-
ObjectiveKey string `json:"objectiveKey"`
66+
ObjectiveKey string `json:"objective_key"`
6767
Permissions Permissions `json:"permissions"`
6868
Metadata map[string]string `json:"metadata"`
6969
}
7070

7171
// DataSample is the representation of one of the element type stored in the ledger
7272
type DataSample struct {
73-
AssetType AssetType `json:"assetType"`
74-
DataManagerKeys []string `json:"dataManagerKeys"`
73+
AssetType AssetType `json:"asset_type"`
74+
DataManagerKeys []string `json:"data_manager_keys"`
7575
Owner string `json:"owner"`
7676
TestOnly bool `json:"testOnly"`
7777
}
7878

7979
// Algo is the representation of one of the element type stored in the ledger
8080
type Algo struct {
8181
Name string `json:"name"`
82-
AssetType AssetType `json:"assetType"`
83-
StorageAddress string `json:"storageAddress"`
82+
AssetType AssetType `json:"asset_type"`
83+
StorageAddress string `json:"storage_address"`
8484
Description *HashDress `json:"description"`
8585
Owner string `json:"owner"`
8686
Permissions Permissions `json:"permissions"`
@@ -101,9 +101,9 @@ type AggregateAlgo struct {
101101
// that are common to Traintuple, CompositeTraintuple and
102102
// AggregateTuple
103103
type GenericTuple struct {
104-
AssetType AssetType `json:"assetType"`
105-
AlgoKey string `json:"algoKey"`
106-
ComputePlanID string `json:"computePlanID"`
104+
AssetType AssetType `json:"asset_type"`
105+
AlgoKey string `json:"algo_key"`
106+
ComputePlanID string `json:"compute_plan_id"`
107107
Creator string `json:"creator"`
108108
Log string `json:"log"`
109109
Metadata map[string]string `json:"metadata"`
@@ -114,79 +114,79 @@ type GenericTuple struct {
114114

115115
// Traintuple is the representation of one the element type stored in the ledger. It describes a training task occuring on the platform
116116
type Traintuple struct {
117-
AssetType AssetType `json:"assetType"`
118-
AlgoKey string `json:"algoKey"`
119-
ComputePlanID string `json:"computePlanID"`
117+
AssetType AssetType `json:"asset_type"`
118+
AlgoKey string `json:"algo_key"`
119+
ComputePlanID string `json:"compute_plan_id"`
120120
Creator string `json:"creator"`
121121
Log string `json:"log"`
122122
Metadata map[string]string `json:"metadata"`
123123
Rank int `json:"rank"`
124124
Status string `json:"status"`
125125
Tag string `json:"tag"`
126126
Dataset *Dataset `json:"dataset"`
127-
InModelKeys []string `json:"inModels"`
128-
OutModel *HashDress `json:"outModel"`
127+
InModelKeys []string `json:"in_models"`
128+
OutModel *HashDress `json:"out_model"`
129129
Permissions Permissions `json:"permissions"`
130130
}
131131

132132
// CompositeTraintuple is like a traintuple, but for composite model composition
133133
type CompositeTraintuple struct {
134-
AssetType AssetType `json:"assetType"`
135-
AlgoKey string `json:"algoKey"`
136-
ComputePlanID string `json:"computePlanID"`
134+
AssetType AssetType `json:"asset_type"`
135+
AlgoKey string `json:"algo_key"`
136+
ComputePlanID string `json:"compute_plan_id"`
137137
Creator string `json:"creator"`
138138
Log string `json:"log"`
139139
Metadata map[string]string `json:"metadata"`
140140
Rank int `json:"rank"`
141141
Status string `json:"status"`
142142
Tag string `json:"tag"`
143143
Dataset *Dataset `json:"dataset"`
144-
InHeadModel string `json:"inHeadModel"`
145-
InTrunkModel string `json:"inTrunkModel"`
146-
OutHeadModel CompositeTraintupleOutHeadModel `json:"outHeadModel"`
147-
OutTrunkModel CompositeTraintupleOutModel `json:"outTrunkModel"`
144+
InHeadModel string `json:"in_head_model"`
145+
InTrunkModel string `json:"in_trunk_model"`
146+
OutHeadModel CompositeTraintupleOutHeadModel `json:"out_head_model"`
147+
OutTrunkModel CompositeTraintupleOutModel `json:"out_trunk_model"`
148148
}
149149

150150
// Aggregatetuple is like a traintuple, but for aggregate model composition
151151
type Aggregatetuple struct {
152-
AssetType AssetType `json:"assetType"`
153-
AlgoKey string `json:"algoKey"`
154-
ComputePlanID string `json:"computePlanID"`
152+
AssetType AssetType `json:"asset_type"`
153+
AlgoKey string `json:"algo_key"`
154+
ComputePlanID string `json:"compute_plan_id"`
155155
Creator string `json:"creator"`
156156
Log string `json:"log"`
157157
Metadata map[string]string `json:"metadata"`
158158
Rank int `json:"rank"`
159159
Status string `json:"status"`
160160
Tag string `json:"tag"`
161-
InModelKeys []string `json:"inModels"`
162-
OutModel *HashDress `json:"outModel"`
161+
InModelKeys []string `json:"in_models"`
162+
OutModel *HashDress `json:"out_model"`
163163
Permissions Permissions `json:"permissions"` // TODO (aggregate): what do permissions mean here?
164164
Worker string `json:"worker"`
165165
}
166166

167167
// CompositeTraintupleOutModel is the out-model of a CompositeTraintuple
168168
type CompositeTraintupleOutModel struct {
169-
OutModel *HashDress `json:"outModel"`
169+
OutModel *HashDress `json:"out_model"`
170170
Permissions Permissions `json:"permissions"`
171171
}
172172

173173
// CompositeTraintupleOutHeadModel is the out-model of a CompositeTraintuple
174174
type CompositeTraintupleOutHeadModel struct {
175-
OutModel *Hash `json:"outModel"`
175+
OutModel *Hash `json:"out_model"`
176176
Permissions Permissions `json:"permissions"`
177177
}
178178

179179
// Testtuple is the representation of one the element type stored in the ledger. It describes a training task occuring on the platform
180180
type Testtuple struct {
181181
AlgoKey string `json:"algo"`
182-
AssetType AssetType `json:"assetType"`
182+
AssetType AssetType `json:"asset_type"`
183183
Certified bool `json:"certified"`
184-
ComputePlanID string `json:"computePlanID"`
184+
ComputePlanID string `json:"compute_plan_id"`
185185
Creator string `json:"creator"`
186186
Dataset *TtDataset `json:"dataset"`
187187
Log string `json:"log"`
188188
Metadata map[string]string `json:"metadata"`
189-
TraintupleKey string `json:"traintupleKey"`
189+
TraintupleKey string `json:"traintuple_key"`
190190
ObjectiveKey string `json:"objective"`
191191
Permissions Permissions `json:"permissions"`
192192
Rank int `json:"rank"`
@@ -196,27 +196,27 @@ type Testtuple struct {
196196

197197
// ComputePlan is the ledger's representation of a compute plan.
198198
type ComputePlan struct {
199-
AggregatetupleKeys []string `json:"aggregatetupleKeys"`
200-
AssetType AssetType `json:"assetType"`
201-
CleanModels bool `json:"cleanModels"` // whether or not to delete intermediary models
202-
CompositeTraintupleKeys []string `json:"compositeTraintupleKeys"`
203-
IDToTrainTask map[string]TrainTask `json:"IDToTrainTask"`
199+
AggregatetupleKeys []string `json:"aggregatetuple_keys"`
200+
AssetType AssetType `json:"asset_type"`
201+
CleanModels bool `json:"clean_models"` // whether or not to delete intermediary models
202+
CompositeTraintupleKeys []string `json:"composite_traintuple_keys"`
203+
IDToTrainTask map[string]TrainTask `json:"id_to_train_task"`
204204
Metadata map[string]string `json:"metadata"`
205205
State ComputePlanState `json:"-"` // "-" means this field is excluded from JSON (de)serialization
206-
StateKey string `json:"stateKey"`
206+
StateKey string `json:"state_key"`
207207
Tag string `json:"tag"`
208-
TesttupleKeys []string `json:"testtupleKeys"`
209-
TraintupleKeys []string `json:"traintupleKeys"`
208+
TesttupleKeys []string `json:"testtuple_keys"`
209+
TraintupleKeys []string `json:"traintuple_keys"`
210210
}
211211

212212
// ComputePlanState is the ledger's representation of the compute plan state.
213213
// To minimize the size of every compute plan, update its state record under another
214214
// key in the ledger. It will reduce the growing rate of the blockchain size.
215215
type ComputePlanState struct {
216-
DoneCount int `json:"doneCount"`
217-
IntermediaryModelsInUse []string `json:"intermediaryModelsInUse"`
216+
DoneCount int `json:"done_count"`
217+
IntermediaryModelsInUse []string `json:"intermediary_models_in_use"`
218218
Status string `json:"status"`
219-
TupleCount int `json:"tupleCount"`
219+
TupleCount int `json:"tuple_count"`
220220
}
221221

222222
// TrainTask is represent the information for one tuple in a Compute Plan
@@ -237,27 +237,27 @@ type Hash struct {
237237
// HashDress stores a hash and a Storage Address
238238
type HashDress struct {
239239
Hash string `json:"hash"`
240-
StorageAddress string `json:"storageAddress"`
240+
StorageAddress string `json:"storage_address"`
241241
}
242242

243243
// HashDressName stores a hash, storage address and a name
244244
type HashDressName struct {
245245
Name string `json:"name"`
246246
Hash string `json:"hash"`
247-
StorageAddress string `json:"storageAddress"`
247+
StorageAddress string `json:"storage_address"`
248248
}
249249

250250
// Model stores the traintupleKey leading to the model, its hash and storage addressl
251251
type Model struct {
252-
TraintupleKey string `json:"traintupleKey"`
252+
TraintupleKey string `json:"traintuple_key"`
253253
Hash string `json:"hash"`
254-
StorageAddress string `json:"storageAddress"`
254+
StorageAddress string `json:"storage_address"`
255255
}
256256

257257
// Dataset stores info about a dataManagerKey and a list of associated dataSample
258258
type Dataset struct {
259-
DataManagerKey string `json:"dataManagerKey"`
260-
DataSampleKeys []string `json:"dataSampleKeys"`
259+
DataManagerKey string `json:"data_manager_key"`
260+
DataSampleKeys []string `json:"data_sample_keys"`
261261
Metadata map[string]string `json:"metadata"`
262262
Worker string `json:"worker"`
263263
}
@@ -270,7 +270,7 @@ type Dataset struct {
270270
type TtDataset struct {
271271
Worker string `json:"worker"`
272272
DataSampleKeys []string `json:"keys"`
273-
OpenerHash string `json:"openerHash"`
273+
OpenerHash string `json:"opener_hash"`
274274
Perf float32 `json:"perf"`
275275
}
276276

chaincode/ledger_db.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ func (db *LedgerDB) GetIndexKeys(index string, attributes []string) ([]string, e
184184
// It fails if it does not exists or if it does not have an `AssetType` field.
185185
func (db *LedgerDB) GetAssetType(key string) (AssetType, error) {
186186
asset := struct {
187-
AssetType AssetType `json:"assetType"`
187+
AssetType AssetType `json:"asset_type"`
188188
}{}
189189
if err := db.Get(key, &asset); err != nil {
190190
return asset.AssetType, err

chaincode/mockstub_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -650,12 +650,12 @@ func newCompositeKey(objectType string, attributes []string) (string, error) {
650650
if err := validateCompositeKeyAttribute(objectType); err != nil {
651651
return "", err
652652
}
653-
ck := compositeKeyNamespace + objectType + string(minUnicodeRuneValue)
653+
ck := compositeKeyNamespace + objectType + string(rune(minUnicodeRuneValue))
654654
for _, att := range attributes {
655655
if err := validateCompositeKeyAttribute(att); err != nil {
656656
return "", err
657657
}
658-
ck += att + string(minUnicodeRuneValue)
658+
ck += att + string(rune(minUnicodeRuneValue))
659659
}
660660
return ck, nil
661661
}

0 commit comments

Comments
 (0)