File size: 1,988 Bytes
2cf4a54
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#!/bin/bash
# For licensing see accompanying LICENSE file.
# Copyright (C) 2025 Apple Inc. All Rights Reserved.

# Setup script for Starflow using conda/miniconda

set -e  # Exit on any error

echo "Setting up Starflow development environment with conda..."

# Check if conda is available
if ! command -v conda &> /dev/null; then
    echo "Error: conda not found. Please install miniconda or anaconda first."
    echo "Download from: https://docs.conda.io/en/latest/miniconda.html"
    exit 1
fi

# Define environment name
ENV_NAME="starflow"

# Create conda environment if it doesn't exist
if ! conda env list | grep -q "^$ENV_NAME "; then
    echo "Creating conda environment '$ENV_NAME' with Python 3.10..."
    conda create -n $ENV_NAME python=3.10 -y
fi

# Activate environment
echo "Activating conda environment '$ENV_NAME'..."
eval "$(conda shell.bash hook)"
conda activate $ENV_NAME

# Install PyTorch and related packages via conda (often faster and more reliable)
echo "Installing PyTorch and related packages via conda..."
conda install pytorch torchvision pytorch-cuda -c pytorch -c nvidia -y

# Install other critical dependencies
echo "Installing other critical dependencies..."
pip install numpy pyyaml

# Install remaining dependencies from requirements.txt
echo "Installing remaining dependencies from requirements.txt..."
pip install -r requirements.txt

# Setup Hugging Face authentication (optional)
if [ "$HF_TOKEN" ]; then
    echo "Setting up Hugging Face authentication..."
    huggingface-cli login --token $HF_TOKEN --add-to-git-credential
fi

# Setup git configuration (optional)
if [ "$1" == "setup_git" ]; then
    read -p "Enter your git username: " git_username
    read -p "Enter your git email: " git_email
    git config --global user.name "$git_username"
    git config --global user.email "$git_email"
fi

echo ""
echo "Setup complete! 🎉"
echo ""
echo "To activate the conda environment in future sessions:"
echo "  conda activate $ENV_NAME"
echo ""