"""Pathway loading -- from config directories."""

from __future__ import annotations

import logging
from typing import Any

logger = logging.getLogger(__name__)


async def load_pathways_from_config(
    directories: list[str],
    pathway_service: Any,
    auto_deploy: list[str] | None = None,
) -> int:
    """Load pathways from configured directories."""
    if not pathway_service:
        logger.warning(
            "PathwayService not available - cannot load pathways from config"
        )
        return 0

    try:
        return await pathway_service.load_from_directories(
            directories, source="config"
        )
    except Exception as e:
        logger.exception("Failed to load pathways from config: %s", e)
        return 0
