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

tool/flow tasks deps lost when struct value pass in task field #2516

Closed
morlay opened this issue Aug 2, 2023 · 3 comments
Closed

tool/flow tasks deps lost when struct value pass in task field #2516

morlay opened this issue Aug 2, 2023 · 3 comments
Labels
NeedsInvestigation Triage Requires triage/attention

Comments

@morlay
Copy link

morlay commented Aug 2, 2023

What version of CUE are you using (cue version)?

$ cue version
v0.5.0

Does this issue reproduce with the latest stable release?

Yes

What did you do?

# test_tool.cue
package test

import (
	"tool/cli"
	"tool/exec"
)

input: "x"

command: build: {
	_prepare: exec.Run & {
		cmd:    "echo \(input)"
		stdout: string
	}

	_env: {
		INPUT: _prepare.stdout
	}

	_run: exec.Run & {
		cmd: [
			"sh",
			"-c",
			"echo ${INPUT}",
		]
		env: _env
		stdout: string
	}

	output: _run.stdout
}

command: print: cli.Print & {
	text: command.build.output
}

What did you expect to see?

comand.build._prepare should execute before comand.build._run

What did you see instead?

comand.build._prepare not executed
then comand.build._run throw the error non-concrete value string

@morlay morlay added NeedsInvestigation Triage Requires triage/attention labels Aug 2, 2023
@morlay morlay changed the title [v0.6.0-rc.1] tool/flow tasks deps is different from v0.5.0. tool/flow tasks deps lost when struct value pass in task field Aug 2, 2023
@morlay
Copy link
Author

morlay commented Aug 2, 2023

With v0.6.0-rc.1, We could iter the _env to fix this issue. like:

package test

import (
	"tool/cli"
	"tool/exec"
)

input: "x"

command: build: {
	_prepare: exec.Run & {
		cmd:    "echo \(input)"
		stdout: string
	}

	_env: {
		INPUT: _prepare.stdout
	}

	_run: exec.Run & {
		cmd: [
			"sh",
			"-c",
			"echo ${INPUT}",
		]
                 // re iter the _env
		env: {
			for k, v in _env {
				"\(k)": v
			}
		}
		stdout: string
	}

	output: _run.stdout
}

command: print: cli.Print & {
	text: command.build.output
}

But still throw error in v0.5.0

@morlay
Copy link
Author

morlay commented Aug 2, 2023

issue2516.txtar

Could pass with &dep.Config{ Dynamic: true, Descend: true }

-- in.cue --
package p

import (
	"tool/cli"
	"tool/exec"
)

root: version: exec.Run & {
	cmd:    "echo foo"
	stdout: string
}

root: build: {
	env: {
	    VERSION: root.version.stdout
	}

	run: exec.Run & {
		cmd:    [
            "sh",
            "-c",
            "echo ${VERSION}",
        ]
		"env":  env
		stdout: string
	}
}

root: print: cli.Print & {
	text: root.build.run.stdout
}
-- out/run/errors --
-- out/run/t0 --
graph TD
  t0("root.version [Ready]")
  t1("root.build.run [Waiting]")
  t1-->t0
  t2("root.print [Waiting]")
  t2-->t1

-- out/run/t1 --
graph TD
  t0("root.version [Terminated]")
  t1("root.build.run [Ready]")
  t1-->t0
  t2("root.print [Waiting]")
  t2-->t1

-- out/run/t1/value --
{
	$id: "tool/exec.Run"
	cmd: "echo foo"
	env: {}
	stdout:  "foo"
	stderr:  null
	stdin:   null
	success: bool
}
-- out/run/t1/stats --
Leaks:  0
Freed:  73
Reused: 64
Allocs: 9
Retain: 0

Unifications: 34
Conjuncts:    104
Disjuncts:    73
-- out/run/t2 --
graph TD
  t0("root.version [Terminated]")
  t1("root.build.run [Terminated]")
  t1-->t0
  t2("root.print [Ready]")
  t2-->t1

-- out/run/t2/value --
{
	$id: "tool/exec.Run"
	cmd: ["sh", "-c", "echo ${VERSION}"]
	env: {
		VERSION: "foo"
	}
	stdout:  "foo"
	stderr:  null
	stdin:   null
	success: bool
}
-- out/run/t2/stats --
Leaks:  0
Freed:  73
Reused: 73
Allocs: 0
Retain: 0

Unifications: 34
Conjuncts:    110
Disjuncts:    73
-- out/run/t3 --
graph TD
  t0("root.version [Terminated]")
  t1("root.build.run [Terminated]")
  t1-->t0
  t2("root.print [Terminated]")
  t2-->t1

-- out/run/t3/value --
{
	$id:    "tool/cli.Print"
	stdout: "foo"
	text:   "foo"
}
-- out/run/t3/stats --
Leaks:  0
Freed:  74
Reused: 74
Allocs: 0
Retain: 0

Unifications: 35
Conjuncts:    114
Disjuncts:    74
-- out/run/stats/totals --
Leaks:  0
Freed:  220
Reused: 211
Allocs: 9
Retain: 0

Unifications: 103
Conjuncts:    328
Disjuncts:    220

@myitcv
Copy link
Member

myitcv commented Aug 7, 2023

Closing because this is very likely connected to #2517 (comment).

@myitcv myitcv closed this as completed Aug 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
NeedsInvestigation Triage Requires triage/attention
Projects
None yet
Development

No branches or pull requests

2 participants