Skip to content

Commit

Permalink
Create Execution Success, need to implement get Execution
Browse files Browse the repository at this point in the history
Signed-off-by: Future-Outlier <[email protected]>
  • Loading branch information
Future-Outlier committed Aug 8, 2024
1 parent d5d7b79 commit c7c82ac
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 5 deletions.
2 changes: 2 additions & 0 deletions flytectl/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,8 @@ require (
github.com/spf13/viper v1.11.0 // indirect
github.com/stretchr/objx v0.5.2 // indirect
github.com/subosito/gotenv v1.2.0 // indirect
github.com/vmihailenco/msgpack/v5 v5.4.1 // indirect
github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect
go.opencensus.io v0.24.0 // indirect
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.47.0 // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.46.1 // indirect
Expand Down
4 changes: 4 additions & 0 deletions flytectl/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,10 @@ github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsT
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/subosito/gotenv v1.2.0 h1:Slr1R9HxAlEKefgq5jn9U+DnETlIUa6HfgEzj0g5d7s=
github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw=
github.com/vmihailenco/msgpack/v5 v5.4.1 h1:cQriyiUvjTwOHg8QZaPihLWeRAAVoCpE00IUPn0Bjt8=
github.com/vmihailenco/msgpack/v5 v5.4.1/go.mod h1:GaZTsDaehaPpQVyxrf5mtQlH+pc21PIudVV/E3rRQok=
github.com/vmihailenco/tagparser/v2 v2.0.0 h1:y09buUbR+b5aycVFQs/g70pqKVZNBmxwAhO7/IwNM9g=
github.com/vmihailenco/tagparser/v2 v2.0.0/go.mod h1:Wri+At7QHww0WTrCBeu4J6bNtoV6mEfg5OIWRZA9qds=
github.com/yalp/jsonpath v0.0.0-20180802001716-5cc68e5049a0 h1:6fRhSjgLCkTD3JnJxvaJ4Sj+TYblw757bqYgZaOq5ZY=
github.com/yalp/jsonpath v0.0.0-20180802001716-5cc68e5049a0/go.mod h1:/LWChgwKmvncFJFHJ7Gvn9wZArjbV5/FppcK2fKk/tI=
github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
Expand Down
2 changes: 1 addition & 1 deletion flyteidl/clients/go/coreutils/extract_literal.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func ExtractFromLiteral(literal *core.Literal) (interface{}, error) {
case *core.Scalar_StructuredDataset:
return scalarValue.StructuredDataset.Uri, nil
case *core.Scalar_Json:
return scalarValue.Json.Value, nil
return scalarValue.Json, nil
case *core.Scalar_Union:
// extract the value of the union but not the actual union object
extractedVal, err := ExtractFromLiteral(scalarValue.Union.Value)
Expand Down
22 changes: 18 additions & 4 deletions flyteidl/clients/go/coreutils/literals.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,19 @@ package coreutils
import (
"encoding/json"
"fmt"
"github.com/vmihailenco/msgpack/v5"
"math"
"reflect"
"strconv"
"strings"
"time"

"github.com/flyteorg/flyte/flyteidl/gen/pb-go/flyteidl/core"
"github.com/flyteorg/flyte/flytestdlib/storage"
"github.com/golang/protobuf/jsonpb"
"github.com/golang/protobuf/ptypes"
structpb "github.com/golang/protobuf/ptypes/struct"
"github.com/pkg/errors"

"github.com/flyteorg/flyte/flyteidl/gen/pb-go/flyteidl/core"
"github.com/flyteorg/flyte/flytestdlib/storage"
)

func MakePrimitive(v interface{}) (*core.Primitive, error) {
Expand Down Expand Up @@ -256,7 +256,7 @@ func MakeDefaultLiteralForType(typ *core.LiteralType) (*core.Literal, error) {
Scalar: &core.Scalar{
Value: &core.Scalar_Json{
Json: &core.Json{
Value: []byte("{}"),
Value: []byte(""),
},
},
},
Expand Down Expand Up @@ -398,6 +398,7 @@ func MakeLiteralForSimpleType(t core.SimpleType, s string) (*core.Literal, error
Generic: st,
}
case core.SimpleType_JSON:
fmt.Println("@@@ JSON STRING: ", s)
scalar.Value = &core.Scalar_Json{
Json: &core.Json{
Value: []byte(s),
Expand Down Expand Up @@ -585,6 +586,19 @@ func MakeLiteralForType(t *core.LiteralType, v interface{}) (*core.Literal, erro
strValue = string(byteValue)
}
}
if newT.Simple == core.SimpleType_JSON {
if _, isValueStringType := v.(string); !isValueStringType {
jsonBytes, err := json.Marshal(v)
if err != nil {
return nil, fmt.Errorf("unable to marshal to json string for json value %v", v)

Check warning on line 593 in flyteidl/clients/go/coreutils/literals.go

View check run for this annotation

Codecov / codecov/patch

flyteidl/clients/go/coreutils/literals.go#L591-L593

Added lines #L591 - L593 were not covered by tests
}
jsonBytes, err = msgpack.Marshal(jsonBytes)
if err != nil {
return nil, fmt.Errorf("unable to marshal to msgpack bytes for json value %v", v)

Check warning on line 597 in flyteidl/clients/go/coreutils/literals.go

View check run for this annotation

Codecov / codecov/patch

flyteidl/clients/go/coreutils/literals.go#L595-L597

Added lines #L595 - L597 were not covered by tests
}
strValue = string(jsonBytes)

Check warning on line 599 in flyteidl/clients/go/coreutils/literals.go

View check run for this annotation

Codecov / codecov/patch

flyteidl/clients/go/coreutils/literals.go#L599

Added line #L599 was not covered by tests
}
}
lv, err := MakeLiteralForSimpleType(newT.Simple, strValue)
if err != nil {
return nil, err
Expand Down
2 changes: 2 additions & 0 deletions flyteidl/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ require (
github.com/sirupsen/logrus v1.9.3 // indirect
github.com/spf13/cobra v1.7.0 // indirect
github.com/stretchr/objx v0.5.2 // indirect
github.com/vmihailenco/msgpack/v5 v5.4.1 // indirect
github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect
go.opencensus.io v0.24.0 // indirect
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.46.1 // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.46.1 // indirect
Expand Down
4 changes: 4 additions & 0 deletions flyteidl/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,10 @@ github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/vmihailenco/msgpack/v5 v5.4.1 h1:cQriyiUvjTwOHg8QZaPihLWeRAAVoCpE00IUPn0Bjt8=
github.com/vmihailenco/msgpack/v5 v5.4.1/go.mod h1:GaZTsDaehaPpQVyxrf5mtQlH+pc21PIudVV/E3rRQok=
github.com/vmihailenco/tagparser/v2 v2.0.0 h1:y09buUbR+b5aycVFQs/g70pqKVZNBmxwAhO7/IwNM9g=
github.com/vmihailenco/tagparser/v2 v2.0.0/go.mod h1:Wri+At7QHww0WTrCBeu4J6bNtoV6mEfg5OIWRZA9qds=
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
Expand Down

0 comments on commit c7c82ac

Please sign in to comment.