Skip to content

Commit

Permalink
feat: display task names in picasso (#2458)
Browse files Browse the repository at this point in the history
## Description
<!-- Describe this change, how it works, and the motivation behind it.
-->

## REMINDER: Tag Reviewers, so they get notified to review

## Is this change user facing?
YES/NO
<!-- If yes, please add the "user facing" label to the PR -->
<!-- If yes, don't forget to include docs changes where relevant -->

## References (if applicable)
<!-- Add relevant Github Issues, Discord threads, or other helpful
information. -->
<!-- You can auto-close issues by putting "Fixes #XXXX" here. -->
  • Loading branch information
tedim52 committed May 22, 2024
1 parent 7bad2a9 commit 424dc39
Show file tree
Hide file tree
Showing 8 changed files with 40 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ func (builtin *ExecCapabilities) FillPersistableAttributes(builder *enclave_plan
}

func (builtin *ExecCapabilities) UpdatePlan(planYaml *plan_yaml.PlanYaml) error {
err := planYaml.AddExec(string(builtin.serviceName), builtin.returnValue, builtin.cmdList, builtin.acceptableCodes)
err := planYaml.AddExec(string(builtin.serviceName), builtin.description, builtin.returnValue, builtin.cmdList, builtin.acceptableCodes)
if err != nil {
return stacktrace.Propagate(err, "An error occurred updating plan with exec.")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ func (builtin *RunPythonCapabilities) FillPersistableAttributes(builder *enclave
}

func (builtin *RunPythonCapabilities) UpdatePlan(plan *plan_yaml.PlanYaml) error {
err := plan.AddRunPython(builtin.run, builtin.returnValue, builtin.serviceConfig, builtin.storeSpecList, builtin.pythonArguments, builtin.packages)
err := plan.AddRunPython(builtin.run, builtin.description, builtin.returnValue, builtin.serviceConfig, builtin.storeSpecList, builtin.pythonArguments, builtin.packages)
if err != nil {
return stacktrace.Propagate(err, "An error occurred updating plan with run python")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ func (builtin *RunShCapabilities) FillPersistableAttributes(builder *enclave_pla
}

func (builtin *RunShCapabilities) UpdatePlan(plan *plan_yaml.PlanYaml) error {
err := plan.AddRunSh(builtin.run, builtin.returnValue, builtin.serviceConfig, builtin.storeSpecList)
err := plan.AddRunSh(builtin.run, builtin.description, builtin.returnValue, builtin.serviceConfig, builtin.storeSpecList)
if err != nil {
return stacktrace.Propagate(err, "An error occurred adding run sh task to the plan")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,16 +88,16 @@ type FileMount struct {

// Task represents a task to be executed.
type Task struct {
Uuid string `yaml:"uuid,omitempty"` // done
Name string `yaml:"name,omitempty"` // done
TaskType TaskType `yaml:"taskType,omitempty"` // done
RunCmd []string `yaml:"command,omitempty"` // done
Image string `yaml:"image,omitempty"` // done
Uuid string `yaml:"uuid,omitempty"`
Name string `yaml:"name,omitempty"`
TaskType TaskType `yaml:"taskType,omitempty"`
RunCmd []string `yaml:"command,omitempty"`
Image string `yaml:"image,omitempty"`
Files []*FileMount `yaml:"files,omitempty"`
Store []*FilesArtifact `yaml:"store,omitempty"`

// only exists on shell tasks
EnvVars []*EnvironmentVariable `yaml:"envVar,omitempty"` // done
EnvVars []*EnvironmentVariable `yaml:"envVar,omitempty"`

// only exists on python tasks
PythonPackages []string `yaml:"pythonPackages,omitempty"`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ func (planYaml *PlanYaml) AddService(

func (planYaml *PlanYaml) AddRunSh(
runCommand string,
description string,
returnValue *starlarkstruct.Struct,
serviceConfig *service.ServiceConfig,
storeSpecList []*store_spec2.StoreSpec,
Expand Down Expand Up @@ -161,6 +162,7 @@ func (planYaml *PlanYaml) AddRunSh(

// create task yaml object
taskYaml := &Task{} //nolint exhaustruct
taskYaml.Name = description
taskYaml.Uuid = uuid
taskYaml.TaskType = shell

Expand All @@ -179,7 +181,7 @@ func (planYaml *PlanYaml) AddRunSh(
taskYaml.Files = planYaml.getFileMountsFromFilesArtifacts(serviceConfig.GetFilesArtifactsExpansion())

// for store
// - all files artifacts product from store are new files artifact that are added to the plan
// - all files artifacts produced from store are new files artifact that are added to the plan
// - add them to files artifacts list
// - add them to the store section of run sh
var store []*FilesArtifact
Expand All @@ -205,6 +207,7 @@ func (planYaml *PlanYaml) AddRunSh(

func (planYaml *PlanYaml) AddRunPython(
runCommand string,
description string,
returnValue *starlarkstruct.Struct,
serviceConfig *service.ServiceConfig,
storeSpecList []*store_spec2.StoreSpec,
Expand Down Expand Up @@ -234,6 +237,7 @@ func (planYaml *PlanYaml) AddRunPython(

// create task yaml object
taskYaml := &Task{} //nolint exhaustruct
taskYaml.Name = description
taskYaml.Uuid = uuid
taskYaml.TaskType = python

Expand Down Expand Up @@ -282,6 +286,7 @@ func (planYaml *PlanYaml) AddRunPython(

func (planYaml *PlanYaml) AddExec(
serviceName string,
description string,
returnValue *starlark.Dict,
cmdList []string,
acceptableCodes []int64) error {
Expand Down Expand Up @@ -315,6 +320,7 @@ func (planYaml *PlanYaml) AddExec(

// create task yaml
taskYaml := &Task{} //nolint exhaustruct
taskYaml.Name = description
taskYaml.Uuid = uuid
taskYaml.TaskType = exec
taskYaml.ServiceName = serviceName
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,8 @@ func (suite *StartosisIntepreterPlanYamlTestSuite) TestRunShWithFilesArtifacts()
},
store=[
StoreSpec(src="/bye.txt", name="bye-file")
]
],
description = "Store bye",
)
`
inputArgs := `{"hi_files_artifact": "hi-file"}`
Expand Down Expand Up @@ -195,6 +196,7 @@ filesArtifacts:
- /bye.txt
tasks:
- uuid: "1"
name: Store bye
taskType: sh
command:
- echo bye > /bye.txt
Expand Down Expand Up @@ -235,6 +237,7 @@ func (suite *StartosisIntepreterPlanYamlTestSuite) TestRunPython() {
store = [
StoreSpec(src = "bye.txt", name = "bye-file"),
],
description = "Request docs"
)
`
inputArgs := `{"hi_files_artifact": "hi-file"}`
Expand Down Expand Up @@ -266,6 +269,7 @@ filesArtifacts:
- bye.txt
tasks:
- uuid: "1"
name: Request docs
taskType: python
command:
- "\n import requests\n response = requests.get(\"docs.kurtosis.com\")\n print(response.status_code)
Expand Down Expand Up @@ -301,12 +305,13 @@ func (suite *StartosisIntepreterPlanYamlTestSuite) TestExec() {
files = {
"/root": hi_files_artifact,
}
)
),
)
result = plan.exec(
service_name="db",
recipe=ExecRecipe(command=["echo", "Hello, world"]),
acceptable_codes=[0],
description = "Say Hello"
)
`
inputArgs := `{"hi_files_artifact": "hi-file"}`
Expand Down Expand Up @@ -349,6 +354,7 @@ filesArtifacts:
name: hi-file
tasks:
- uuid: "3"
name: Say Hello
taskType: exec
command:
- echo
Expand Down Expand Up @@ -381,6 +387,7 @@ func (suite *StartosisIntepreterPlanYamlTestSuite) TestRenderTemplate() {
files = {
"/root": bye_files_artifact,
},
description = "Say bye",
)
`
inputArgs := `{"hi_files_artifact": "hi-file"}`
Expand Down Expand Up @@ -411,6 +418,7 @@ filesArtifacts:
- fairwell.txt
tasks:
- uuid: "2"
name: Say bye
taskType: sh
command:
- cat /root/bye.txt
Expand Down Expand Up @@ -563,6 +571,7 @@ func (suite *StartosisIntepreterPlanYamlTestSuite) TestUploadFiles() {
files = {
"/root": dockerfile_artifact,
},
description = "Say dockerfile contents"
)
`
_, instructionsPlan, interpretationError := suite.interpreter.Interpret(
Expand Down Expand Up @@ -591,6 +600,7 @@ filesArtifacts:
- ./server/Dockerfile
tasks:
- uuid: "2"
name: Say dockerfile contents
taskType: sh
command:
- cat /root/Dockerfile
Expand Down Expand Up @@ -732,12 +742,15 @@ func (suite *StartosisIntepreterPlanYamlTestSuite) TestFutureReferencesAreSwappe
command=["echo", service.ip_address + " " + service.hostname]
),
acceptable_codes=[0],
description = "Get db ip"
)
runShResult = plan.run_sh(
run="echo " + execResult["code"] + " " + execResult["output"],
description = "Say db ip"
)
plan.run_sh(
run="echo " + runShResult.code + " " + runShResult.output,
description = "Say db ip again"
)
`
inputArgs := `{"hi_files_artifact": "hi-file"}`
Expand Down Expand Up @@ -780,6 +793,7 @@ filesArtifacts:
name: hi-file
tasks:
- uuid: "3"
name: Get db ip
taskType: exec
command:
- echo
Expand All @@ -788,11 +802,13 @@ tasks:
acceptableCodes:
- 0
- uuid: "4"
name: Say db ip
taskType: sh
command:
- echo {{ kurtosis.3.code }} {{ kurtosis.3.output }}
image: badouralix/curl-jq
- uuid: "5"
name: Say db ip again
taskType: sh
command:
- echo {{ kurtosis.4.code }} {{ kurtosis.4.output }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ export const KurtosisPackageNode = memo(
const serviceVariable = `{{service.${serviceNamesToId[task.serviceName]}.name}}`;
updateData(`${id}:${task.uuid}`, {
type: "exec",
name: "",
name: task.name,
isValid: true,
isFromPackage: true,
service: serviceVariable,
Expand All @@ -195,7 +195,7 @@ export const KurtosisPackageNode = memo(
if (task.taskType === "python") {
updateData(`${id}:${task.uuid}`, {
type: "python",
name: `Python ${task.uuid}`,
name: task.name,
isValid: true,
isFromPackage: true,
command: (task.command || []).join(" "),
Expand Down Expand Up @@ -231,7 +231,7 @@ export const KurtosisPackageNode = memo(
if (task.taskType === "sh") {
updateData(`${id}:${task.uuid}`, {
type: "shell",
name: `Shell ${task.uuid}`,
name: task.name,
isValid: true,
isFromPackage: true,
command: (task.command || []).join(" "),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ export type PlanService = {
type PlanExecTask = {
taskType: "exec";
uuid: string;
name: string;
command: string[];
serviceName: string;
acceptableCodes?: number[];
Expand All @@ -161,6 +162,7 @@ type PlanExecTask = {
type PlanPythonTask = {
taskType: "python";
uuid: string;
name: string;
command?: string[];
image: string;
files?: PlanFile[];
Expand All @@ -171,6 +173,7 @@ type PlanPythonTask = {
type PlanShTask = {
taskType: "sh";
uuid: string;
name: string;
command?: string[];
image: string;
files?: PlanFile[];
Expand Down

0 comments on commit 424dc39

Please sign in to comment.