Skip to content

Commit 2c81a91

Browse files
Fix pre-commit issues: formatting, imports, linting
Signed-off-by: cogniware-devops <ambarish.desai@cogniware.ai>
1 parent e95576f commit 2c81a91

3 files changed

Lines changed: 82 additions & 7 deletions

File tree

CogniwareIms/.gitignore

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# Copyright (C) 2024 Intel Corporation
2+
# SPDX-License-Identifier: Apache-2.0
3+
14
# Python
25
__pycache__/
36
*.py[cod]
@@ -8,12 +11,20 @@ venv/
811
env/
912
ENV/
1013
.venv
14+
*.egg-info/
15+
dist/
16+
build/
17+
.pytest_cache/
18+
.coverage
19+
htmlcov/
1120

1221
# Node
1322
node_modules/
1423
npm-debug.log*
1524
yarn-debug.log*
1625
yarn-error.log*
26+
.pnp
27+
.pnp.js
1728
.next/
1829
out/
1930
build/
@@ -25,6 +36,7 @@ build/
2536
*.swo
2637
*~
2738
.DS_Store
39+
*.code-workspace
2840

2941
# Logs
3042
*.log
@@ -33,14 +45,16 @@ logs/
3345
# Environment
3446
.env
3547
.env.local
48+
.env*.local
49+
.env.production
3650

3751
# Docker
3852
.dockerignore
3953

4054
# Build artifacts
41-
dist/
42-
build/
4355
*.egg-info/
56+
*.egg
57+
MANIFEST
4458

4559
# Data (excluded per OPEA guidelines)
4660
data/
@@ -49,7 +63,22 @@ data/
4963
*.pdf
5064
*.docx
5165

66+
# Models (large files)
67+
models/
68+
*.bin
69+
*.safetensors
70+
*.gguf
71+
5272
# Temporary files
5373
*.tmp
5474
*.bak
5575
*.backup
76+
tmp/
77+
temp/
78+
79+
# OS
80+
Thumbs.db
81+
82+
# Lock files (keep package-lock.json but ignore others)
83+
yarn.lock
84+
pnpm-lock.yaml

CogniwareIms/.pre-commit-config.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,4 +69,3 @@ repos:
6969
- id: flake8
7070
args: ["--max-line-length=120", "--ignore=E203,W503"]
7171
files: \.py$
72-
exclude: '^((?!CogniwareIms/).)*$'

CogniwareIms/tests/test_compose_on_xeon.sh

Lines changed: 51 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,36 @@
44

55
set -e
66

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+
822
LOG_PATH="$WORKPATH/tests"
923

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+
1037
# Get IP address with fallback to localhost
1138
if command -v hostname >/dev/null 2>&1; then
1239
ip_address=$(hostname -I | awk '{print $1}' 2>/dev/null || echo "127.0.0.1")
@@ -45,13 +72,27 @@ wait_for_service() {
4572

4673
function build_docker_images() {
4774
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
4983
docker compose -f build.yaml build
5084
}
5185

5286
function start_services() {
5387
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
5596

5697
# Set environment variables
5798
export HUGGINGFACEHUB_API_TOKEN=${HUGGINGFACEHUB_API_TOKEN}
@@ -195,7 +236,13 @@ function validate_frontend() {
195236

196237
function stop_services() {
197238
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
199246
docker compose down -v 2>/dev/null || {
200247
echo "Warning: Some containers may not have stopped cleanly"
201248
docker ps -a | grep cogniware || true

0 commit comments

Comments
 (0)