|
4 | 4 |
|
5 | 5 | set -e |
6 | 6 |
|
7 | | -WORKPATH=$(dirname "$PWD") |
| 7 | +# Calculate WORKPATH - handle both local and CI environments |
| 8 | +# If run from tests/ directory: WORKPATH = parent directory |
| 9 | +# If run from root: WORKPATH = current directory |
| 10 | +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" |
| 11 | +if [ -f "$SCRIPT_DIR/../cogniwareims.py" ]; then |
| 12 | + # We're in the CogniwareIms directory structure |
| 13 | + WORKPATH="$(cd "$SCRIPT_DIR/.." && pwd)" |
| 14 | +elif [ -f "$SCRIPT_DIR/../../CogniwareIms/cogniwareims.py" ]; then |
| 15 | + # We're in GenAIExamples/CogniwareIms/tests |
| 16 | + WORKPATH="$(cd "$SCRIPT_DIR/../.." && pwd)/CogniwareIms" |
| 17 | +else |
| 18 | + # Fallback: assume we're in the example directory |
| 19 | + WORKPATH="$(cd "$SCRIPT_DIR/.." && pwd)" |
| 20 | +fi |
| 21 | + |
8 | 22 | LOG_PATH="$WORKPATH/tests" |
9 | 23 |
|
| 24 | +# Debug output |
| 25 | +echo "SCRIPT_DIR: $SCRIPT_DIR" |
| 26 | +echo "WORKPATH: $WORKPATH" |
| 27 | +echo "Verifying WORKPATH..." |
| 28 | +if [ ! -f "$WORKPATH/cogniwareims.py" ] && [ ! -f "$WORKPATH/CogniwareIms/cogniwareims.py" ]; then |
| 29 | + echo "WARNING: cogniwareims.py not found in WORKPATH. Attempting to locate..." |
| 30 | + # Try to find it |
| 31 | + if [ -f "$(dirname "$SCRIPT_DIR")/cogniwareims.py" ]; then |
| 32 | + WORKPATH="$(dirname "$SCRIPT_DIR")" |
| 33 | + echo "Found cogniwareims.py at: $WORKPATH" |
| 34 | + fi |
| 35 | +fi |
| 36 | + |
10 | 37 | # Get IP address with fallback to localhost |
11 | 38 | if command -v hostname >/dev/null 2>&1; then |
12 | 39 | ip_address=$(hostname -I | awk '{print $1}' 2>/dev/null || echo "127.0.0.1") |
@@ -45,13 +72,27 @@ wait_for_service() { |
45 | 72 |
|
46 | 73 | function build_docker_images() { |
47 | 74 | echo "Building Docker images..." |
48 | | - cd $WORKPATH/docker_image_build |
| 75 | + if [ -d "$WORKPATH/docker_image_build" ]; then |
| 76 | + cd "$WORKPATH/docker_image_build" |
| 77 | + elif [ -d "$WORKPATH/CogniwareIms/docker_image_build" ]; then |
| 78 | + cd "$WORKPATH/CogniwareIms/docker_image_build" |
| 79 | + else |
| 80 | + echo "ERROR: docker_image_build directory not found" |
| 81 | + exit 1 |
| 82 | + fi |
49 | 83 | docker compose -f build.yaml build |
50 | 84 | } |
51 | 85 |
|
52 | 86 | function start_services() { |
53 | 87 | echo "Starting Cogniware IMS services on Intel Xeon..." |
54 | | - cd $WORKPATH/docker_compose/intel/cpu/xeon |
| 88 | + if [ -d "$WORKPATH/docker_compose/intel/cpu/xeon" ]; then |
| 89 | + cd "$WORKPATH/docker_compose/intel/cpu/xeon" |
| 90 | + elif [ -d "$WORKPATH/CogniwareIms/docker_compose/intel/cpu/xeon" ]; then |
| 91 | + cd "$WORKPATH/CogniwareIms/docker_compose/intel/cpu/xeon" |
| 92 | + else |
| 93 | + echo "ERROR: docker_compose/intel/cpu/xeon directory not found" |
| 94 | + exit 1 |
| 95 | + fi |
55 | 96 |
|
56 | 97 | # Set environment variables |
57 | 98 | export HUGGINGFACEHUB_API_TOKEN=${HUGGINGFACEHUB_API_TOKEN} |
@@ -195,7 +236,13 @@ function validate_frontend() { |
195 | 236 |
|
196 | 237 | function stop_services() { |
197 | 238 | echo "Stopping services..." |
198 | | - cd $WORKPATH/docker_compose/intel/cpu/xeon |
| 239 | + if [ -d "$WORKPATH/docker_compose/intel/cpu/xeon" ]; then |
| 240 | + cd "$WORKPATH/docker_compose/intel/cpu/xeon" |
| 241 | + elif [ -d "$WORKPATH/CogniwareIms/docker_compose/intel/cpu/xeon" ]; then |
| 242 | + cd "$WORKPATH/CogniwareIms/docker_compose/intel/cpu/xeon" |
| 243 | + else |
| 244 | + echo "Warning: docker_compose directory not found, attempting cleanup anyway" |
| 245 | + fi |
199 | 246 | docker compose down -v 2>/dev/null || { |
200 | 247 | echo "Warning: Some containers may not have stopped cleanly" |
201 | 248 | docker ps -a | grep cogniware || true |
|
0 commit comments