Skip to content
Open
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
42 changes: 0 additions & 42 deletions api.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,45 +111,3 @@ async def get_task_status(task_id: str):
log_error(logger, f"Error getting task status: {str(e)}")
await send_error_to_webhook(str(e), "get_task_status", task_id)
raise HTTPException(status_code=500, detail=str(e))

@router.get("/metrics")
async def get_metrics():
"""Return system metrics"""
try:
with get_db() as db:
# Get database statistics
total_tasks = db.query(Task).count()
completed_tasks = db.query(Task).filter(Task.status == "completed").count()
failed_tasks = db.query(Task).filter(Task.status == "failed").count()
running_tasks = db.query(Task).filter(Task.status == "running").count()

# Get system metrics
cpu_percent = psutil.cpu_percent()
memory = psutil.virtual_memory()
disk = psutil.disk_usage('/')

metrics = {
"system": {
"cpu_percent": cpu_percent,
"memory_percent": memory.percent,
"disk_percent": disk.percent
},
"tasks": {
"total": total_tasks,
"completed": completed_tasks,
"failed": failed_tasks,
"running": running_tasks,
# "queued": task_queue.qsize(),
"available_slots": MAX_CONCURRENT_TASKS - running_tasks
}
}

# Send metrics to webhook
await send_metrics_to_webhook(metrics)

return metrics

except Exception as e:
log_error(logger, f"Error getting metrics: {str(e)}")
await send_error_to_webhook(str(e), "get_metrics")
raise HTTPException(status_code=500, detail=str(e))
2 changes: 1 addition & 1 deletion browser.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ async def execute_task(self, task: str, config: Dict[str, Any], task_id: str) ->
async def onStepEnd(self: Agent):
self.save_history(history_path)

if run_history == True:
if run_history:
log_info(logger, f"TASK {task_id} run history {str(history)}")
with open(history_path, "w") as f:
json.dump(history, f)
Expand Down
3 changes: 2 additions & 1 deletion compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ services:
depends_on:
- db
# scale: 2
image: browseruser/browser-user:pr-4
image: browseruser/browser-user
environment:
- OLLAMA_HOST=${OLLAMA_HOST}
- ERROR_WEBHOOK_URL=http://localhost:3000
Expand Down Expand Up @@ -59,6 +59,7 @@ services:
- STATUS_WEBHOOK_URL=http://localhost:3000
- DEEPSEEK_API_KEY=${DEEPSEEK_API_KEY}
- OPENAI_API_KEY=${OPENAI_API_KEY}
- GOOGLE_API_KEY=${GOOGLE_API_KEY}
- DATABASE_URL=postgresql://postgres:${POSTGRES_PASSWORD}@db:5432/browser-use
- PYTHONUNBUFFERED=1
- BROWSER_USE_LOGGING_LEVEL=info
Expand Down
68 changes: 0 additions & 68 deletions crud.py

This file was deleted.

53 changes: 0 additions & 53 deletions database.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,25 +63,6 @@ class Task(Base):
started_at = Column(DateTime, nullable=True)
completed_at = Column(DateTime, nullable=True)

class Metric(Base):
__tablename__ = "metrics"

id = Column(Integer, primary_key=True, index=True)
name = Column(String, nullable=False)
value = Column(Float, nullable=False)
created_at = Column(DateTime, nullable=False)

class Session(Base):
__tablename__ = "sessions"

id = Column(Integer, primary_key=True, index=True)
task_id = Column(Integer, nullable=False)
start_time = Column(DateTime, nullable=False)
end_time = Column(DateTime, nullable=True)
status = Column(String, nullable=False)
error = Column(String, nullable=True)
created_at = Column(DateTime, nullable=False)

# Function to get database session
@contextmanager
def get_db():
Expand Down Expand Up @@ -170,40 +151,6 @@ def get_pending_tasks(db: Session, skip: int = 0, limit: int = 100) -> list[Task
}, exc_info=True)
raise

# Functions for Session
def get_sessions(db: Session, skip: int = 0, limit: int = 100) -> list[Session]:
"""List all sessions with pagination"""
try:
result = db.query(Session).offset(skip).limit(limit).all()
return result
except Exception as e:
log_error(logger, "Error listing sessions", {
"error": str(e)
}, exc_info=True)
raise

def get_session(db: Session, session_id: int) -> Session:
"""Get a session by ID"""
try:
return db.query(Session).filter(Session.id == session_id).first()
except Exception as e:
log_error(logger, "Error getting session", {
"session_id": session_id,
"error": str(e)
}, exc_info=True)
raise

def get_task_sessions(db: Session, task_id: int) -> list[Session]:
"""Get all sessions for a task"""
try:
result = db.query(Session).filter(Session.task_id == task_id).all()
return result
except Exception as e:
log_error(logger, "Error getting task sessions", {
"task_id": task_id,
"error": str(e)
}, exc_info=True)
raise

def delete_task(db: Session, task_id: int) -> bool:
"""Remove a task from database"""
Expand Down
128 changes: 0 additions & 128 deletions diagnose.py

This file was deleted.

Loading
Loading