From 88edb39c8f424d5f6b2126739948206ce5829e98 Mon Sep 17 00:00:00 2001 From: Gyanendra Mishra Date: Wed, 25 Oct 2023 19:56:13 +0100 Subject: [PATCH] fix: name temporary python script for run_python with suitable name (#1616) Earlier we would name it with a name like `tranquil-wind` etc and that would confuse the reader on what it might contain. The ideal solution here is to clean this up and not use a temporary files artifact at all and not use the service network inside interpret --------- Co-authored-by: leoporoli --- .../kurtosis_instruction/tasks/run_python.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/core/server/api_container/server/startosis_engine/kurtosis_instruction/tasks/run_python.go b/core/server/api_container/server/startosis_engine/kurtosis_instruction/tasks/run_python.go index 4c22a22859..e4df70e945 100644 --- a/core/server/api_container/server/startosis_engine/kurtosis_instruction/tasks/run_python.go +++ b/core/server/api_container/server/startosis_engine/kurtosis_instruction/tasks/run_python.go @@ -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 { @@ -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()) + 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) @@ -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") @@ -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