Skip to content

Commit

Permalink
Cleanup + Fixing
Browse files Browse the repository at this point in the history
  • Loading branch information
pyranota committed Dec 19, 2024
1 parent a0e452f commit 3666694
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 14 deletions.
5 changes: 2 additions & 3 deletions backend/windmill-worker/nsjail/run.python3.config.proto
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,9 @@ mount {
is_bind: true
}

#TODO: Make dynamic
mount {
src: "/tmp/windmill/cache/py_runtime"
dst: "/tmp/windmill/cache/py_runtime"
src: "{PY_INSTALL_DIR}"
dst: "{PY_INSTALL_DIR}"
is_bind: true
}

Expand Down
16 changes: 5 additions & 11 deletions backend/windmill-worker/src/python_executor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,13 +129,6 @@ impl PyVersion {
pub fn to_cache_dir_top_level(&self) -> String {
format!("python_{}", self.to_string_no_dot())
}
/// e.g.: `(to_cache_dir(), to_cache_dir_top_level())`
#[cfg(all(feature = "enterprise", feature = "parquet"))]
pub fn to_cache_dir_tuple(&self) -> (String, String) {
use windmill_common::worker::ROOT_CACHE_DIR;
let top_level = self.to_cache_dir_top_level();
(format!("{ROOT_CACHE_DIR}python_{}", &top_level), top_level)
}
/// e.g.: `3xy`
pub fn to_string_no_dot(&self) -> String {
self.to_string_with_dot().replace('.', "")
Expand All @@ -157,6 +150,7 @@ impl PyVersion {
"3.11" => Some(Py311),
"3.12" => Some(Py312),
"3.13" => Some(Py313),
"default" => Some(PyVersion::default()),
_ => {
tracing::warn!(
"Cannot convert string (\"{value}\") to PyVersion\nExpected format x.yz"
Expand All @@ -172,6 +166,7 @@ impl PyVersion {
"311" => Some(Py311),
"312" => Some(Py312),
"313" => Some(Py313),
"default" => Some(PyVersion::default()),
_ => {
tracing::warn!(
"Cannot convert string (\"{value}\") to PyVersion\nExpected format xyz"
Expand Down Expand Up @@ -244,7 +239,6 @@ impl PyVersion {
}
res
}
#[async_recursion::async_recursion]
async fn get_python_inner(
self,
job_id: &Uuid,
Expand All @@ -261,7 +255,7 @@ impl PyVersion {
if py_path.is_err() {
// Install it
if let Err(err) = self
.get_python_inner(job_id, mem_peak, db, worker_name, w_id, occupancy_metrics)
.install_python(job_id, mem_peak, db, worker_name, w_id, occupancy_metrics)
.await
{
tracing::error!("Cannot install python: {err}");
Expand Down Expand Up @@ -568,7 +562,7 @@ pub async fn uv_pip_compile(
} else {
// Make sure we have python runtime installed
py_version
.install_python(job_id, mem_peak, db, worker_name, w_id, occupancy_metrics)
.get_python(job_id, mem_peak, db, worker_name, w_id, occupancy_metrics)
.await?;

let mut args = vec![
Expand Down Expand Up @@ -1055,7 +1049,7 @@ mount {{
"run.config.proto",
&NSJAIL_CONFIG_RUN_PYTHON3_CONTENT
.replace("{JOB_DIR}", job_dir)
// .replace("{PY_RUNTIME_DIR}", &python_path)
.replace("{PY_INSTALL_DIR}", PY_INSTALL_DIR)
.replace("{CLONE_NEWUSER}", &(!*DISABLE_NUSER).to_string())
.replace("{SHARED_MOUNT}", shared_mount)
.replace("{SHARED_DEPENDENCIES}", shared_deps.as_str())
Expand Down
11 changes: 11 additions & 0 deletions backend/windmill-worker/src/worker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -798,6 +798,17 @@ pub async fn run_worker(
"Cannot preinstall or find Instance Python version to worker: {e}"//
);
}
if let Err(e) = PyVersion::Py311
.get_python(&Uuid::nil(), &mut 0, &db, &worker_name, "", &mut None)
.await
{
tracing::error!(
worker = %worker_name,
hostname = %hostname,
worker_dir = %worker_dir,
"Cannot preinstall or find default 311 version to worker: {e}"//
);
}
});
}

Expand Down

0 comments on commit 3666694

Please sign in to comment.