Commit 3ac95a90 authored by Graham King's avatar Graham King Committed by GitHub
Browse files

fix(dynamo-run): Fix build if llamacpp and mistralrs are disabled (#262)

parent ba33b2bd
...@@ -225,4 +225,4 @@ fn print_cuda(output: &Output) { ...@@ -225,4 +225,4 @@ fn print_cuda(output: &Output) {
} }
#[cfg(not(any(feature = "mistralrs", feature = "llamacpp")))] #[cfg(not(any(feature = "mistralrs", feature = "llamacpp")))]
fn print_cuda(_output: Output) {} fn print_cuda(_output: &Output) {}
...@@ -59,7 +59,7 @@ use pyo3::prelude::*; ...@@ -59,7 +59,7 @@ use pyo3::prelude::*;
target_os = "macos", target_os = "macos",
any(feature = "sglang", feature = "vllm", feature = "python") any(feature = "sglang", feature = "vllm", feature = "python")
))] ))]
fn fix_venv(venv: String, py: pyo3::Python<'_>) -> anyhow::Result<()> { fn fix_venv(venv: String, py: Python<'_>) -> anyhow::Result<()> {
let version_info = py.version_info(); let version_info = py.version_info();
let sys: PyObject = py.import("sys")?.into(); let sys: PyObject = py.import("sys")?.into();
let sys_path = sys.getattr(py, "path")?; let sys_path = sys.getattr(py, "path")?;
...@@ -76,4 +76,6 @@ fn fix_venv(venv: String, py: pyo3::Python<'_>) -> anyhow::Result<()> { ...@@ -76,4 +76,6 @@ fn fix_venv(venv: String, py: pyo3::Python<'_>) -> anyhow::Result<()> {
target_os = "linux", target_os = "linux",
any(feature = "sglang", feature = "vllm", feature = "python") any(feature = "sglang", feature = "vllm", feature = "python")
))] ))]
fn fix_venv(_venv: String, _py: Python<'_>) {} fn fix_venv(_venv: String, _py: Python<'_>) -> anyhow::Result<()> {
Ok(())
}
...@@ -94,7 +94,7 @@ pub fn run_subprocess( ...@@ -94,7 +94,7 @@ pub fn run_subprocess(
) -> anyhow::Result<()> { ) -> anyhow::Result<()> {
pyo3::prepare_freethreaded_python(); // or enable feature "auto-initialize" pyo3::prepare_freethreaded_python(); // or enable feature "auto-initialize"
if let Ok(venv) = env::var("VIRTUAL_ENV") { if let Ok(venv) = env::var("VIRTUAL_ENV") {
Python::with_gil(|py| crate::engines::fix_venv(venv, py)); let _ = Python::with_gil(|py| crate::engines::fix_venv(venv, py));
} }
let dir = model_path.display().to_string(); let dir = model_path.display().to_string();
Python::with_gil(|py| { Python::with_gil(|py| {
......
...@@ -291,7 +291,7 @@ pub async fn start( ...@@ -291,7 +291,7 @@ pub async fn start(
) -> anyhow::Result<SgLangWorker> { ) -> anyhow::Result<SgLangWorker> {
pyo3::prepare_freethreaded_python(); pyo3::prepare_freethreaded_python();
if let Ok(venv) = env::var("VIRTUAL_ENV") { if let Ok(venv) = env::var("VIRTUAL_ENV") {
Python::with_gil(|py| crate::engines::fix_venv(venv, py)); let _ = Python::with_gil(|py| crate::engines::fix_venv(venv, py));
} }
let Sockets { let Sockets {
......
...@@ -58,7 +58,7 @@ pub fn run_subprocess( ...@@ -58,7 +58,7 @@ pub fn run_subprocess(
) -> anyhow::Result<()> { ) -> anyhow::Result<()> {
pyo3::prepare_freethreaded_python(); // or enable feature "auto-initialize" pyo3::prepare_freethreaded_python(); // or enable feature "auto-initialize"
if let Ok(venv) = env::var("VIRTUAL_ENV") { if let Ok(venv) = env::var("VIRTUAL_ENV") {
Python::with_gil(|py| crate::engines::fix_venv(venv, py)); let _ = Python::with_gil(|py| crate::engines::fix_venv(venv, py));
} }
let card = model_card_path.display().to_string(); let card = model_card_path.display().to_string();
let model_path_str = model_path.display().to_string(); let model_path_str = model_path.display().to_string();
......
...@@ -167,7 +167,7 @@ pub async fn start( ...@@ -167,7 +167,7 @@ pub async fn start(
) -> anyhow::Result<VllmWorker> { ) -> anyhow::Result<VllmWorker> {
pyo3::prepare_freethreaded_python(); // or enable feature "auto-initialize" pyo3::prepare_freethreaded_python(); // or enable feature "auto-initialize"
if let Ok(venv) = env::var("VIRTUAL_ENV") { if let Ok(venv) = env::var("VIRTUAL_ENV") {
Python::with_gil(|py| crate::engines::fix_venv(venv, py)); let _ = Python::with_gil(|py| crate::engines::fix_venv(venv, py));
} }
let py_imports = Arc::new(python_imports()); let py_imports = Arc::new(python_imports());
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment