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

fix: name temporary python script for run_python with suitable name #1616

Merged
merged 4 commits into from
Oct 25, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ const (
temporaryPythonDirectoryPrefix = "run-python-*"

successfulPipRunExitCode = 0

scriptArtifactFormat = "%v-python-script"
)

func NewRunPythonService(serviceNetwork service_network.ServiceNetwork, runtimeValueStore *runtime_value_store.RuntimeValueStore) *kurtosis_plan_instruction.KurtosisPlanInstruction {
Expand Down Expand Up @@ -149,6 +151,9 @@ type RunPythonCapabilities struct {
}

func (builtin *RunPythonCapabilities) Interpret(_ string, arguments *builtin_argument.ArgumentValuesSet) (starlark.Value, *startosis_errors.InterpretationError) {
randomUuid := uuid.NewRandom()
builtin.name = fmt.Sprintf("task-%v", randomUuid.String())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can put this "task-%v" in a constant


pythonScript, err := builtin_argument.ExtractArgumentValue[starlark.String](arguments, RunArgName)
if err != nil {
return nil, startosis_errors.WrapWithInterpretationError(err, "Unable to extract value for '%s' argument", RunArgName)
Expand All @@ -160,10 +165,7 @@ func (builtin *RunPythonCapabilities) Interpret(_ string, arguments *builtin_arg
return nil, scriptCompressionInterpretationErr
}
defer compressedScript.Close()
uniqueFilesArtifactName, err := builtin.serviceNetwork.GetUniqueNameForFileArtifact()
if err != nil {
return nil, startosis_errors.NewInterpretationError("an error occurred while generating unique artifact name for python script")
}
uniqueFilesArtifactName := fmt.Sprintf(scriptArtifactFormat, builtin.name)
_, err = builtin.serviceNetwork.UploadFilesArtifact(compressedScript, compressedScriptMd5, uniqueFilesArtifactName)
if err != nil {
return nil, startosis_errors.WrapWithInterpretationError(err, "An error occurred while storing the python script to disk")
Expand Down Expand Up @@ -258,8 +260,6 @@ func (builtin *RunPythonCapabilities) Interpret(_ string, arguments *builtin_arg
return nil, startosis_errors.NewInterpretationError("An error occurred while generating UUID for future reference for %v instruction", RunPythonBuiltinName)
}
builtin.resultUuid = resultUuid
randomUuid := uuid.NewRandom()
builtin.name = fmt.Sprintf("task-%v", randomUuid.String())

result := createInterpretationResult(resultUuid, builtin.storeSpecList)
return result, nil
Expand Down