fix: persist studio home path across server restarts
This commit is contained in:
parent
4e69c0e415
commit
6e2f64b3b6
3 changed files with 16 additions and 1 deletions
|
|
@ -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"
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -968,6 +968,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)) {
|
||||
|
|
|
|||
|
|
@ -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 unsloth_cli/commands/studio.py -- two parents up is the package root
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue