From 027788707e9826371bd14cd0942dbe76a7475308 Mon Sep 17 00:00:00 2001 From: Kareem Horstink Date: Sun, 23 Aug 2026 16:15:56 +0000 Subject: [PATCH] fix: idempotent setup (skip env if exists), trim requirements.txt --- requirements.txt | 11 ++++++----- setup.bat | 44 +++++++++++++++++++++++++++++++------------- setup.sh | 28 +++++++++++++++++----------- 3 files changed, 54 insertions(+), 29 deletions(-) diff --git a/requirements.txt b/requirements.txt index 8888c31..e6a30c5 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,12 +1,13 @@ # Photo Judgers — Requirements # Install in conda env: pip install -r requirements.txt +# +# simple-aesthetics-predictor automatically installs torch + transformers. +# We avoid pinning torchvision/torchaudio here to prevent version mismatch +# with the torch that simple-aesthetics-predictor resolves. Pillow is needed +# for image loading; tqdm for progress bars. -# Core dependencies simple-aesthetics-predictor transformers -torch -torchvision -torchaudio Pillow tqdm -numpy +numpy \ No newline at end of file diff --git a/setup.bat b/setup.bat index 3d6bfb1..5b3622c 100644 --- a/setup.bat +++ b/setup.bat @@ -1,6 +1,9 @@ @echo off REM Photo Judgers — Conda Environment Setup (Windows) REM Run this from the project root: photo_judgers\setup.bat +REM Idempotent: safe to re-run. Creates env if missing, installs deps. + +set ENV_NAME=photo_judgers echo ======================================== echo Photo Judgers — Setup @@ -16,30 +19,45 @@ if %ERRORLEVEL% NEQ 0 ( exit /b 1 ) -echo Creating conda environment: photo_judgers -echo Python version: 3.11 +echo Checking for environment: %ENV_NAME% echo. -REM Create the conda environment -conda create -y -n photo_judgers python=3.11 +REM Check if the environment already exists +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 %ERRORLEVEL% NEQ 0 ( - echo ERROR: Failed to create conda environment. - pause - exit /b 1 +if defined ENV_EXISTS ( + echo Environment '%ENV_NAME%' already exists. Skipping creation. +) else ( + echo Creating conda environment: %ENV_NAME% + echo Python version: 3.11 + echo. + conda create -y -n %ENV_NAME% python=3.11 + if %ERRORLEVEL% NEQ 0 ( + echo ERROR: Failed to create conda environment. + pause + exit /b 1 + ) ) echo. echo Activating environment... -call conda activate photo_judgers +call conda activate %ENV_NAME% echo. -echo Installing packages... +echo Installing packages from requirements.txt... echo. - -REM Install from requirements.txt pip install -r requirements.txt +if %ERRORLEVEL% NEQ 0 ( + echo. + echo WARNING: Package installation reported an error. + echo Check the messages above. +) + echo. echo ======================================== echo Setup complete! @@ -51,4 +69,4 @@ echo. echo To run the scorer: echo run.bat echo. -pause +pause \ No newline at end of file diff --git a/setup.sh b/setup.sh index 734dcfe..87f35b3 100644 --- a/setup.sh +++ b/setup.sh @@ -1,9 +1,12 @@ #!/bin/bash # Photo Judgers — Conda Environment Setup (Linux/Mac) # Run this from the project root: ./setup.sh +# Idempotent: safe to re-run. Creates env if missing, installs deps. set -e +ENV_NAME="photo_judgers" + echo "========================================" echo " Photo Judgers — Setup" echo "========================================" @@ -16,23 +19,26 @@ if ! command -v conda &>/dev/null; then exit 1 fi -echo "Creating conda environment: photo_judgers" -echo "Python version: 3.11" +echo "Checking for environment: ${ENV_NAME}" echo "" -# Create the conda environment -conda create -y -n photo_judgers python=3.11 +# Check if the environment already exists +if conda env list | grep -E "^\s*${ENV_NAME}\s*$" > /dev/null 2>&1; then + echo "Environment '${ENV_NAME}' already exists. Skipping creation." +else + echo "Creating environment '${ENV_NAME}'" + echo "Python version: 3.11" + echo "" + conda create -y -n "${ENV_NAME}" python=3.11 +fi echo "" echo "Activating environment..." -source $(conda info --base)/etc/profile.d/conda.sh -conda activate photo_judgers +conda activate "${ENV_NAME}" echo "" -echo "Installing packages..." +echo "Installing packages from requirements.txt..." echo "" - -# Install from requirements.txt pip install -r requirements.txt echo "" @@ -41,8 +47,8 @@ echo " Setup complete!" echo "========================================" echo "" echo "To activate the environment:" -echo " conda activate photo_judgers" +echo " conda activate ${ENV_NAME}" echo "" echo "To run the scorer:" echo " ./run.sh" -echo "" +echo "" \ No newline at end of file