* Studio: derive training output dir from model basename for local-drive models A LoRA/QLoRA run started from a model loaded by absolute path (common when models live on a non-system drive, e.g. G:\modelsAI\...\gemma-4-12B-it) seeded the default output dir with that full path. resolve_output_dir then raised "path escapes root ... is not under the studio outputs folder", so training could not start from a model stored off the system drive. Add default_run_dir_name(): Hugging Face repo ids keep their namespace (org/model becomes org_model), while local paths collapse to their final component so an absolute source path can no longer leak into the output dir. Use it at the three worker derivation sites and add a regression test. * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Studio: cap run dir name length and drop redundant resolve Apply PR review feedback: length-cap the auto-generated output dir component so an unusually long model name stays under the filesystem name limit, and drop the redundant double resolve_output_dir at the embedding site so all three derivation sites match. --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
101 lines
2.5 KiB
Python
101 lines
2.5 KiB
Python
# SPDX-License-Identifier: AGPL-3.0-only
|
|
# Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0
|
|
|
|
"""Path utilities for model and dataset handling."""
|
|
|
|
from .path_utils import (
|
|
normalize_path,
|
|
is_local_path,
|
|
is_model_cached,
|
|
get_cache_path,
|
|
resolve_cached_repo_id_case,
|
|
get_cache_case_resolution_stats,
|
|
reset_cache_case_resolution_state,
|
|
)
|
|
from .storage_roots import (
|
|
studio_root,
|
|
assets_root,
|
|
datasets_root,
|
|
dataset_uploads_root,
|
|
recipe_datasets_root,
|
|
outputs_root,
|
|
exports_root,
|
|
auth_root,
|
|
auth_db_path,
|
|
studio_db_path,
|
|
rag_root,
|
|
rag_db_path,
|
|
rag_uploads_root,
|
|
documents_root,
|
|
project_workspaces_root,
|
|
tmp_root,
|
|
seed_uploads_root,
|
|
unstructured_seed_cache_root,
|
|
unstructured_uploads_root,
|
|
oxc_validator_tmp_root,
|
|
tensorboard_root,
|
|
legacy_hf_cache_dir,
|
|
hf_default_cache_dir,
|
|
lmstudio_model_dirs,
|
|
well_known_model_dirs,
|
|
ensure_dir,
|
|
ensure_studio_directories,
|
|
resolve_under_root,
|
|
default_run_dir_name,
|
|
resolve_output_dir,
|
|
resolve_export_dir,
|
|
resolve_export_write_dir,
|
|
resolve_tensorboard_dir,
|
|
resolve_dataset_path,
|
|
)
|
|
|
|
# Re-export shim: mark project-path helpers as used so the import-hoist
|
|
# safety net does not flag them as unused.
|
|
_REEXPORTED = (documents_root, project_workspaces_root, resolve_export_write_dir)
|
|
|
|
__all__ = [
|
|
"normalize_path",
|
|
"is_local_path",
|
|
"is_model_cached",
|
|
"get_cache_path",
|
|
"resolve_cached_repo_id_case",
|
|
"get_cache_case_resolution_stats",
|
|
"reset_cache_case_resolution_state",
|
|
"studio_root",
|
|
"assets_root",
|
|
"datasets_root",
|
|
"dataset_uploads_root",
|
|
"recipe_datasets_root",
|
|
"outputs_root",
|
|
"exports_root",
|
|
"auth_root",
|
|
"auth_db_path",
|
|
"studio_db_path",
|
|
"rag_root",
|
|
"rag_db_path",
|
|
"rag_uploads_root",
|
|
"documents_root",
|
|
"project_workspaces_root",
|
|
"tmp_root",
|
|
"seed_uploads_root",
|
|
"unstructured_seed_cache_root",
|
|
"unstructured_uploads_root",
|
|
"oxc_validator_tmp_root",
|
|
"tensorboard_root",
|
|
"legacy_hf_cache_dir",
|
|
"hf_default_cache_dir",
|
|
"lmstudio_model_dirs",
|
|
"well_known_model_dirs",
|
|
"ensure_dir",
|
|
"ensure_studio_directories",
|
|
"resolve_under_root",
|
|
"default_run_dir_name",
|
|
"resolve_output_dir",
|
|
"resolve_export_dir",
|
|
"resolve_export_write_dir",
|
|
"resolve_tensorboard_dir",
|
|
"resolve_dataset_path",
|
|
]
|
|
|
|
# Bind the re-exports so the import-hoist verifier counts them as used.
|
|
_ = (rag_root, rag_db_path, rag_uploads_root)
|