Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/itk.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ jobs:
run: bash run_itk.sh
working-directory: itk
env:
A2A_SAMPLES_REVISION: itk-v.0.11-alpha
A2A_SAMPLES_REVISION: itk-v.015-alpha
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@ docs/ai/ai_learnings.md
itk/a2a-samples/
itk/pyproto/
itk/instruction.proto
itk/logs/
21 changes: 20 additions & 1 deletion itk/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ You must set the `A2A_SAMPLES_REVISION` environment variable to specify which re

Example:
```bash
export A2A_SAMPLES_REVISION=itk-v.0.11-alpha
export A2A_SAMPLES_REVISION=itk-v.015-alpha
```

### 2. Execute Tests
Expand All @@ -52,3 +52,22 @@ The script will:
- Checkout the specified revision.
- Build the ITK service Docker image.
- Run the tests and output results.

## Debugging

To enable debug logging and persist logs for inspection:

1. Set the `ITK_LOG_LEVEL` environment variable to `DEBUG`:
```bash
export ITK_LOG_LEVEL=DEBUG
```
2. Run the test script:
```bash
./run_itk.sh
```

When run in `DEBUG` mode:
- The `logs/` directory will be created in this directory (if it doesn't exist).
- The `logs/` directory will be mounted to the container.
- The test execution will produce detailed logs in `logs/` (e.g., `agent_current.log`).
- The `logs/` directory will **not** be removed during cleanup.
7 changes: 5 additions & 2 deletions itk/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import asyncio
import base64
import logging
import os
import uuid

import grpc
Expand Down Expand Up @@ -36,7 +37,8 @@
from a2a.utils import TransportProtocol


logging.basicConfig(level=logging.INFO)
log_level = os.environ.get('ITK_LOG_LEVEL', 'INFO').upper()
logging.basicConfig(level=log_level)
logger = logging.getLogger(__name__)


Expand Down Expand Up @@ -352,8 +354,9 @@ async def main_async(http_port: int, grpc_port: int) -> None:
grpc_port,
)

uvicorn_log_level = os.environ.get('ITK_LOG_LEVEL', 'INFO').lower()
Comment thread
kdziedzic70 marked this conversation as resolved.
config = uvicorn.Config(
app, host='127.0.0.1', port=http_port, log_level='info'
app, host='127.0.0.1', port=http_port, log_level=uvicorn_log_level
)
uvicorn_server = uvicorn.Server(config)

Expand Down
15 changes: 15 additions & 0 deletions itk/run_itk.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
#!/bin/bash
set -ex

# Set default log level
export ITK_LOG_LEVEL="${ITK_LOG_LEVEL:-INFO}"

# Initialize default exit code
RESULT=1

Expand Down Expand Up @@ -63,9 +66,21 @@ ITK_DIR=$(pwd)
# Stop existing container if any
docker rm -f itk-service || true

# Create logs directory if debug
if [ "${ITK_LOG_LEVEL^^}" = "DEBUG" ]; then
mkdir -p "$ITK_DIR/logs"
fi

DOCKER_MOUNT_LOGS=""
if [ "${ITK_LOG_LEVEL^^}" = "DEBUG" ]; then
DOCKER_MOUNT_LOGS="-v $ITK_DIR/logs:/app/logs"
fi
Comment thread
kdziedzic70 marked this conversation as resolved.

docker run -d --name itk-service \
-v "$A2A_PYTHON_ROOT:/app/agents/repo" \
-v "$ITK_DIR:/app/agents/repo/itk" \
$DOCKER_MOUNT_LOGS \
-e ITK_LOG_LEVEL="$ITK_LOG_LEVEL" \
-p 8000:8000 \
itk_service

Expand Down
Loading