mirror of
https://github.com/trustgraph-ai/trustgraph.git
synced 2026-05-01 03:16:23 +02:00
Fix verify CLI issues
This commit is contained in:
parent
52ca74bbbc
commit
3b6b035e6f
1 changed files with 26 additions and 18 deletions
|
|
@ -171,14 +171,12 @@ def check_api_gateway(url: str, timeout: int, token: Optional[str] = None) -> Tu
|
||||||
|
|
||||||
|
|
||||||
def check_processors(url: str, min_processors: int, timeout: int, token: Optional[str] = None) -> Tuple[bool, str]:
|
def check_processors(url: str, min_processors: int, timeout: int, token: Optional[str] = None) -> Tuple[bool, str]:
|
||||||
"""Check if processors are running via show-processor-state."""
|
"""Check if processors are running via metrics endpoint."""
|
||||||
try:
|
try:
|
||||||
api = Api(url, token=token)
|
# Construct metrics URL from API URL
|
||||||
|
if not url.endswith('/'):
|
||||||
# Use the metrics endpoint similar to show_processor_state
|
url += '/'
|
||||||
# This is a simplified check - we'll use requests to check the metrics
|
metrics_url = f"{url}api/metrics/query?query=processor_info"
|
||||||
metrics_url = url.replace('http://', '').replace('https://', '').split('/')[0]
|
|
||||||
metrics_url = f"http://{metrics_url}:8088/api/metrics/query?query=processor_info"
|
|
||||||
|
|
||||||
resp = requests.get(metrics_url, timeout=timeout)
|
resp = requests.get(metrics_url, timeout=timeout)
|
||||||
if resp.status_code == 200:
|
if resp.status_code == 200:
|
||||||
|
|
@ -199,7 +197,7 @@ def check_processors(url: str, min_processors: int, timeout: int, token: Optiona
|
||||||
def check_flow_classes(url: str, timeout: int, token: Optional[str] = None) -> Tuple[bool, str]:
|
def check_flow_classes(url: str, timeout: int, token: Optional[str] = None) -> Tuple[bool, str]:
|
||||||
"""Check if flow classes are loaded."""
|
"""Check if flow classes are loaded."""
|
||||||
try:
|
try:
|
||||||
api = Api(url, token=token)
|
api = Api(url, token=token, timeout=timeout)
|
||||||
flow_api = api.flow()
|
flow_api = api.flow()
|
||||||
|
|
||||||
classes = flow_api.list_classes()
|
classes = flow_api.list_classes()
|
||||||
|
|
@ -216,7 +214,7 @@ def check_flow_classes(url: str, timeout: int, token: Optional[str] = None) -> T
|
||||||
def check_flows(url: str, timeout: int, token: Optional[str] = None) -> Tuple[bool, str]:
|
def check_flows(url: str, timeout: int, token: Optional[str] = None) -> Tuple[bool, str]:
|
||||||
"""Check if flow manager is responding."""
|
"""Check if flow manager is responding."""
|
||||||
try:
|
try:
|
||||||
api = Api(url, token=token)
|
api = Api(url, token=token, timeout=timeout)
|
||||||
flow_api = api.flow()
|
flow_api = api.flow()
|
||||||
|
|
||||||
flows = flow_api.list()
|
flows = flow_api.list()
|
||||||
|
|
@ -231,12 +229,22 @@ def check_flows(url: str, timeout: int, token: Optional[str] = None) -> Tuple[bo
|
||||||
def check_prompts(url: str, timeout: int, token: Optional[str] = None) -> Tuple[bool, str]:
|
def check_prompts(url: str, timeout: int, token: Optional[str] = None) -> Tuple[bool, str]:
|
||||||
"""Check if prompts are loaded."""
|
"""Check if prompts are loaded."""
|
||||||
try:
|
try:
|
||||||
api = Api(url, token=token)
|
api = Api(url, token=token, timeout=timeout)
|
||||||
|
config = api.config()
|
||||||
|
|
||||||
prompts = api.prompts().list()
|
# Import ConfigKey here to avoid top-level import issues
|
||||||
|
from trustgraph.api.types import ConfigKey
|
||||||
|
import json
|
||||||
|
|
||||||
if prompts and len(prompts) > 0:
|
# Get the template-index which lists all prompts
|
||||||
return True, f"Found {len(prompts)} prompt(s)"
|
values = config.get([
|
||||||
|
ConfigKey(type="prompt", key="template-index")
|
||||||
|
])
|
||||||
|
|
||||||
|
ix = json.loads(values[0].value)
|
||||||
|
|
||||||
|
if ix and len(ix) > 0:
|
||||||
|
return True, f"Found {len(ix)} prompt(s)"
|
||||||
else:
|
else:
|
||||||
return False, "No prompts found"
|
return False, "No prompts found"
|
||||||
|
|
||||||
|
|
@ -247,7 +255,7 @@ def check_prompts(url: str, timeout: int, token: Optional[str] = None) -> Tuple[
|
||||||
def check_library(url: str, timeout: int, token: Optional[str] = None) -> Tuple[bool, str]:
|
def check_library(url: str, timeout: int, token: Optional[str] = None) -> Tuple[bool, str]:
|
||||||
"""Check if library service is responding."""
|
"""Check if library service is responding."""
|
||||||
try:
|
try:
|
||||||
api = Api(url, token=token)
|
api = Api(url, token=token, timeout=timeout)
|
||||||
library_api = api.library()
|
library_api = api.library()
|
||||||
|
|
||||||
# Try to get documents (with default user)
|
# Try to get documents (with default user)
|
||||||
|
|
@ -365,10 +373,10 @@ def main():
|
||||||
print("=" * 60)
|
print("=" * 60)
|
||||||
print("TrustGraph System Status Verification")
|
print("TrustGraph System Status Verification")
|
||||||
print("=" * 60)
|
print("=" * 60)
|
||||||
print(f"Global timeout: {args.global_timeout}s")
|
# print(f"Global timeout: {args.global_timeout}s")
|
||||||
print(f"Check timeout: {args.check_timeout}s")
|
# print(f"Check timeout: {args.check_timeout}s")
|
||||||
print(f"Retry delay: {args.retry_delay}s")
|
# print(f"Retry delay: {args.retry_delay}s")
|
||||||
print("=" * 60)
|
# print("=" * 60)
|
||||||
print()
|
print()
|
||||||
|
|
||||||
# Phase 1: Infrastructure
|
# Phase 1: Infrastructure
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue