o
    wi	                     @   s   d dl mZmZ d dlZd dlmZ G dd deZG dd dZejdd	 Z	ejd
d Z
dd Zdd Zdd Zdd Zdd Zdd ZdS )    )	MagicMockpatchN)
DeployBasec                   @   s,   e Zd Zdd Zdd Zdd Zdd Zd	S )
MockDeployablec                 C      d S N selfr   r   Z/home/ubuntu/sommelier/.venv/lib/python3.10/site-packages/tests/deploy/test_deploy_base.pydeploy      zMockDeployable.deployc                 C   r   r   r   r	   r   r   r   serve   r   zMockDeployable.servec                 C   r   r   r   r	   r   r   r   run   r   zMockDeployable.runc                 C   r   r   r   r	   r   r   r   stop    r   zMockDeployable.stopN)__name__
__module____qualname__r   r   r   r   r   r   r   r   r      s
    r   c                   @   s   e Zd ZdS )MockTritonDeployableN)r   r   r   r   r   r   r   r   $   s    r   c                   C   s   t  S r   )r   r   r   r   r   
mock_model(   s   r   c                 C   s   t d| ddddS )N
test_model   @  A  )triton_model_namemodelmax_batch_size	http_port	grpc_port)r   )r   r   r   r   deploy_base-   s   r   c                 C   s   | j dksJ | j|ksJ | jdksJ | jdksJ | jdks#J | jdks*J | jdu s1J | jdu s8J | jdu s?J d S )Nr   r   r   r   z0.0.0.0TF)	r   r   r   r   r   address
allow_grpc
allow_http	streaming)r   r   r   r   r   test_initialization_with_model8   s   r$   c                  C   sR   t d} t | j_tddd}|jdksJ W d    d S 1 s"w   Y  d S )Nznemo.deploy.deploy_base.ModelPTr   z	test.ckpt)r   checkpoint_path)r   r   restore_fromreturn_valuer   r%   )mock_model_ptr   r   r   r   #test_initialization_with_checkpointD   s   

"r)   c                  C   sJ   t t} tdd W d    n1 sw   Y  dt| jv s#J d S )Nr   )r   z2Either checkpoint_path or model should be provided)pytestraises	Exceptionr   strvalue)exc_infor   r   r   /test_initialization_without_model_or_checkpointN   s   r0   c                  C   s*   t d\} }| dksJ |dksJ d S )Nz nemo.models.test_model.TestModelznemo.models.test_model	TestModel)r   get_module_and_class)module
class_namer   r   r   test_get_module_and_classT   s   r5   c                 C   sH   t  | _tdt  |  du sJ W d    d S 1 sw   Y  d S )N)nemo.deploy.deploy_base.ITritonDeployableT)r   r   r   _is_model_deployable)r   r   r   r   test_is_model_deployable_validZ   s   "r8   c              	   C   s|   t  | _tdt+ tt}|   W d    n1 sw   Y  dt|j	v s,J W d    d S 1 s7w   Y  d S )Nr6   z&This model is not deployable to Triton)
r   r   r   r   r*   r+   r,   r7   r-   r.   )r   r/   r   r   r    test_is_model_deployable_invalid`   s   
"r9   )unittest.mockr   r   r*   nemo.deploy.deploy_baser   r   r   fixturer   r   r$   r)   r0   r5   r8   r9   r   r   r   r   <module>   s   



