Fix telemetry ping regression for explicit statistics
Fixed Codex regression: keep snapshot_download pings for explicit statistics values; detection only runs when statistics is None. Also replaced bare except.
This commit is contained in:
parent
d0f3e4d32e
commit
7b7287c9b9
1 changed files with 33 additions and 33 deletions
|
|
@ -1170,40 +1170,40 @@ def _get_statistics(statistics = None, force_download = True):
|
|||
except:
|
||||
statistics = "other"
|
||||
|
||||
if statistics is not None:
|
||||
import tempfile
|
||||
from huggingface_hub import snapshot_download
|
||||
from unsloth_zoo.rl_environments import execute_with_time_limit
|
||||
if statistics is not None:
|
||||
import tempfile
|
||||
from huggingface_hub import snapshot_download
|
||||
from unsloth_zoo.rl_environments import execute_with_time_limit
|
||||
|
||||
if has_internet():
|
||||
if has_internet():
|
||||
|
||||
def stats_check():
|
||||
with tempfile.TemporaryDirectory(ignore_cleanup_errors = True) as f:
|
||||
snapshot_download(
|
||||
f"unslothai/{statistics}",
|
||||
force_download = True,
|
||||
cache_dir = f,
|
||||
local_dir = f,
|
||||
)
|
||||
|
||||
time_limited_stats_check = execute_with_time_limit(120)(stats_check)
|
||||
try:
|
||||
time_limited_stats_check()
|
||||
except TimeoutError:
|
||||
raise TimeoutError(
|
||||
"Unsloth: HuggingFace seems to be down after trying for 120 seconds :(\n"
|
||||
"Check https://status.huggingface.co/ for more details.\n"
|
||||
"As a temporary measure, use modelscope with the same model name ie:\n"
|
||||
"```\n"
|
||||
"pip install modelscope\n"
|
||||
"import os; os.environ['UNSLOTH_USE_MODELSCOPE'] = '1'\n"
|
||||
"from unsloth import FastLanguageModel\n"
|
||||
"model = FastLanguageModel.from_pretrained('unsloth/gpt-oss-20b')\n"
|
||||
"```"
|
||||
def stats_check():
|
||||
with tempfile.TemporaryDirectory(ignore_cleanup_errors = True) as f:
|
||||
snapshot_download(
|
||||
f"unslothai/{statistics}",
|
||||
force_download = True,
|
||||
cache_dir = f,
|
||||
local_dir = f,
|
||||
)
|
||||
except:
|
||||
# Try no time limit check
|
||||
stats_check()
|
||||
|
||||
time_limited_stats_check = execute_with_time_limit(120)(stats_check)
|
||||
try:
|
||||
time_limited_stats_check()
|
||||
except TimeoutError:
|
||||
raise TimeoutError(
|
||||
"Unsloth: HuggingFace seems to be down after trying for 120 seconds :(\n"
|
||||
"Check https://status.huggingface.co/ for more details.\n"
|
||||
"As a temporary measure, use modelscope with the same model name ie:\n"
|
||||
"```\n"
|
||||
"pip install modelscope\n"
|
||||
"import os; os.environ['UNSLOTH_USE_MODELSCOPE'] = '1'\n"
|
||||
"from unsloth import FastLanguageModel\n"
|
||||
"model = FastLanguageModel.from_pretrained('unsloth/gpt-oss-20b')\n"
|
||||
"```"
|
||||
)
|
||||
except Exception:
|
||||
# Try no time limit check
|
||||
stats_check()
|
||||
|
||||
|
||||
def get_statistics(local_files_only = False):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue