Skip to content
This repository was archived by the owner on Oct 9, 2023. It is now read-only.

Add GetOutputMetadata to the output reader #289

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Add tests
Signed-off-by: Kevin Su <[email protected]>
pingsutw committed Oct 12, 2022

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
commit 4fa606734c764955304a481a45bd795bf99ae0c3
2 changes: 1 addition & 1 deletion go/tasks/pluginmachinery/io/iface.go
Original file line number Diff line number Diff line change
@@ -43,7 +43,7 @@ type OutputReader interface {
Read(ctx context.Context) (*core.LiteralMap, *ExecutionError, error)
// DeckExists checks if the deck file has been generated.
DeckExists(ctx context.Context) (bool, error)
// GetOutputMetadata get the metadata from task's output, like deck uri
// GetOutputMetadata get the metadata from the output of tasks, such as deck URI.
GetOutputMetadata(ctx context.Context) map[string]string
}

3 changes: 3 additions & 0 deletions go/tasks/pluginmachinery/ioutils/in_memory_output_reader.go
Original file line number Diff line number Diff line change
@@ -48,6 +48,9 @@ func (r InMemoryOutputReader) DeckExists(_ context.Context) (bool, error) {
}

func (r InMemoryOutputReader) GetOutputMetadata(_ context.Context) map[string]string {
if r.DeckPath == nil {
return map[string]string{}
}
return map[string]string{deckURIKey: r.DeckPath.String()}
}

Original file line number Diff line number Diff line change
@@ -25,6 +25,7 @@ func TestInMemoryOutputReader(t *testing.T) {
or := NewInMemoryOutputReader(&flyteIdlCore.LiteralMap{Literals: lt}, &deckPath, nil)

assert.Equal(t, &deckPath, or.DeckPath)
assert.Equal(t, deckPath.String(), or.GetOutputMetadata(context.Background())[deckURIKey])
ctx := context.TODO()

ok, err := or.IsError(ctx)
Original file line number Diff line number Diff line change
@@ -68,6 +68,7 @@ func TestReadOrigin(t *testing.T) {
exists, err := r.DeckExists(ctx)
assert.NoError(t, err)
assert.True(t, exists)
assert.Equal(t, "deck.html", r.GetOutputMetadata(ctx)[deckURIKey])
})

t.Run("system", func(t *testing.T) {