fix: persist studio home path across server restarts
This commit is contained in:
parent
9e8b87a0fe
commit
40c5b86005
4 changed files with 19 additions and 1 deletions
|
|
@ -14,10 +14,15 @@ studio_app = typer.Typer(help = "Unsloth Studio commands.")
|
|||
|
||||
|
||||
def _studio_home() -> Path:
|
||||
"""Studio root, overridable via UNSLOTH_STUDIO_HOME."""
|
||||
"""Studio root: env var > config file > default."""
|
||||
custom = os.environ.get("UNSLOTH_STUDIO_HOME")
|
||||
if custom:
|
||||
return Path(custom).expanduser().resolve()
|
||||
conf = Path.home() / ".unsloth" / "studio_home"
|
||||
if conf.is_file():
|
||||
saved = conf.read_text().strip()
|
||||
if saved:
|
||||
return Path(saved).expanduser().resolve()
|
||||
return Path.home() / ".unsloth" / "studio"
|
||||
|
||||
# __file__ is cli/commands/studio.py — two parents up is the package root
|
||||
|
|
|
|||
|
|
@ -9,9 +9,15 @@ import tempfile
|
|||
|
||||
|
||||
def studio_root() -> Path:
|
||||
"""Studio root: env var > config file > default."""
|
||||
custom = os.environ.get("UNSLOTH_STUDIO_HOME")
|
||||
if custom:
|
||||
return Path(custom).expanduser().resolve()
|
||||
conf = Path.home() / ".unsloth" / "studio_home"
|
||||
if conf.is_file():
|
||||
saved = conf.read_text().strip()
|
||||
if saved:
|
||||
return Path(saved).expanduser().resolve()
|
||||
return Path.home() / ".unsloth" / "studio"
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -828,6 +828,10 @@ Write-Host "[OK] Using $PythonCmd ($(& $PythonCmd --version 2>&1))" -ForegroundC
|
|||
|
||||
# ── Studio home (configurable via UNSLOTH_STUDIO_HOME) ──
|
||||
$StudioHome = if ($env:UNSLOTH_STUDIO_HOME) { $env:UNSLOTH_STUDIO_HOME } else { Join-Path $env:USERPROFILE ".unsloth\studio" }
|
||||
# Persist for future `unsloth studio` runs (survives shell restarts)
|
||||
$UnslothDir = Join-Path $env:USERPROFILE ".unsloth"
|
||||
if (-not (Test-Path $UnslothDir)) { New-Item -ItemType Directory -Path $UnslothDir -Force | Out-Null }
|
||||
Set-Content -Path (Join-Path $UnslothDir "studio_home") -Value $StudioHome -NoNewline
|
||||
|
||||
$VenvDir = Join-Path $StudioHome ".venv"
|
||||
if (-not (Test-Path $VenvDir)) {
|
||||
|
|
|
|||
|
|
@ -231,6 +231,9 @@ else
|
|||
# Configurable via UNSLOTH_STUDIO_HOME; defaults to ~/.unsloth/studio
|
||||
STUDIO_HOME="${UNSLOTH_STUDIO_HOME:-$HOME/.unsloth/studio}"
|
||||
echo " Studio home: $STUDIO_HOME"
|
||||
# Persist for future `unsloth studio` runs (survives shell restarts)
|
||||
mkdir -p "$HOME/.unsloth"
|
||||
echo "$STUDIO_HOME" > "$HOME/.unsloth/studio_home"
|
||||
VENV_DIR="$STUDIO_HOME/.venv"
|
||||
VENV_T5_DIR="$STUDIO_HOME/.venv_t5"
|
||||
mkdir -p "$STUDIO_HOME"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue