o
    i                     @   sh   d dl mZ d dlmZ ddlmZmZ ddlmZ ddl	m
Z
 ded	ee fd
dZd	efddZdS )    )Optional)	APIRouter   )RouteConfigcreate_router)logger   )get_lora_route_confighandler_typereturnc                 C   s@   | dkrt ddddgddS | dkrt d	d
ddgddS t| S )aL  Get route configuration for SageMaker handler types.

    This resolver handles both core SageMaker routes (/ping, /invocations) and
    LoRA-specific routes (/adapters, etc.). It serves as a unified entry point
    for all SageMaker routing configuration.

    Args:
        handler_type: The handler type identifier (e.g., 'ping', 'invoke',
                     'register_adapter', 'unregister_adapter')

    Returns:
        RouteConfig: The route configuration if the handler type has a route
        None: If the handler type doesn't have a route (e.g., transform-only handlers)
    pingz/pingGEThealth	sagemakerzHealth check endpoint)pathmethodtagssummaryinvokez/invocationsPOST	inferencezModel inference endpoint)r   r	   )r
    r   p/home/ubuntu/.local/lib/python3.10/site-packages/model_hosting_container_standards/sagemaker/sagemaker_router.pyget_sagemaker_route_config   s   r   c                  C   s4   t d ttdgd} t dt| j d | S )a  Create a FastAPI router with all registered SageMaker handlers mounted.

    This convenience function creates an APIRouter and automatically mounts all
    registered SageMaker handlers using the unified route resolver. It provides
    a complete SageMaker-compatible routing solution out of the box.

    Supported Routes:
        - Core SageMaker endpoints: /ping (health check), /invocations (inference)
        - LoRA adapter management: /adapters (list/register), /adapters/{name} (unregister)
        - Any additional SageMaker-specific routes registered via decorators

    The router uses a unified route resolver that handles both core SageMaker
    routes and LoRA-specific routes, providing a single entry point for all
    SageMaker routing configuration.

    Alternative Usage:
        For more control over router configuration or to mount handlers to an
        existing router, use the generic mount_handlers function:

        ```python
        from model_hosting_container_standards.common.fastapi.routing import mount_handlers
        from model_hosting_container_standards.sagemaker.sagemaker_router import get_sagemaker_route_config

        # Mount to existing router
        mount_handlers(my_router, route_resolver=get_sagemaker_route_config)
        ```

    Returns:
        APIRouter: Configured router with SageMaker handlers mounted and tagged
                  with ["sagemaker"] for OpenAPI documentation

    Example:
        ```python
        from fastapi import FastAPI
        from model_hosting_container_standards.sagemaker import create_sagemaker_router

        app = FastAPI()
        sagemaker_router = create_sagemaker_router()
        app.include_router(sagemaker_router)
        ```
    z5Creating SageMaker router with unified route resolverr   )route_resolverr   z+SageMaker router created successfully with z routes)r   infor   r   lenroutes)routerr   r   r   create_sagemaker_router1   s   
*r   N)typingr   fastapir   common.fastapi.routingr   r   logging_configr   lora.routesr	   strr   r   r   r   r   r   <module>   s    $