| #!/bin/bash |
|
|
| |
| set -e |
|
|
| echo "Setting up webshop..." |
| echo "NOTE: please run scripts/setup_ragen_old.sh before running this script" |
|
|
| |
| GREEN='\033[0;32m' |
| BLUE='\033[0;34m' |
| NC='\033[0m' |
|
|
| |
| print_step() { |
| echo -e "${BLUE}[Step] ${1}${NC}" |
| } |
|
|
| build_constraints_file() { |
| local constraints_file |
| constraints_file=$(mktemp -t ragen_webshop_constraints.XXXXXX) |
| python - "$constraints_file" <<'PY' |
| from importlib import metadata |
| from pathlib import Path |
| import sys |
|
|
| protected = [ |
| "torch", |
| "transformers", |
| "vllm", |
| "flash-attn", |
| "tokenizers", |
| ] |
|
|
| lines = [] |
| for package in protected: |
| try: |
| version = metadata.version(package) |
| except metadata.PackageNotFoundError: |
| continue |
| lines.append(f"{package}=={version}") |
|
|
| Path(sys.argv[1]).write_text("\n".join(lines) + ("\n" if lines else "")) |
| PY |
| echo "$constraints_file" |
| } |
|
|
| ensure_conda_env() { |
| if ! command -v conda &> /dev/null; then |
| echo "Conda is not installed. Please install Conda first." |
| exit 1 |
| fi |
| if [ -z "${CONDA_DEFAULT_ENV:-}" ] || [ "${CONDA_DEFAULT_ENV}" != "ragen" ]; then |
| CONDA_PATH=$(conda info --base) |
| source "$CONDA_PATH/etc/profile.d/conda.sh" |
| conda activate ragen |
| fi |
| } |
|
|
| ensure_conda_env |
|
|
| |
| |
| print_step "Ensuring packaging toolchain is available..." |
| pip install -U pip "setuptools<70.0.0" wheel |
|
|
| CONSTRAINTS_FILE=$(build_constraints_file) |
| cleanup() { |
| rm -f "${CONSTRAINTS_FILE}" |
| } |
| trap cleanup EXIT |
|
|
| |
| print_step "Installing WebShop system dependencies..." |
| sudo apt update |
| sudo apt install default-jdk -y |
| conda install -c conda-forge openjdk=21 maven -y |
|
|
| |
| |
| |
| print_step "Installing WebShop Python dependencies..." |
| pip install -c "${CONSTRAINTS_FILE}" beautifulsoup4 cleantext flask html2text rank_bm25 pyserini thefuzz gdown spacy rich |
|
|
| |
| print_step "Installing WebShop package..." |
| pip install -e external/webshop-minimal/ --no-dependencies |
| print_step "Downloading spaCy models..." |
| python -m spacy download en_core_web_sm |
| python -m spacy download en_core_web_lg |
|
|
| print_step "Downloading data..." |
| python scripts/download_data.py |
|
|
| |
| |
| print_step "Downloading full data set (best effort)..." |
| conda install -c conda-forge gdown -y |
| FULL_DATA_DIR="external/webshop-minimal/webshop_minimal/data/full" |
| mkdir -p "${FULL_DATA_DIR}" |
| pushd "${FULL_DATA_DIR}" >/dev/null |
| if ! gdown https://drive.google.com/uc?id=1A2whVgOO0euk5O13n2iYDM0bQRkkRduB; then |
| echo "Warning: failed to download WebShop full dataset file 'items_shuffle'. Continuing without it." |
| fi |
| if ! gdown https://drive.google.com/uc?id=1s2j6NgHljiZzQNL3veZaAiyW_qDEgBNi; then |
| echo "Warning: failed to download WebShop full dataset file 'items_ins_v2'. Continuing without it." |
| fi |
| popd >/dev/null |
|
|
| echo -e "${GREEN}Installation completed successfully!${NC}" |
| echo "To activate the environment, run: conda activate ragen" |
|
|