Skip to content
This repository has been archived by the owner on May 31, 2024. It is now read-only.

Commit

Permalink
wip: docs added
Browse files Browse the repository at this point in the history
Signed-off-by: Yuvraj <code@evalsocket.dev>
  • Loading branch information
yindia committed Jun 25, 2021
1 parent a9ccca7 commit 20ac9af
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 41 deletions.
2 changes: 1 addition & 1 deletion cmd/register/examples_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ func TestRegisterExamplesFunc(t *testing.T) {
mockAdminClient.OnCreateLaunchPlanMatch(mock.Anything, mock.Anything).Return(nil, nil)
Client = mockStorage
err := registerExamplesFunc(ctx, args, cmdCtx)
assert.Nil(t, err)
assert.NotNil(t, err)
}
func TestRegisterExamplesFuncErr(t *testing.T) {
setup()
Expand Down
11 changes: 7 additions & 4 deletions cmd/register/files.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,12 @@ If there are already registered entities with v1 version then the command will f
bin/flytectl register file _pb_output/* -d development -p flytesnacks
Fast Registers will register all the fast serialized protobuf files including tasks, workflows and launchplans with default v1 version.
If there are already registered entities with v1 version then the command will fail immediately on the first such encounter.
Fast Register will register all the fast serialized protobuf files including tasks, workflows and launchplans with default v1 version. Learn more about registration https://docs.flyte.org/projects/cookbook/en/stable/auto/deployment/workflow/fast_registration.html
Fast Register required --additionalDistributionDir and --destinationDir flags
::
bin/flytectl register file _pb_output/* -d development -p flytesnacks -v v2 -l "s3://dummy/prefix" --destinationDir="" --additionalDistributionDir="s3://dummy/fast"
Using archive file.Currently supported are .tgz and .tar extension files and can be local or remote file served through http/https.
Use --archive flag.
Expand Down Expand Up @@ -99,7 +100,7 @@ func Register(ctx context.Context, args []string, cmdCtx cmdCore.CommandContext)
dataRefs, tmpDir, err := getSerializeOutputFiles(ctx, args)
if err != nil {
logger.Errorf(ctx, "error while un-archiving files in tmp dir due to %v", err)
return _err
return err
}
logger.Infof(ctx, "Parsing file... Total(%v)", len(dataRefs))

Expand All @@ -110,8 +111,10 @@ func Register(ctx context.Context, args []string, cmdCtx cmdCore.CommandContext)
if _err = uploadFastRegisterArtifact(ctx, dataRefs[i], rconfig.DefaultFilesConfig.AdditionalDistributionDir, rconfig.DefaultFilesConfig.Version); _err != nil {
registerResults = append(registerResults, Result{Name: dataRefs[i], Status: "Failed", Info: "Failed while uploading the source code"})
}
} else {
} else if strings.HasSuffix(dataRefs[i], ".pb") {
registerResults, _err = registerFile(ctx, dataRefs[i], registerResults, cmdCtx)
} else {
registerResults = append(registerResults, Result{Name: dataRefs[i], Status: "Failed", Info: "Invalid files"})
}
}

Expand Down
39 changes: 3 additions & 36 deletions cmd/register/files_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ func TestRegisterFromFiles(t *testing.T) {
mockAdminClient.OnCreateLaunchPlanMatch(mock.Anything, mock.Anything).Return(nil, nil)
Client = mockStorage
err := Register(ctx, args, cmdCtx)
assert.Nil(t, err)
assert.NotNil(t, err)
})
t.Run("Failed fast registration while flags are missing", func(t *testing.T) {
setup()
Expand All @@ -77,7 +77,7 @@ func TestRegisterFromFiles(t *testing.T) {
mockAdminClient.OnCreateLaunchPlanMatch(mock.Anything, mock.Anything).Return(nil, nil)
Client = mockStorage
err := registerFromFilesFunc(ctx, args, cmdCtx)
assert.Nil(t, err)
assert.NotNil(t, err)
})
t.Run("Valid registration of fast serialize", func(t *testing.T) {
setup()
Expand All @@ -96,23 +96,7 @@ func TestRegisterFromFiles(t *testing.T) {
err := registerFromFilesFunc(ctx, args, cmdCtx)
assert.Nil(t, err)
})
t.Run("Registration with compress file without Archive flag ", func(t *testing.T) {
setup()
registerFilesSetup()
rconfig.DefaultFilesConfig.Archive = false
rconfig.DefaultFilesConfig.DestinationDir = "/"
rconfig.DefaultFilesConfig.OutputLocationPrefix = s3Output
rconfig.DefaultFilesConfig.AdditionalDistributionDir = s3Output
mockStorage := &storageMocks.ComposedProtobufStore{}
args = []string{"testdata/flytesnacks-core.tgz"}
mockStorage.OnWriteRawMatch(ctx, mock.Anything, mock.Anything, mock.Anything, mock.Anything).Return(nil)
mockAdminClient.OnCreateTaskMatch(mock.Anything, mock.Anything).Return(nil, nil)
mockAdminClient.OnCreateWorkflowMatch(mock.Anything, mock.Anything).Return(nil, nil)
mockAdminClient.OnCreateLaunchPlanMatch(mock.Anything, mock.Anything).Return(nil, nil)
Client = mockStorage
err := registerFromFilesFunc(ctx, args, cmdCtx)
assert.NotNil(t, err)
})

t.Run("Registration with proto files ", func(t *testing.T) {
setup()
registerFilesSetup()
Expand All @@ -130,22 +114,5 @@ func TestRegisterFromFiles(t *testing.T) {
err := registerFromFilesFunc(ctx, args, cmdCtx)
assert.Nil(t, err)
})
t.Run("Registration In valid tar without Archive flag", func(t *testing.T) {
setup()
registerFilesSetup()
rconfig.DefaultFilesConfig.Archive = false
rconfig.DefaultFilesConfig.DestinationDir = "/"
rconfig.DefaultFilesConfig.OutputLocationPrefix = s3Output
rconfig.DefaultFilesConfig.AdditionalDistributionDir = s3Output
mockStorage := &storageMocks.ComposedProtobufStore{}
args = []string{"testdata/invalid.tar"}
mockStorage.OnWriteRawMatch(ctx, mock.Anything, mock.Anything, mock.Anything, mock.Anything).Return(nil)
mockAdminClient.OnCreateTaskMatch(mock.Anything, mock.Anything).Return(nil, nil)
mockAdminClient.OnCreateWorkflowMatch(mock.Anything, mock.Anything).Return(nil, nil)
mockAdminClient.OnCreateLaunchPlanMatch(mock.Anything, mock.Anything).Return(nil, nil)
Client = mockStorage
err := registerFromFilesFunc(ctx, args, cmdCtx)
assert.NotNil(t, err)
})

}

0 comments on commit 20ac9af

Please sign in to comment.