forked from flyteorg/flyte
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Small bugfix: always return execution data for no storage scheme (fly…
…teorg#209) Signed-off-by: Katrina Rogan <katroganGH@gmail.com>
- Loading branch information
Katrina Rogan
committed
Jun 22, 2021
1 parent
cc40a39
commit 6a1d9bc
Showing
5 changed files
with
95 additions
and
10 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package util | ||
|
||
import ( | ||
"github.com/flyteorg/flyteadmin/pkg/common" | ||
"github.com/flyteorg/flyteadmin/pkg/runtime/interfaces" | ||
"github.com/flyteorg/flyteidl/gen/pb-go/flyteidl/admin" | ||
) | ||
|
||
func ShouldFetchData(config *interfaces.RemoteDataConfig, urlBlob admin.UrlBlob) bool { | ||
return config.Scheme == common.Local || config.Scheme == common.None || urlBlob.Bytes < config.MaxSizeInBytes | ||
} | ||
|
||
func ShouldFetchOutputData(config *interfaces.RemoteDataConfig, urlBlob admin.UrlBlob, outputURI string) bool { | ||
return ShouldFetchData(config, urlBlob) && len(outputURI) > 0 | ||
} |
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,72 @@ | ||
package util | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/flyteorg/flyteadmin/pkg/common" | ||
"github.com/flyteorg/flyteadmin/pkg/runtime/interfaces" | ||
"github.com/flyteorg/flyteidl/gen/pb-go/flyteidl/admin" | ||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestShouldFetchData(t *testing.T) { | ||
t.Run("local config", func(t *testing.T) { | ||
assert.True(t, ShouldFetchData(&interfaces.RemoteDataConfig{ | ||
Scheme: common.Local, | ||
MaxSizeInBytes: 100, | ||
}, admin.UrlBlob{ | ||
Bytes: 200, | ||
})) | ||
}) | ||
t.Run("no config", func(t *testing.T) { | ||
assert.True(t, ShouldFetchData(&interfaces.RemoteDataConfig{ | ||
Scheme: common.None, | ||
MaxSizeInBytes: 100, | ||
}, admin.UrlBlob{ | ||
Bytes: 200, | ||
})) | ||
}) | ||
t.Run("max size under limit", func(t *testing.T) { | ||
assert.True(t, ShouldFetchData(&interfaces.RemoteDataConfig{ | ||
Scheme: common.AWS, | ||
MaxSizeInBytes: 1000, | ||
}, admin.UrlBlob{ | ||
Bytes: 200, | ||
})) | ||
}) | ||
t.Run("max size over limit", func(t *testing.T) { | ||
assert.False(t, ShouldFetchData(&interfaces.RemoteDataConfig{ | ||
Scheme: common.AWS, | ||
MaxSizeInBytes: 100, | ||
}, admin.UrlBlob{ | ||
Bytes: 200, | ||
})) | ||
}) | ||
} | ||
|
||
func TestShouldFetchOutputData(t *testing.T) { | ||
t.Run("local config", func(t *testing.T) { | ||
assert.True(t, ShouldFetchOutputData(&interfaces.RemoteDataConfig{ | ||
Scheme: common.Local, | ||
MaxSizeInBytes: 100, | ||
}, admin.UrlBlob{ | ||
Bytes: 200, | ||
}, "s3://foo/bar.txt")) | ||
}) | ||
t.Run("max size under limit", func(t *testing.T) { | ||
assert.True(t, ShouldFetchOutputData(&interfaces.RemoteDataConfig{ | ||
Scheme: common.AWS, | ||
MaxSizeInBytes: 1000, | ||
}, admin.UrlBlob{ | ||
Bytes: 200, | ||
}, "s3://foo/bar.txt")) | ||
}) | ||
t.Run("output uri empty", func(t *testing.T) { | ||
assert.False(t, ShouldFetchOutputData(&interfaces.RemoteDataConfig{ | ||
Scheme: common.AWS, | ||
MaxSizeInBytes: 1000, | ||
}, admin.UrlBlob{ | ||
Bytes: 200, | ||
}, "")) | ||
}) | ||
} |