-
Notifications
You must be signed in to change notification settings - Fork 665
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update error handling in start.go, make the sandbox publisher create …
…a function call, add a ton of debug printing that will be removed later today, update enumer for cloud version, add code to render literal, handle message on the consumer side, add task event handling, workflow to be added later, update the event handler interface to be less verbose, run processing in goroutine, update selects Signed-off-by: Yee Hing Tong <[email protected]>
- Loading branch information
1 parent
e6227ec
commit e3df3c4
Showing
16 changed files
with
419 additions
and
59 deletions.
There are no files selected for viewing
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
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
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
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
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
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
39 changes: 37 additions & 2 deletions
39
flyteadmin/pkg/runtime/interfaces/cloudeventversion_enumer.go
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
package lib | ||
|
||
// ArtifactKey - This is used to tag Literals as a tracking bit. | ||
const ArtifactKey = "_ua" |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
package lib | ||
|
||
import ( | ||
"fmt" | ||
"github.com/flyteorg/flyte/flyteidl/gen/pb-go/flyteidl/core" | ||
"strings" | ||
"time" | ||
) | ||
|
||
func RenderLiteral(lit *core.Literal) (string, error) { | ||
if lit == nil { | ||
return "", fmt.Errorf("can't RenderLiteral, input is nil") | ||
} | ||
|
||
switch lit.Value.(type) { | ||
case *core.Literal_Scalar: | ||
scalar := lit.GetScalar() | ||
if scalar.GetPrimitive() == nil { | ||
return "", fmt.Errorf("rendering only works for primitives, got [%v]", scalar) | ||
} | ||
// todo: figure out how to expose more formatting | ||
// todo: maybe add a metric to each one of these, or this whole block. | ||
switch scalar.GetPrimitive().GetValue().(type) { | ||
case *core.Primitive_StringValue: | ||
return scalar.GetPrimitive().GetStringValue(), nil | ||
case *core.Primitive_Integer: | ||
return fmt.Sprintf("%d", scalar.GetPrimitive().GetInteger()), nil | ||
case *core.Primitive_FloatValue: | ||
return fmt.Sprintf("%v", scalar.GetPrimitive().GetFloatValue()), nil | ||
case *core.Primitive_Boolean: | ||
if scalar.GetPrimitive().GetBoolean() { | ||
return "true", nil | ||
} | ||
return "false", nil | ||
case *core.Primitive_Datetime: | ||
// just date for now, not sure if we should support time... | ||
dt := scalar.GetPrimitive().GetDatetime().AsTime() | ||
txt := dt.Format("2006-01-02") | ||
return txt, nil | ||
case *core.Primitive_Duration: | ||
dur := scalar.GetPrimitive().GetDuration().AsDuration() | ||
// Found somewhere as iso8601 representation of duration, but there's still lots of | ||
// possibilities for formatting. | ||
txt := "PT" + strings.ToUpper(dur.Truncate(time.Millisecond).String()) | ||
return txt, nil | ||
default: | ||
return "", fmt.Errorf("unknown primitive type [%v]", scalar.GetPrimitive()) | ||
} | ||
case *core.Literal_Collection: | ||
return "", fmt.Errorf("can't RenderLiteral for collections") | ||
case *core.Literal_Map: | ||
return "", fmt.Errorf("can't RenderLiteral for maps") | ||
} | ||
|
||
return "", fmt.Errorf("unknown literal type [%v]", lit) | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package lib | ||
|
||
import ( | ||
"github.com/flyteorg/flyte/flyteidl/gen/pb-go/flyteidl/core" | ||
"github.com/golang/protobuf/ptypes/timestamp" | ||
"github.com/stretchr/testify/assert" | ||
"testing" | ||
"time" | ||
) | ||
|
||
func TestRenderDate(t *testing.T) { | ||
dt := time.Date(2020, 12, 8, 0, 0, 0, 0, time.UTC) | ||
pt := timestamp.Timestamp{ | ||
Seconds: dt.Unix(), | ||
Nanos: 0, | ||
} | ||
lit := core.Literal{ | ||
Value: &core.Literal_Scalar{Scalar: &core.Scalar{Value: &core.Scalar_Primitive{Primitive: &core.Primitive{Value: &core.Primitive_Datetime{Datetime: &pt}}}}}, | ||
} | ||
|
||
txt, err := RenderLiteral(&lit) | ||
assert.NoError(t, err) | ||
assert.Equal(t, "2020-12-08", txt) | ||
} |
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
Oops, something went wrong.