Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Print text logs in import-dir and export-dir commands #1682

Merged
merged 6 commits into from
Aug 15, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
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
5 changes: 2 additions & 3 deletions cmd/workspace/workspace/export_dir.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,7 @@ func newExportDir() *cobra.Command {
}
workspaceFS := filer.NewFS(ctx, workspaceFiler)

// TODO: print progress events on stderr instead: https://github.com/databricks/cli/issues/448
err = cmdio.RenderJson(ctx, newExportStartedEvent(opts.sourceDir))
err = cmdio.RenderWithTemplate(ctx, newExportStartedEvent(opts.sourceDir), "", "Exporting files from {{.SourcePath}}\n")
if err != nil {
return err
}
Expand All @@ -120,7 +119,7 @@ func newExportDir() *cobra.Command {
if err != nil {
return err
}
return cmdio.RenderJson(ctx, newExportCompletedEvent(opts.targetDir))
return cmdio.RenderWithTemplate(ctx, newExportCompletedEvent(opts.targetDir), "", "Exported complete. The files are available at {{.TargetPath}}\n")
}

return cmd
Expand Down
5 changes: 2 additions & 3 deletions cmd/workspace/workspace/import_dir.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,7 @@ Notebooks will have their extensions (one of .scala, .py, .sql, .ipynb, .r) stri
return err
}

// TODO: print progress events on stderr instead: https://github.com/databricks/cli/issues/448
err = cmdio.RenderJson(ctx, newImportStartedEvent(opts.sourceDir))
err = cmdio.RenderWithTemplate(ctx, newImportStartedEvent(opts.sourceDir), "", "Importing files from {{.SourcePath}}\n")
if err != nil {
return err
}
Expand All @@ -145,7 +144,7 @@ Notebooks will have their extensions (one of .scala, .py, .sql, .ipynb, .r) stri
if err != nil {
return err
}
return cmdio.RenderJson(ctx, newImportCompletedEvent(opts.targetDir))
return cmdio.RenderWithTemplate(ctx, newImportCompletedEvent(opts.targetDir), "", "Import complete. The files are available at {{.TargetPath}}\n")
}

return cmd
Expand Down
8 changes: 0 additions & 8 deletions libs/cmdio/render.go
Original file line number Diff line number Diff line change
Expand Up @@ -280,14 +280,6 @@ func RenderIteratorWithTemplate[T any](ctx context.Context, i listing.Iterator[T
return renderWithTemplate(newIteratorRenderer(i), ctx, c.outputFormat, c.out, headerTemplate, template)
}

func RenderJson(ctx context.Context, v any) error {
c := fromContext(ctx)
if _, ok := v.(listingInterface); ok {
panic("use RenderIteratorJson instead")
}
return renderWithTemplate(newRenderer(v), ctx, flags.OutputJSON, c.out, c.headerTemplate, c.template)
}

func RenderIteratorJson[T any](ctx context.Context, i listing.Iterator[T]) error {
c := fromContext(ctx)
return renderWithTemplate(newIteratorRenderer(i), ctx, c.outputFormat, c.out, c.headerTemplate, c.template)
Expand Down
Loading