This repository has been archived by the owner on Oct 9, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add GetDeckPath to OutputReader (#268)
* Add GetDeckPath to RemoteFileOutputReader Signed-off-by: Kevin Su <pingsutw@apache.org> * make generate Signed-off-by: Kevin Su <pingsutw@apache.org> * Fix tests Signed-off-by: Kevin Su <pingsutw@apache.org> * Fix tests Signed-off-by: Kevin Su <pingsutw@apache.org> * Fix tests Signed-off-by: Kevin Su <pingsutw@apache.org> * more tests Signed-off-by: Kevin Su <pingsutw@apache.org> * nit Signed-off-by: Kevin Su <pingsutw@apache.org>
- Loading branch information
Showing
22 changed files
with
237 additions
and
12 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
32 changes: 32 additions & 0 deletions
32
flyteplugins/go/tasks/pluginmachinery/io/mocks/output_file_paths.go
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
36 changes: 36 additions & 0 deletions
36
flyteplugins/go/tasks/pluginmachinery/io/mocks/output_reader.go
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
32 changes: 32 additions & 0 deletions
32
flyteplugins/go/tasks/pluginmachinery/io/mocks/output_writer.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
44 changes: 44 additions & 0 deletions
44
flyteplugins/go/tasks/pluginmachinery/ioutils/in_memory_output_reader_test.go
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,44 @@ | ||
package ioutils | ||
|
||
import ( | ||
"context" | ||
"testing" | ||
|
||
flyteIdlCore "github.com/flyteorg/flyteidl/gen/pb-go/flyteidl/core" | ||
"github.com/flyteorg/flytestdlib/storage" | ||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestInMemoryOutputReader(t *testing.T) { | ||
deckPath := storage.DataReference("s3://bucket/key") | ||
lt := map[string]*flyteIdlCore.Literal{ | ||
"results": { | ||
Value: &flyteIdlCore.Literal_Scalar{ | ||
Scalar: &flyteIdlCore.Scalar{ | ||
Value: &flyteIdlCore.Scalar_Primitive{ | ||
Primitive: &flyteIdlCore.Primitive{Value: &flyteIdlCore.Primitive_Integer{Integer: 3}}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
} | ||
or := NewInMemoryOutputReader(&flyteIdlCore.LiteralMap{Literals: lt}, &deckPath, nil) | ||
|
||
assert.Equal(t, &deckPath, or.GetDeckPath()) | ||
ctx := context.TODO() | ||
|
||
ok, err := or.IsError(ctx) | ||
assert.False(t, ok) | ||
assert.NoError(t, err) | ||
|
||
assert.False(t, or.IsFile(ctx)) | ||
|
||
ok, err = or.Exists(ctx) | ||
assert.True(t, ok) | ||
assert.NoError(t, err) | ||
|
||
literalMap, executionErr, err := or.Read(ctx) | ||
assert.Equal(t, lt, literalMap.Literals) | ||
assert.Nil(t, executionErr) | ||
assert.NoError(t, err) | ||
} |
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
48 changes: 48 additions & 0 deletions
48
flyteplugins/go/tasks/pluginmachinery/ioutils/remote_file_output_writer_test.go
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,48 @@ | ||
package ioutils | ||
|
||
import ( | ||
"context" | ||
"testing" | ||
|
||
"github.com/flyteorg/flytestdlib/promutils" | ||
"github.com/flyteorg/flytestdlib/storage" | ||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestRemoteFileOutputWriter(t *testing.T) { | ||
ctx := context.TODO() | ||
memStore, err := storage.NewDataStore(&storage.Config{Type: storage.TypeMemory}, promutils.NewTestScope()) | ||
assert.Nil(t, err) | ||
|
||
outputPrefix := storage.DataReference("output") | ||
rawOutputPrefix := storage.DataReference("sandbox") | ||
previousCheckpointPath := storage.DataReference("checkpoint") | ||
|
||
checkpointPath := NewCheckpointRemoteFilePaths( | ||
ctx, | ||
memStore, | ||
outputPrefix, | ||
NewRawOutputPaths(ctx, rawOutputPrefix), | ||
previousCheckpointPath, | ||
) | ||
|
||
t.Run("Test NewCheckpointRemoteFilePaths", func(t *testing.T) { | ||
assert.Equal(t, previousCheckpointPath, checkpointPath.GetPreviousCheckpointsPrefix()) | ||
assert.Equal(t, outputPrefix, checkpointPath.GetOutputPrefixPath()) | ||
|
||
assert.Equal(t, constructPath(memStore, rawOutputPrefix, CheckpointPrefix), checkpointPath.GetCheckpointPrefix()) | ||
assert.Equal(t, constructPath(memStore, outputPrefix, OutputsSuffix), checkpointPath.GetOutputPath()) | ||
assert.Equal(t, constructPath(memStore, outputPrefix, deckSuffix), checkpointPath.GetDeckPath()) | ||
assert.Equal(t, constructPath(memStore, outputPrefix, ErrorsSuffix), checkpointPath.GetErrorPath()) | ||
assert.Equal(t, constructPath(memStore, outputPrefix, FuturesSuffix), checkpointPath.GetFuturesPath()) | ||
}) | ||
|
||
t.Run("Test NewRemoteFileOutputWriter", func(t *testing.T) { | ||
p := NewRemoteFileOutputWriter(ctx, memStore, checkpointPath) | ||
|
||
assert.Equal(t, constructPath(memStore, rawOutputPrefix, CheckpointPrefix), p.GetCheckpointPrefix()) | ||
assert.Equal(t, constructPath(memStore, outputPrefix, OutputsSuffix), p.GetOutputPath()) | ||
assert.Equal(t, constructPath(memStore, outputPrefix, deckSuffix), p.GetDeckPath()) | ||
assert.Equal(t, constructPath(memStore, outputPrefix, ErrorsSuffix), p.GetErrorPath()) | ||
}) | ||
} |
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
Oops, something went wrong.