- Configure workspace Git repository with comprehensive .gitignore - Add Odoo as submodule for ERP reference code - Include documentation: SETUP.md, GIT-STRUCTURE.md - Add gitignore templates for projects (backend, frontend, database) - Structure supports independent repos per project/subproject level Workspace includes: - core/ - Reusable patterns, modules, orchestration system - projects/ - Active projects (erp-suite, gamilit, trading-platform, etc.) - knowledge-base/ - Reference code and patterns (includes Odoo submodule) - devtools/ - Development tools and templates - customers/ - Client implementations template 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
192 lines
5.5 KiB
Bash
Executable File
192 lines
5.5 KiB
Bash
Executable File
#!/bin/bash
|
|
#
|
|
# Setup Python environments for OrbiQuant IA Trading Platform
|
|
# Creates conda environments for all Python services
|
|
#
|
|
# Usage: ./scripts/setup-python-envs.sh [service_name]
|
|
# service_name: data-service, ml-engine, llm-agent, or 'all' (default)
|
|
#
|
|
|
|
set -e # Exit on error
|
|
|
|
# Colors for output
|
|
RED='\033[0;31m'
|
|
GREEN='\033[0;32m'
|
|
YELLOW='\033[1;33m'
|
|
BLUE='\033[0;34m'
|
|
NC='\033[0m' # No Color
|
|
|
|
# Configuration
|
|
CONDA_PATH="${HOME}/miniconda3/bin/conda"
|
|
PROJECT_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
|
APPS_DIR="${PROJECT_ROOT}/apps"
|
|
|
|
# Service definitions
|
|
SERVICES=("data-service" "ml-engine" "llm-agent")
|
|
|
|
# Functions
|
|
print_info() {
|
|
echo -e "${BLUE}[INFO]${NC} $1"
|
|
}
|
|
|
|
print_success() {
|
|
echo -e "${GREEN}[SUCCESS]${NC} $1"
|
|
}
|
|
|
|
print_warning() {
|
|
echo -e "${YELLOW}[WARNING]${NC} $1"
|
|
}
|
|
|
|
print_error() {
|
|
echo -e "${RED}[ERROR]${NC} $1"
|
|
}
|
|
|
|
check_conda() {
|
|
print_info "Checking conda installation..."
|
|
if [ ! -f "${CONDA_PATH}" ]; then
|
|
print_error "Conda not found at ${CONDA_PATH}"
|
|
print_error "Please install Miniconda first: https://docs.conda.io/en/latest/miniconda.html"
|
|
exit 1
|
|
fi
|
|
print_success "Conda found at ${CONDA_PATH}"
|
|
${CONDA_PATH} --version
|
|
}
|
|
|
|
setup_service() {
|
|
local service=$1
|
|
local service_dir="${APPS_DIR}/${service}"
|
|
local env_file="${service_dir}/environment.yml"
|
|
|
|
print_info "================================================"
|
|
print_info "Setting up environment for: ${service}"
|
|
print_info "================================================"
|
|
|
|
# Check if environment.yml exists
|
|
if [ ! -f "${env_file}" ]; then
|
|
print_error "Environment file not found: ${env_file}"
|
|
return 1
|
|
fi
|
|
|
|
# Get environment name from environment.yml
|
|
local env_name=$(grep "^name:" "${env_file}" | awk '{print $2}')
|
|
|
|
print_info "Environment name: ${env_name}"
|
|
|
|
# Check if environment already exists
|
|
if ${CONDA_PATH} env list | grep -q "^${env_name} "; then
|
|
print_warning "Environment '${env_name}' already exists"
|
|
read -p "Do you want to remove and recreate it? (y/N): " -n 1 -r
|
|
echo
|
|
if [[ $REPLY =~ ^[Yy]$ ]]; then
|
|
print_info "Removing existing environment..."
|
|
${CONDA_PATH} env remove -n "${env_name}" -y
|
|
else
|
|
print_info "Skipping ${service}"
|
|
return 0
|
|
fi
|
|
fi
|
|
|
|
# Create conda environment
|
|
print_info "Creating conda environment from ${env_file}..."
|
|
${CONDA_PATH} env create -f "${env_file}"
|
|
|
|
print_success "Environment '${env_name}' created successfully!"
|
|
|
|
# Print activation instructions
|
|
print_info ""
|
|
print_info "To activate this environment, run:"
|
|
print_info " conda activate ${env_name}"
|
|
print_info ""
|
|
}
|
|
|
|
verify_environment() {
|
|
local service=$1
|
|
local service_dir="${APPS_DIR}/${service}"
|
|
local env_file="${service_dir}/environment.yml"
|
|
|
|
if [ ! -f "${env_file}" ]; then
|
|
print_warning "Skipping verification for ${service}: environment.yml not found"
|
|
return 1
|
|
fi
|
|
|
|
local env_name=$(grep "^name:" "${env_file}" | awk '{print $2}')
|
|
|
|
if ${CONDA_PATH} env list | grep -q "^${env_name} "; then
|
|
print_success "${service}: Environment '${env_name}' exists"
|
|
return 0
|
|
else
|
|
print_error "${service}: Environment '${env_name}' not found"
|
|
return 1
|
|
fi
|
|
}
|
|
|
|
show_usage() {
|
|
echo "Usage: $0 [service_name]"
|
|
echo ""
|
|
echo "Arguments:"
|
|
echo " service_name Name of the service to setup (data-service, ml-engine, llm-agent)"
|
|
echo " Use 'all' to setup all services (default)"
|
|
echo ""
|
|
echo "Examples:"
|
|
echo " $0 # Setup all services"
|
|
echo " $0 all # Setup all services"
|
|
echo " $0 ml-engine # Setup only ml-engine"
|
|
echo ""
|
|
}
|
|
|
|
# Main execution
|
|
main() {
|
|
local target_service="${1:-all}"
|
|
|
|
print_info "OrbiQuant IA - Python Environment Setup"
|
|
print_info "Project root: ${PROJECT_ROOT}"
|
|
print_info ""
|
|
|
|
# Check conda installation
|
|
check_conda
|
|
echo ""
|
|
|
|
# Setup services
|
|
if [ "${target_service}" = "all" ]; then
|
|
print_info "Setting up all Python services..."
|
|
echo ""
|
|
|
|
for service in "${SERVICES[@]}"; do
|
|
setup_service "${service}"
|
|
echo ""
|
|
done
|
|
|
|
# Verify all environments
|
|
print_info "================================================"
|
|
print_info "Verifying installed environments..."
|
|
print_info "================================================"
|
|
|
|
for service in "${SERVICES[@]}"; do
|
|
verify_environment "${service}"
|
|
done
|
|
|
|
elif [[ " ${SERVICES[@]} " =~ " ${target_service} " ]]; then
|
|
setup_service "${target_service}"
|
|
verify_environment "${target_service}"
|
|
|
|
else
|
|
print_error "Unknown service: ${target_service}"
|
|
show_usage
|
|
exit 1
|
|
fi
|
|
|
|
echo ""
|
|
print_success "Setup complete!"
|
|
print_info ""
|
|
print_info "Next steps:"
|
|
print_info "1. Activate the environment: conda activate orbiquant-<service-name>"
|
|
print_info "2. Copy .env.example to .env and configure your settings"
|
|
print_info "3. Run the service: python -m src.main"
|
|
print_info ""
|
|
print_info "Available environments:"
|
|
${CONDA_PATH} env list | grep orbiquant || true
|
|
}
|
|
|
|
# Run main function
|
|
main "$@"
|