studio: declare UNSLOTH_IS_PRESENT at backend startup (#6262)
The studio backend lazily imports unsloth_zoo submodules (export's llama_cpp, hardware's vllm_utils, mlx, chat_templates). Each imports the top-level unsloth_zoo, which raises 'Please install Unsloth via pip install unsloth' unless UNSLOTH_IS_PRESENT is set (normally by import unsloth). Only hardware.py set it per-site; the rest crash on a clean install, and it surfaced on Windows. Set it once at backend startup (as unsloth does on import) so every site, and the DiffusionGemma runner, works across platforms. Follow-up to #6259 (which covered only the shim subprocess env).
This commit is contained in:
parent
cc32777f30
commit
b91116cacc
2 changed files with 10 additions and 0 deletions
|
|
@ -193,6 +193,11 @@ if _STUDIO_ROOT_RESOLVED != _LEGACY_STUDIO_ROOT:
|
|||
if not os.environ.get("UNSLOTH_LLAMA_CPP_PATH"):
|
||||
os.environ["UNSLOTH_LLAMA_CPP_PATH"] = str(_STUDIO_ROOT_RESOLVED / "llama.cpp")
|
||||
|
||||
# The studio bundles unsloth_zoo; declare unsloth present (as `import unsloth`
|
||||
# does) so its lazy submodule imports (export, hardware, mlx) and the
|
||||
# DiffusionGemma runner never trip the install guard on a clean install.
|
||||
os.environ.setdefault("UNSLOTH_IS_PRESENT", "1")
|
||||
|
||||
import hashlib
|
||||
import mimetypes
|
||||
import re as _re
|
||||
|
|
|
|||
|
|
@ -545,6 +545,11 @@ if _STUDIO_ROOT_RESOLVED != _LEGACY_STUDIO_ROOT:
|
|||
if not os.environ.get("UNSLOTH_LLAMA_CPP_PATH"):
|
||||
os.environ["UNSLOTH_LLAMA_CPP_PATH"] = str(_STUDIO_ROOT_RESOLVED / "llama.cpp")
|
||||
|
||||
# The studio bundles unsloth_zoo; declare unsloth present (as `import unsloth`
|
||||
# does) so its lazy submodule imports (export, hardware, mlx) and the
|
||||
# DiffusionGemma runner never trip the install guard on a clean install.
|
||||
os.environ.setdefault("UNSLOTH_IS_PRESENT", "1")
|
||||
|
||||
|
||||
def _write_pid_file():
|
||||
"""Write the current process PID to the studio PID file."""
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue