Skip to content

Commit

Permalink
fix dedicated worker multipython
Browse files Browse the repository at this point in the history
  • Loading branch information
pyranota committed Feb 20, 2025
1 parent 5740679 commit 30fd680
Showing 1 changed file with 27 additions and 1 deletion.
28 changes: 27 additions & 1 deletion backend/windmill-worker/src/python_executor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2418,7 +2418,33 @@ for line in sys.stdin:
);
proc_envs.insert("BASE_URL".to_string(), base_internal_url.to_string());

let py_version = PyVersion::from_instance_version().await;
let py_version = if let Some(requirements) = requirements_o {
let requirements_lines: Vec<&str> = if requirements.len() > 0 {
requirements
.split("\n")
.filter(|x| !x.starts_with("--") && !x.trim().is_empty())
.collect()
} else {
vec![]
};
// If script is deployed we can try to parse first line to get assigned version
if let Some(v) = requirements_lines
.get(0)
.and_then(|line| PyVersion::parse_version(line))
{
// We have valid assigned version, we use it
v
} else {
// If there is no assigned version in lockfile we automatically fallback to 3.11
// In this case we have dependencies, but no associated python version
// This is the case for old deployed scripts
PyVersion::Py311
}
} else {
tracing::warn!(workspace_id = %w_id, "lockfile is empty for dedicated worker, thus python version cannot be infered. Fallback to 3.11");
PyVersion::Py311
};

let python_path = get_python_path(
py_version,
worker_name,
Expand Down

0 comments on commit 30fd680

Please sign in to comment.