Merge pull request #1302 from aluzzardi/up-target

Support for partially running a DAG
This commit is contained in:
Andrea Luzzardi 2022-01-13 23:58:26 -08:00 committed by GitHub
commit 971346c6d5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 8 deletions

View File

@ -143,10 +143,10 @@ func europaUp(ctx context.Context, cl *client.Client, args ...string) error {
lg := log.Ctx(ctx) lg := log.Ctx(ctx)
p, err := plan.Load(ctx, plan.Config{ p, err := plan.Load(ctx, plan.Config{
Args: args, Args: args,
With: viper.GetStringSlice("with"), With: viper.GetStringSlice("with"),
Target: viper.GetString("target"),
}) })
if err != nil { if err != nil {
lg.Fatal().Err(err).Msg("failed to load plan") lg.Fatal().Err(err).Msg("failed to load plan")
} }
@ -225,6 +225,7 @@ func init() {
upCmd.Flags().BoolP("force", "f", false, "Force up, disable inputs check") upCmd.Flags().BoolP("force", "f", false, "Force up, disable inputs check")
upCmd.Flags().String("output", "", "Write computed output. Prints on stdout if set to-") upCmd.Flags().String("output", "", "Write computed output. Prints on stdout if set to-")
upCmd.Flags().StringArrayP("with", "w", []string{}, "") upCmd.Flags().StringArrayP("with", "w", []string{}, "")
upCmd.Flags().StringP("target", "t", "", "Run a single target of the DAG (for debugging only)")
if err := viper.BindPFlags(upCmd.Flags()); err != nil { if err := viper.BindPFlags(upCmd.Flags()); err != nil {
panic(err) panic(err)

View File

@ -26,8 +26,9 @@ type Plan struct {
} }
type Config struct { type Config struct {
Args []string Args []string
With []string With []string
Target string
} }
func Load(ctx context.Context, cfg Config) (*Plan, error) { func Load(ctx context.Context, cfg Config) (*Plan, error) {
@ -149,10 +150,17 @@ func (p *Plan) Up(ctx context.Context, s solver.Solver) (*compiler.Value, error)
computed := compiler.NewValue() computed := compiler.NewValue()
cfg := &cueflow.Config{
FindHiddenTasks: true,
}
if p.config.Target != "" {
cfg.Root = cue.ParsePath(p.config.Target)
// The target may reference dependencies outside of the target path.
// InferTasks will include them in the workflow.
cfg.InferTasks = true
}
flow := cueflow.New( flow := cueflow.New(
&cueflow.Config{ cfg,
FindHiddenTasks: true,
},
p.source.Cue(), p.source.Cue(),
newRunner(p.context, s, computed), newRunner(p.context, s, computed),
) )