diff --git a/backend/windmill-worker/src/python_executor.rs b/backend/windmill-worker/src/python_executor.rs index b8e1be3d38..3e97d9a007 100644 --- a/backend/windmill-worker/src/python_executor.rs +++ b/backend/windmill-worker/src/python_executor.rs @@ -472,7 +472,13 @@ async fn prepare_wrapper( let relative_imports = RELATIVE_IMPORT_REGEX.is_match(&inner_content); - let script_path_splitted = script_path.split("/"); + let script_path_splitted = script_path.split("/").map(|x| { + if x.starts_with(|x: char| x.is_ascii_digit()) { + format!("_{}", x) + } else { + x.to_string() + } + }); let dirs_full = script_path_splitted .clone() .take(script_path_splitted.clone().count() - 1) @@ -497,12 +503,6 @@ async fn prepare_wrapper( let module_dir = format!("{}/{}", job_dir, dirs); tokio::fs::create_dir_all(format!("{module_dir}/")).await?; - let last = if last.starts_with(|x: char| x.is_ascii_digit()) { - format!("_{}", last) - } else { - last - }; - let _ = write_file(&module_dir, &format!("{last}.py"), inner_content).await?; if relative_imports { let _ = write_file(job_dir, "loader.py", RELATIVE_PYTHON_LOADER).await?;