Skip to content

Commit 6229b14

Browse files
committed
improved formatting etc
1 parent 5d18c19 commit 6229b14

File tree

153 files changed

+9377
-9594
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

153 files changed

+9377
-9594
lines changed

.github/workflows/publish.yml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: Publish to PyPI
2+
3+
on:
4+
release:
5+
types: [published]
6+
workflow_dispatch:
7+
8+
jobs:
9+
build:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v4
13+
14+
- name: Install uv
15+
uses: astral-sh/setup-uv@v4
16+
with:
17+
enable-cache: true
18+
19+
- name: Set up Python
20+
run: uv python install 3.12
21+
22+
- name: Build package
23+
run: |
24+
uv build
25+
26+
- name: Upload artifacts
27+
uses: actions/upload-artifact@v4
28+
with:
29+
name: dist
30+
path: dist/
31+
32+
publish:
33+
needs: build
34+
runs-on: ubuntu-latest
35+
environment:
36+
name: pypi
37+
url: https://pypi.org/p/chuk-tool-processor
38+
permissions:
39+
id-token: write
40+
41+
steps:
42+
- name: Download artifacts
43+
uses: actions/download-artifact@v4
44+
with:
45+
name: dist
46+
path: dist/
47+
48+
- name: Publish to PyPI
49+
uses: pypa/gh-action-pypi-publish@release/v1
50+
with:
51+
verbose: true

.github/workflows/test.yml

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
name: Test
2+
3+
on:
4+
push:
5+
branches: [ main, develop ]
6+
pull_request:
7+
branches: [ main ]
8+
workflow_dispatch:
9+
10+
jobs:
11+
test:
12+
runs-on: ${{ matrix.os }}
13+
strategy:
14+
fail-fast: false
15+
matrix:
16+
os: [ubuntu-latest, windows-latest, macos-latest]
17+
python-version: ["3.11", "3.12", "3.13"]
18+
19+
steps:
20+
- uses: actions/checkout@v4
21+
22+
- name: Install uv
23+
uses: astral-sh/setup-uv@v4
24+
with:
25+
enable-cache: true
26+
cache-dependency-glob: "uv.lock"
27+
28+
- name: Set up Python ${{ matrix.python-version }}
29+
run: uv python install ${{ matrix.python-version }}
30+
31+
- name: Install dependencies
32+
run: |
33+
uv sync --dev
34+
35+
- name: Run linting
36+
run: |
37+
uv run ruff check .
38+
uv run ruff format --check .
39+
40+
- name: Run type checking
41+
run: |
42+
uv run mypy src --ignore-missing-imports
43+
44+
- name: Run tests with coverage
45+
run: |
46+
uv run pytest tests/ --cov=src --cov-report=term --cov-report=xml --cov-report=html
47+
48+
- name: Upload coverage reports
49+
if: matrix.os == 'ubuntu-latest' && matrix.python-version == '3.12'
50+
uses: codecov/codecov-action@v4
51+
with:
52+
file: ./coverage.xml
53+
flags: unittests
54+
name: codecov-umbrella
55+
fail_ci_if_error: false
56+
57+
- name: Check coverage threshold
58+
if: matrix.os == 'ubuntu-latest' && matrix.python-version == '3.12'
59+
run: |
60+
uv run python -c "
61+
import xml.etree.ElementTree as ET
62+
tree = ET.parse('coverage.xml')
63+
root = tree.getroot()
64+
coverage = float(root.attrib['line-rate']) * 100
65+
print(f'Coverage: {coverage:.2f}%')
66+
if coverage < 80:
67+
print(f'Coverage {coverage:.2f}% is below 80% threshold')
68+
exit(1)
69+
"

.gitignore

Lines changed: 73 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,82 @@
1-
# Python-generated files
1+
# Byte-compiled / optimized / DLL files
22
__pycache__/
3-
*.py[oc]
3+
*.py[cod]
4+
*$py.class
5+
6+
# C extensions
7+
*.so
8+
9+
# Distribution / packaging
10+
.Python
411
build/
12+
develop-eggs/
513
dist/
14+
downloads/
15+
eggs/
16+
.eggs/
17+
lib/
18+
lib64/
19+
parts/
20+
sdist/
21+
var/
622
wheels/
7-
*.egg-info
23+
share/python-wheels/
24+
*.egg-info/
25+
.installed.cfg
26+
*.egg
27+
MANIFEST
828

9-
# Virtual environments
10-
.venv
29+
# Unit test / coverage reports
30+
htmlcov/
31+
.tox/
32+
.nox/
33+
.coverage
34+
.coverage.*
35+
.cache
36+
nosetests.xml
37+
coverage.xml
38+
*.cover
39+
*.py,cover
40+
.hypothesis/
41+
.pytest_cache/
42+
cover/
1143

12-
# env
44+
# Environments
1345
.env
46+
.venv
47+
env/
48+
venv/
49+
ENV/
50+
env.bak/
51+
venv.bak/
52+
53+
# mypy
54+
.mypy_cache/
55+
.dmypy.json
56+
dmypy.json
1457

15-
# DS Store
58+
# IDEs
59+
.idea/
60+
.vscode/
61+
*.swp
62+
*.swo
63+
*~
64+
65+
# OS
1666
.DS_Store
17-
.pytest_cache
67+
Thumbs.db
68+
ehthumbs.db
69+
70+
# uv
71+
.uv/
72+
uv.lock.bak
73+
74+
# ruff
75+
.ruff_cache/
76+
77+
# Local test files
78+
test.db
79+
*.db
80+
scratch/
81+
temp/
82+
tmp/

.pre-commit-config.yaml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
repos:
2+
- repo: https://github.com/pre-commit/pre-commit-hooks
3+
rev: v4.6.0
4+
hooks:
5+
- id: trailing-whitespace
6+
- id: end-of-file-fixer
7+
- id: check-yaml
8+
- id: check-added-large-files
9+
- id: check-json
10+
- id: check-toml
11+
- id: check-merge-conflict
12+
- id: check-case-conflict
13+
- id: detect-private-key
14+
15+
- repo: https://github.com/astral-sh/ruff-pre-commit
16+
rev: v0.7.1
17+
hooks:
18+
- id: ruff
19+
args: [--fix]
20+
- id: ruff-format
21+
22+
- repo: https://github.com/pre-commit/mirrors-mypy
23+
rev: v1.13.0
24+
hooks:
25+
- id: mypy
26+
additional_dependencies: [types-all]
27+
files: ^src/
28+
args: [--ignore-missing-imports]
29+
30+
- repo: https://github.com/pycqa/isort
31+
rev: 5.13.2
32+
hooks:
33+
- id: isort
34+
args: ["--profile", "black"]
35+
36+
- repo: https://github.com/asottile/pyupgrade
37+
rev: v3.19.0
38+
hooks:
39+
- id: pyupgrade
40+
args: [--py311-plus]
41+
42+
- repo: local
43+
hooks:
44+
- id: pytest-check
45+
name: pytest-check
46+
entry: uv run pytest
47+
language: system
48+
pass_filenames: false
49+
always_run: true
50+
stages: [push]

debug/debug_sse_connection.py

Lines changed: 35 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -8,41 +8,41 @@
88
"""
99

1010
import asyncio
11-
import httpx
1211
import json
1312
from datetime import datetime
1413

14+
import httpx
15+
16+
1517
async def test_sse_connection():
1618
"""Test the SSE connection manually."""
1719
print("🔍 Testing SSE connection manually...")
18-
20+
1921
url = "http://localhost:8000/sse"
20-
22+
2123
try:
22-
async with httpx.AsyncClient() as client:
23-
async with client.stream("GET", url) as response:
24-
print(f"📡 Connected to: {url}")
25-
print(f"📊 Status: {response.status_code}")
26-
print(f"📋 Headers: {dict(response.headers)}")
27-
print("🔄 Receiving events...\n")
28-
29-
event_count = 0
30-
timeout_seconds = 10
31-
32-
async for line in response.aiter_lines():
33-
if line.strip():
34-
event_count += 1
35-
timestamp = datetime.now().strftime("%H:%M:%S.%f")[:-3]
36-
print(f"[{timestamp}] Event {event_count}: {line}")
37-
38-
# Stop after getting a few events or timeout
39-
if event_count > 20:
40-
print("📊 Received enough events, stopping...")
41-
break
42-
43-
print(f"\n✅ Received {event_count} events total")
44-
45-
except asyncio.TimeoutError:
24+
async with httpx.AsyncClient() as client, client.stream("GET", url) as response:
25+
print(f"📡 Connected to: {url}")
26+
print(f"📊 Status: {response.status_code}")
27+
print(f"📋 Headers: {dict(response.headers)}")
28+
print("🔄 Receiving events...\n")
29+
30+
event_count = 0
31+
32+
async for line in response.aiter_lines():
33+
if line.strip():
34+
event_count += 1
35+
timestamp = datetime.now().strftime("%H:%M:%S.%f")[:-3]
36+
print(f"[{timestamp}] Event {event_count}: {line}")
37+
38+
# Stop after getting a few events or timeout
39+
if event_count > 20:
40+
print("📊 Received enough events, stopping...")
41+
break
42+
43+
print(f"\n✅ Received {event_count} events total")
44+
45+
except TimeoutError:
4646
print("⏰ Connection timed out")
4747
except httpx.RequestError as e:
4848
print(f"❌ Connection error: {e}")
@@ -53,13 +53,9 @@ async def test_sse_connection():
5353
async def test_basic_endpoints():
5454
"""Test basic HTTP endpoints."""
5555
print("🔍 Testing basic endpoints...")
56-
57-
endpoints = [
58-
"http://localhost:8000/",
59-
"http://localhost:8000/health",
60-
"http://localhost:8000/tools"
61-
]
62-
56+
57+
endpoints = ["http://localhost:8000/", "http://localhost:8000/health", "http://localhost:8000/tools"]
58+
6359
async with httpx.AsyncClient() as client:
6460
for url in endpoints:
6561
try:
@@ -75,15 +71,15 @@ async def main():
7571
"""Run all debug tests."""
7672
print("🎯 SSE Connection Debug Tool")
7773
print("=" * 40)
78-
74+
7975
# Test basic endpoints first
8076
await test_basic_endpoints()
81-
77+
8278
print("\n" + "=" * 40)
83-
79+
8480
# Test SSE connection
8581
await test_sse_connection()
86-
82+
8783
print("\n🎉 Debug complete!")
8884

8985

@@ -93,4 +89,4 @@ async def main():
9389
except KeyboardInterrupt:
9490
print("\n👋 Debug interrupted")
9591
except Exception as e:
96-
print(f"❌ Debug error: {e}")
92+
print(f"❌ Debug error: {e}")

0 commit comments

Comments
 (0)