feat: add reset.{sh,bat} to rebuild conda env from scratch (fixes corrupt HF stack)
This commit is contained in:
@@ -0,0 +1,62 @@
|
||||
@echo off
|
||||
REM Photo Judgers — Reset Conda Environment (Windows)
|
||||
REM Deletes and recreates the conda env cleanly, then installs deps.
|
||||
REM Use this if setup keeps failing or the HF stack is corrupted.
|
||||
|
||||
set ENV_NAME=photo_judgers
|
||||
|
||||
echo ========================================
|
||||
echo Photo Judgers — Reset Environment
|
||||
echo ========================================
|
||||
echo.
|
||||
|
||||
REM Check conda
|
||||
where conda >nul 2>nul
|
||||
if %ERRORLEVEL% NEQ 0 (
|
||||
echo ERROR: conda not found.
|
||||
pause
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
echo Checking for environment: %ENV_NAME%
|
||||
echo.
|
||||
|
||||
REM Remove env if present
|
||||
conda env list > "%TEMP%\conda_envs.txt" 2>nul
|
||||
set ENV_EXISTS=
|
||||
findstr /R /C "^%ENV_NAME%$" "%TEMP%\conda_envs.txt" >nul 2>nul
|
||||
if %ERRORLEVEL% EQU 0 set ENV_EXISTS=1
|
||||
del "%TEMP%\conda_envs.txt" 2>nul
|
||||
|
||||
if defined ENV_EXISTS (
|
||||
echo Removing existing environment '%ENV_NAME%'...
|
||||
conda env remove -y -n %ENV_NAME% --all
|
||||
)
|
||||
|
||||
echo.
|
||||
echo Creating fresh environment '%ENV_NAME%' (Python 3.11)...
|
||||
conda create -y -n %ENV_NAME% python=3.11
|
||||
if %ERRORLEVEL% NEQ 0 (
|
||||
echo ERROR: Failed to create environment.
|
||||
pause
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
echo.
|
||||
echo Activating environment...
|
||||
call conda activate %ENV_NAME%
|
||||
|
||||
echo.
|
||||
echo Installing packages from requirements.txt...
|
||||
echo.
|
||||
pip install -r requirements.txt
|
||||
|
||||
echo.
|
||||
echo ========================================
|
||||
echo Reset complete!
|
||||
echo ========================================
|
||||
echo.
|
||||
echo To run the scorer:
|
||||
echo run.bat
|
||||
echo.
|
||||
pause
|
||||
@@ -0,0 +1,44 @@
|
||||
#!/bin/bash
|
||||
# Photo Judgers — Reset Conda Environment (Linux/Mac)
|
||||
# Deletes and recreates the conda env cleanly, then installs deps.
|
||||
# Use this if setup keeps failing or the HF stack is corrupted.
|
||||
|
||||
set -e
|
||||
|
||||
ENV_NAME="photo_judgers"
|
||||
|
||||
echo "========================================"
|
||||
echo " Photo Judgers — Reset Environment"
|
||||
echo "========================================"
|
||||
echo ""
|
||||
|
||||
if ! command -v conda &>/dev/null; then
|
||||
echo "ERROR: conda not found."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Remove existing env if present
|
||||
if conda env list | grep -E "^\s*${ENV_NAME}\s*$" > /dev/null 2>&1; then
|
||||
echo "Removing existing environment '${ENV_NAME}'..."
|
||||
conda remove -y -n "${ENV_NAME}" --all
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "Creating fresh environment '${ENV_NAME}' (Python 3.11)..."
|
||||
conda create -y -n "${ENV_NAME}" python=3.11
|
||||
|
||||
echo ""
|
||||
echo "Activating..."
|
||||
conda activate "${ENV_NAME}"
|
||||
|
||||
echo ""
|
||||
echo "Installing packages from requirements.txt..."
|
||||
pip install -r requirements.txt
|
||||
|
||||
echo ""
|
||||
echo "========================================"
|
||||
echo " Reset complete!"
|
||||
echo "========================================"
|
||||
echo "To run:"
|
||||
echo " ./run.sh"
|
||||
echo ""
|
||||
Reference in New Issue
Block a user