docs: add code quality and type checking workflows to master index
Some checks failed
Documentation Validation / validate-docs (push) Has been cancelled
Python Tests / test-python (push) Has been cancelled
API Endpoint Tests / test-api-endpoints (push) Has been cancelled
CLI Tests / test-cli (push) Has been cancelled
Integration Tests / test-service-integration (push) Has been cancelled
Package Tests / test-python-packages (map[name:aitbc-agent-sdk path:packages/py/aitbc-agent-sdk]) (push) Has been cancelled
Package Tests / test-python-packages (map[name:aitbc-core path:packages/py/aitbc-core]) (push) Has been cancelled
Package Tests / test-python-packages (map[name:aitbc-crypto path:packages/py/aitbc-crypto]) (push) Has been cancelled
Package Tests / test-python-packages (map[name:aitbc-sdk path:packages/py/aitbc-sdk]) (push) Has been cancelled
Package Tests / test-javascript-packages (map[name:aitbc-sdk-js path:packages/js/aitbc-sdk]) (push) Has been cancelled
Package Tests / test-javascript-packages (map[name:aitbc-token path:packages/solidity/aitbc-token]) (push) Has been cancelled
Security Scanning / security-scan (push) Has been cancelled
Systemd Sync / sync-systemd (push) Has been cancelled

- Add Code Quality Module section with pre-commit hooks and quality checks
- Add Type Checking CI/CD Module section with MyPy workflow and coverage
- Update README with code quality achievements and project structure
- Migrate FastAPI apps from deprecated on_event to lifespan context manager
- Update pyproject.toml files to reference consolidated dependencies
- Remove unused app.py import in coordinator-api
- Add type hints to agent
This commit is contained in:
aitbc
2026-03-31 21:45:43 +02:00
parent 26592ddf55
commit 9db720add8
308 changed files with 34194 additions and 34575 deletions

View File

@@ -0,0 +1,28 @@
# Type checking pre-commit hooks for AITBC
# Add this to your main .pre-commit-config.yaml
repos:
- repo: local
hooks:
- id: mypy-domain-core
name: mypy-domain-core
entry: ./venv/bin/mypy
language: system
args: [--ignore-missing-imports, --show-error-codes]
files: ^apps/coordinator-api/src/app/domain/(job|miner|agent_portfolio)\.py$
pass_filenames: false
- id: mypy-domain-all
name: mypy-domain-all
entry: ./venv/bin/mypy
language: system
args: [--ignore-missing-imports, --no-error-summary]
files: ^apps/coordinator-api/src/app/domain/
pass_filenames: false
- id: type-check-coverage
name: type-check-coverage
entry: ./scripts/type-checking/check-coverage.sh
language: script
files: ^apps/coordinator-api/src/app/
pass_filenames: false

View File

@@ -0,0 +1,219 @@
[tool.poetry]
name = "aitbc"
version = "v0.2.3"
description = "AI Agent Compute Network - Consolidated Dependencies"
authors = ["AITBC Team"]
packages = []
[tool.poetry.dependencies]
python = "^3.13"
# Core Web Framework
fastapi = ">=0.115.0"
uvicorn = {extras = ["standard"], version = ">=0.32.0"}
gunicorn = ">=22.0.0"
starlette = {version = ">=0.37.2,<0.38.0", optional = true}
# Database & ORM
sqlalchemy = ">=2.0.47"
sqlmodel = ">=0.0.37"
alembic = ">=1.18.0"
aiosqlite = ">=0.20.0"
asyncpg = ">=0.29.0"
# Configuration & Environment
pydantic = ">=2.12.0"
pydantic-settings = ">=2.13.0"
python-dotenv = ">=1.2.0"
# Rate Limiting & Security
slowapi = ">=0.1.9"
limits = ">=5.8.0"
prometheus-client = ">=0.24.0"
# HTTP Client & Networking
httpx = ">=0.28.0"
requests = ">=2.32.0"
aiohttp = ">=3.9.0"
websockets = ">=12.0"
# Cryptography & Blockchain
cryptography = ">=46.0.0"
pynacl = ">=1.5.0"
ecdsa = ">=0.19.0"
base58 = ">=2.1.1"
bech32 = ">=1.2.0"
web3 = ">=6.11.0"
eth-account = ">=0.13.0"
# Data Processing
pandas = ">=2.2.0"
numpy = ">=1.26.0"
orjson = ">=3.10.0"
# Machine Learning & AI (Optional)
torch = {version = ">=2.10.0", optional = true}
torchvision = {version = ">=0.15.0", optional = true}
# CLI Tools
click = ">=8.1.0"
rich = ">=13.0.0"
typer = ">=0.12.0"
click-completion = ">=0.5.2"
tabulate = ">=0.9.0"
colorama = ">=0.4.4"
keyring = ">=23.0.0"
# Logging & Monitoring
structlog = ">=24.1.0"
sentry-sdk = ">=2.0.0"
# Utilities
python-dateutil = ">=2.9.0"
pytz = ">=2024.1"
schedule = ">=1.2.0"
aiofiles = ">=24.1.0"
pyyaml = ">=6.0"
psutil = ">=5.9.0"
tenseal = ">=0.3.0"
# Async Support
asyncio-mqtt = ">=0.16.0"
uvloop = ">=0.22.0"
# Image Processing (Optional)
pillow = {version = ">=10.0.0", optional = true}
opencv-python = {version = ">=4.9.0", optional = true}
# Additional Dependencies
redis = ">=5.0.0"
msgpack = ">=1.1.0"
python-multipart = ">=0.0.6"
[tool.poetry.extras]
# Installation profiles for different use cases
web = ["starlette", "uvicorn", "gunicorn"]
database = ["sqlalchemy", "sqlmodel", "alembic", "aiosqlite", "asyncpg"]
blockchain = ["cryptography", "pynacl", "ecdsa", "base58", "bech32", "web3", "eth-account"]
ml = ["torch", "torchvision", "numpy", "pandas"]
cli = ["click", "rich", "typer", "click-completion", "tabulate", "colorama", "keyring"]
monitoring = ["structlog", "sentry-sdk", "prometheus-client"]
image = ["pillow", "opencv-python"]
all = ["web", "database", "blockchain", "ml", "cli", "monitoring", "image"]
[tool.poetry.group.dev.dependencies]
# Development & Testing
pytest = ">=8.2.0"
pytest-asyncio = ">=0.24.0"
black = ">=24.0.0"
flake8 = ">=7.0.0"
ruff = ">=0.1.0"
mypy = ">=1.8.0"
isort = ">=5.13.0"
pre-commit = ">=3.5.0"
bandit = ">=1.7.0"
pydocstyle = ">=6.3.0"
pyupgrade = ">=3.15.0"
safety = ">=2.3.0"
[tool.poetry.group.test.dependencies]
pytest-cov = ">=4.0.0"
pytest-mock = ">=3.10.0"
pytest-xdist = ">=3.0.0"
[tool.black]
line-length = 127
target-version = ['py313']
include = '\.pyi?$'
extend-exclude = '''
/(
\\.eggs
| \\.git
| \\.hg
| \\.mypy_cache
| \\.tox
| \\.venv
| build
| dist
)/
'''
[tool.isort]
profile = "black"
line_length = 127
multi_line_output = 3
include_trailing_comma = true
force_grid_wrap = 0
use_parentheses = true
ensure_newline_before_comments = true
[tool.mypy]
python_version = "3.13"
warn_return_any = true
warn_unused_configs = true
disallow_untyped_defs = true
disallow_incomplete_defs = true
check_untyped_defs = true
disallow_untyped_decorators = true
no_implicit_optional = true
warn_redundant_casts = true
warn_unused_ignores = true
warn_no_return = true
warn_unreachable = true
strict_equality = true
[[tool.mypy.overrides]]
module = [
"torch.*",
"cv2.*",
"pandas.*",
"numpy.*",
"web3.*",
"eth_account.*",
]
ignore_missing_imports = true
[tool.ruff]
line-length = 127
target-version = "py313"
[tool.ruff.lint]
select = [
"E", # pycodestyle errors
"W", # pycodestyle warnings
"F", # pyflakes
"I", # isort
"B", # flake8-bugbear
"C4", # flake8-comprehensions
"UP", # pyupgrade
]
ignore = [
"E501", # line too long, handled by black
"B008", # do not perform function calls in argument defaults
"C901", # too complex
]
[tool.ruff.lint.per-file-ignores]
"__init__.py" = ["F401"]
"tests/*" = ["B011"]
[tool.pydocstyle]
convention = "google"
add_ignore = ["D100", "D101", "D102", "D103", "D104", "D105", "D106", "D107"]
[tool.pytest.ini_options]
minversion = "8.0"
addopts = "-ra -q --strict-markers --strict-config"
testpaths = ["tests"]
python_files = ["test_*.py", "*_test.py"]
python_classes = ["Test*"]
python_functions = ["test_*"]
markers = [
"slow: marks tests as slow (deselect with '-m \"not slow\"')",
"integration: marks tests as integration tests",
"unit: marks tests as unit tests",
]
[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"

View File

@@ -0,0 +1,130 @@
# AITBC Consolidated Dependencies
# Unified dependency management for all AITBC services
# Version: v0.2.3-consolidated
# Date: 2026-03-31
# ===========================================
# CORE WEB FRAMEWORK
# ===========================================
fastapi==0.115.6
uvicorn[standard]==0.32.1
gunicorn==22.0.0
starlette>=0.40.0,<0.42.0
# ===========================================
# DATABASE & ORM
# ===========================================
sqlalchemy==2.0.47
sqlmodel==0.0.37
alembic==1.18.0
aiosqlite==0.20.0
asyncpg==0.30.0
# ===========================================
# CONFIGURATION & ENVIRONMENT
# ===========================================
pydantic==2.12.0
pydantic-settings==2.13.0
python-dotenv==1.2.0
# ===========================================
# RATE LIMITING & SECURITY
# ===========================================
slowapi==0.1.9
limits==5.8.0
prometheus-client==0.24.0
# ===========================================
# HTTP CLIENT & NETWORKING
# ===========================================
httpx==0.28.0
requests==2.32.0
aiohttp==3.9.0
websockets==12.0
# ===========================================
# CRYPTOGRAPHY & BLOCKCHAIN
# ===========================================
cryptography==46.0.0
pynacl==1.5.0
ecdsa==0.19.0
base58==2.1.1
bech32==1.2.0
web3==6.11.0
eth-account==0.13.0
# ===========================================
# DATA PROCESSING
# ===========================================
pandas==2.2.0
numpy==1.26.0
orjson==3.10.0
# ===========================================
# MACHINE LEARNING & AI
# ===========================================
torch==2.10.0
torchvision==0.15.0
# ===========================================
# CLI TOOLS
# ===========================================
click==8.1.0
rich==13.0.0
typer==0.12.0
click-completion==0.5.2
tabulate==0.9.0
colorama==0.4.4
keyring==23.0.0
# ===========================================
# DEVELOPMENT & TESTING
# ===========================================
pytest==8.2.0
pytest-asyncio==0.24.0
black==24.0.0
flake8==7.0.0
ruff==0.1.0
mypy==1.8.0
isort==5.13.0
pre-commit==3.5.0
bandit==1.7.0
pydocstyle==6.3.0
pyupgrade==3.15.0
safety==2.3.0
# ===========================================
# LOGGING & MONITORING
# ===========================================
structlog==24.1.0
sentry-sdk==2.0.0
# ===========================================
# UTILITIES
# ===========================================
python-dateutil==2.9.0
pytz==2024.1
schedule==1.2.0
aiofiles==24.1.0
pyyaml==6.0
psutil==5.9.0
tenseal==0.3.0
# ===========================================
# ASYNC SUPPORT
# ===========================================
asyncio-mqtt==0.16.0
uvloop==0.22.0
# ===========================================
# IMAGE PROCESSING
# ===========================================
pillow==10.0.0
opencv-python==4.9.0
# ===========================================
# ADDITIONAL DEPENDENCIES
# ===========================================
redis==5.0.0
msgpack==1.1.0
python-multipart==0.0.6

View File

@@ -0,0 +1,58 @@
#!/usr/bin/env python3
"""
Quick test to verify code quality tools are working properly
"""
import subprocess
import sys
from pathlib import Path
def run_command(cmd, description):
"""Run a command and return success status"""
print(f"\n🔍 {description}")
print(f"Running: {' '.join(cmd)}")
try:
result = subprocess.run(cmd, capture_output=True, text=True, cwd="/opt/aitbc")
if result.returncode == 0:
print(f"{description} - PASSED")
return True
else:
print(f"{description} - FAILED")
print(f"Error output: {result.stderr[:500]}")
return False
except Exception as e:
print(f"{description} - ERROR: {e}")
return False
def main():
"""Test code quality tools"""
print("🚀 Testing AITBC Code Quality Setup")
print("=" * 50)
tests = [
(["/opt/aitbc/venv/bin/black", "--check", "--diff", "apps/coordinator-api/src/app/routers/"], "Black formatting check"),
(["/opt/aitbc/venv/bin/isort", "--check-only", "apps/coordinator-api/src/app/routers/"], "Isort import check"),
(["/opt/aitbc/venv/bin/ruff", "check", "apps/coordinator-api/src/app/routers/"], "Ruff linting"),
(["/opt/aitbc/venv/bin/mypy", "--ignore-missing-imports", "apps/coordinator-api/src/app/routers/"], "MyPy type checking"),
(["/opt/aitbc/venv/bin/bandit", "-r", "apps/coordinator-api/src/app/routers/", "-f", "json"], "Bandit security check"),
]
results = []
for cmd, desc in tests:
results.append(run_command(cmd, desc))
# Summary
passed = sum(results)
total = len(results)
print(f"\n📊 Summary: {passed}/{total} tests passed")
if passed == total:
print("🎉 All code quality checks are working!")
return 0
else:
print("⚠️ Some checks failed - review the output above")
return 1
if __name__ == "__main__":
sys.exit(main())