Skip to content
This repository has been archived by the owner on Sep 4, 2024. It is now read-only.

Commit

Permalink
Add error handling (#135)
Browse files Browse the repository at this point in the history
Fix parsing error when it's not expected
  • Loading branch information
RedBird96 authored Jul 8, 2024
1 parent 0ceaae0 commit dfe096f
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 8 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,8 @@ data-head
data-worker
data-worker-2
main.py
avs/
vendor/
debug/
configs/
.DS_Store
35 changes: 28 additions & 7 deletions cmd/node/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,10 @@ func (e *AlloraExecutor) ExecuteFunction(requestID string, req execute.Request)
inferenceForecastsBundle := &types.InferenceForecastBundle{}
// Build inference if existent
if responseValue.InfererValue != "" {
infererValue := alloraMath.MustNewDecFromString(responseValue.InfererValue)
infererValue, err := alloraMath.NewDecFromString(responseValue.InfererValue)
if err != nil {
return result, err
}
inference := &types.Inference{
TopicId: topicId,
Inferer: e.appChain.Address,
Expand All @@ -202,7 +205,10 @@ func (e *AlloraExecutor) ExecuteFunction(requestID string, req execute.Request)
if len(responseValue.ForecasterValues) > 0 {
var forecasterElements []*types.ForecastElement
for _, val := range responseValue.ForecasterValues {
decVal := alloraMath.MustNewDecFromString(val.Value)
decVal, err := alloraMath.NewDecFromString(val.Value)
if err != nil {
return result, err
}
if !topicAllowsNegative {
decVal, err = alloraMath.Log10(decVal)
if err != nil {
Expand Down Expand Up @@ -333,7 +339,10 @@ func (e *AlloraExecutor) ExecuteFunction(requestID string, req execute.Request)
)

for _, inf := range nestedValueBundle.InfererValues {
value := alloraMath.MustNewDecFromString(inf.Value)
value, err := alloraMath.NewDecFromString(inf.Value)
if err != nil {
return result, err
}
if !topicAllowsNegative {
value, err = alloraMath.Log10(value)
if err != nil {
Expand All @@ -347,7 +356,10 @@ func (e *AlloraExecutor) ExecuteFunction(requestID string, req execute.Request)
})
}
for _, inf := range nestedValueBundle.ForecasterValues {
value := alloraMath.MustNewDecFromString(inf.Value)
value, err := alloraMath.NewDecFromString(inf.Value)
if err != nil {
return result, err
}
if !topicAllowsNegative {
value, err = alloraMath.Log10(value)
if err != nil {
Expand All @@ -361,7 +373,10 @@ func (e *AlloraExecutor) ExecuteFunction(requestID string, req execute.Request)
})
}
for _, inf := range nestedValueBundle.OneOutInfererValues {
value := alloraMath.MustNewDecFromString(inf.Value)
value, err := alloraMath.NewDecFromString(inf.Value)
if err != nil {
return result, err
}
if !topicAllowsNegative {
value, err = alloraMath.Log10(value)
if err != nil {
Expand All @@ -375,7 +390,10 @@ func (e *AlloraExecutor) ExecuteFunction(requestID string, req execute.Request)
})
}
for _, inf := range nestedValueBundle.OneOutForecasterValues {
value := alloraMath.MustNewDecFromString(inf.Value)
value, err := alloraMath.NewDecFromString(inf.Value)
if err != nil {
return result, err
}
if !topicAllowsNegative {
value, err = alloraMath.Log10(value)
if err != nil {
Expand All @@ -389,7 +407,10 @@ func (e *AlloraExecutor) ExecuteFunction(requestID string, req execute.Request)
})
}
for _, inf := range nestedValueBundle.OneInForecasterValues {
value := alloraMath.MustNewDecFromString(inf.Value)
value, err := alloraMath.NewDecFromString(inf.Value)
if err != nil {
return result, err
}
if !topicAllowsNegative {
value, err = alloraMath.Log10(value)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion launch-node.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ allora-node \
--role head \
--workspace /tmp/debug/head \
--private-key ./testkeys/head/priv.bin \
--rest-api :8081
--rest-api :8081

0 comments on commit dfe096f

Please sign in to comment.