Skip to content

Commit 28651cb

Browse files
committed
fix(transform): don't write to out streams when nil, use updated preview.Create
new preview create lets us make previews & still read body data downstream
1 parent 552f07b commit 28651cb

File tree

5 files changed

+11
-9
lines changed

5 files changed

+11
-9
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ require (
3939
github.com/olekukonko/tablewriter v0.0.4
4040
github.com/pkg/errors v0.9.1
4141
github.com/qri-io/dag v0.2.2-0.20201208212257-ae00241c4b48
42-
github.com/qri-io/dataset v0.2.1-0.20210126031523-f94fd2290107
42+
github.com/qri-io/dataset v0.2.1-0.20210128201320-3b1209495e96
4343
github.com/qri-io/deepdiff v0.2.1-0.20200807143746-d02d9f531f5b
4444
github.com/qri-io/didmod v0.0.0-20201123165422-8b2e224c993a
4545
github.com/qri-io/doggos v0.1.0

lib/datasets.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -626,12 +626,12 @@ func (m *DatasetMethods) Save(p *SaveParams, res *dataset.Dataset) error {
626626
// allocate an ID for the transform, for now just log the events it produces
627627
runID := transform.NewRunID()
628628
m.inst.bus.SubscribeID(func(ctx context.Context, e event.Event) error {
629-
when := time.Unix(e.Timestamp/1000000000, e.Timestamp%1000000000)
630-
log.Infof("[%s] event %s: %s", when, e.Type, e.Payload)
631629
if e.Type == event.ETTransformPrint {
632630
if msg, ok := e.Payload.(event.TransformMessage); ok {
633-
io.WriteString(scriptOut, msg.Msg)
634-
io.WriteString(scriptOut, "\n")
631+
if p.ScriptOutput != nil {
632+
io.WriteString(scriptOut, msg.Msg)
633+
io.WriteString(scriptOut, "\n")
634+
}
635635
}
636636
}
637637
return nil

lib/transform.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,10 @@ func (m *TransformMethods) Apply(p *ApplyParams, res *ApplyResult) error {
9191
log.Debugw("apply transform event", "type", e.Type, "payload", e.Payload)
9292
if e.Type == event.ETTransformPrint {
9393
if msg, ok := e.Payload.(event.TransformMessage); ok {
94-
io.WriteString(p.ScriptOutput, msg.Msg)
95-
io.WriteString(p.ScriptOutput, "\n")
94+
if p.ScriptOutput != nil {
95+
io.WriteString(p.ScriptOutput, msg.Msg)
96+
io.WriteString(p.ScriptOutput, "\n")
97+
}
9698
}
9799
}
98100
return nil

remote/browse.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ func (rp LocalPreviews) Preview(ctx context.Context, _, refStr string) (*dataset
115115
return nil, err
116116
}
117117

118-
return preview.CreatePreview(ctx, ds)
118+
return preview.Create(ctx, ds)
119119
}
120120

121121
// PreviewComponent gets a component for a reference & component name

transform/startf/exec_step.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ func (r *StepRunner) callTransformFunc(ctx context.Context, thread *starlark.Thr
170170
}
171171

172172
if r.eventsCh != nil {
173-
pview, err := preview.CreatePreview(ctx, ds)
173+
pview, err := preview.Create(ctx, ds)
174174
if err != nil {
175175
return err
176176
}

0 commit comments

Comments
 (0)