Ë
    ?—Öj«  ã                   óP   — d dl Z d dlmZmZ d dlmZ  G d„ de«      Z eed«      Zy)é    N)ÚBackendDictÚBaseBackend)Úmock_randomc            
       ól   ‡ — e Zd ZdZdedefˆ fd„Zdededeeeeef   fd„Zded	edeeef   fd
„Z	ˆ xZ
S )ÚSageMakerRuntimeBackendz(Implementation of SageMakerRuntime APIs.Úregion_nameÚ
account_idc                 ó^   •— t         ‰| �  ||«       i | _        i | _        g | _        g | _        y )N)ÚsuperÚ__init__Úasync_resultsÚresultsÚresults_queueÚasync_results_queue)Úselfr   r	   Ú	__class__s      €úY/var/www/photos/backend/venv/lib/python3.12/site-packages/moto/sagemakerruntime/models.pyr   z SageMakerRuntimeBackend.__init__
   s1   ø€ Ü‰Ñ˜ jÔ1ØDFˆÔØJLˆŒØ>@ˆÔØ;=ˆÕ ó    Úendpoint_nameÚunique_reprÚreturnc                 ó:  — || j                   vri | j                   |<   || j                   |   v r| j                   |   |   S | j                  r,| j                  j                  d«      | j                   |   |<   nd| j                   |   |<   | j                   |   |   S )a  
        This call will return static data by default.

        You can use a dedicated API to override this, by configuring a queue of expected results.

        A request to `get_query_results` will take the first result from that queue. Subsequent requests using the same details will return the same result. Other requests using a different QueryExecutionId will take the next result from the queue, or return static data if the queue is empty.

        Configuring this queue by making an HTTP request to `/moto-api/static/sagemaker/endpoint-results`. An example invocation looks like this:

        .. sourcecode:: python

            expected_results = {
                "account_id": "123456789012",  # This is the default - can be omitted
                "region": "us-east-1",  # This is the default - can be omitted
                "results": [
                    {
                         "Body": "first body",
                         "ContentType": "text/xml",
                         "InvokedProductionVariant": "prod",
                         "CustomAttributes": "my_attr",
                     },
                    # other results as required
                ],
            }
            requests.post(
                "http://motoapi.amazonaws.com/moto-api/static/sagemaker/endpoint-results",
                json=expected_results,
            )

            client = boto3.client("sagemaker-runtime", region_name="us-east-1")
            details = client.invoke_endpoint(EndpointName="asdf", Body="qwer")

        r   )ÚbodyÚcontent_typeÚinvoked_production_variantÚcustom_attributes)r   r   Úpop)r   r   r   s      r   Úinvoke_endpointz'SageMakerRuntimeBackend.invoke_endpoint   sœ   € ðH  §¡Ñ,Ø*,ˆD�L‰L˜Ñ'Ø˜$Ÿ,™, }Ñ5Ñ5Ø—<‘< Ñ.¨{Ñ;Ð;Ø×ÒØ7;×7IÑ7I×7MÑ7MÈaÓ7PˆD�L‰L˜Ñ'¨Ò4ð8ˆD�L‰L˜Ñ'¨Ñ4ð �|‰|˜MÑ*¨;Ñ7Ð7r   Úinput_locationc                 ó  — || j                   vri | j                   |<   || j                   |   v r| j                   |   |   S | j                  r| j                  j                  d«      \  }}nb| j                  r=d}| j                  j                  d«      \  }}}}t	        j
                  ||||dœ«      }nd}t	        j
                  ddi«      }dt        j                  «       › �}	d}
d}|r|n|
}dd	lm	} || j                     | j                     }|j                  |	| j                  ¬
«       |j                  |	||j                  d«      ¬«       d|	› d|
› �d|	› d|› �f| j                   |   |<   | j                   |   |   S )a4  
        This call will return static data by default.

        You can use a dedicated API to override this, by configuring a queue of expected results.
        Subsequent requests using the same `InputLocation` will return the same result.
        Other requests using a different `InputLocation` will take the next result from the queue.
        Please note that for backward compatibility, if the async queue is empty, the sync queue will be used, if configured.

        Configuring this queue by making an HTTP request to `/moto-api/static/sagemaker/async-endpoint-results`.
        An example invocation looks like this:

        .. sourcecode:: python

            expected_results = {
                "account_id": "123456789012",  # This is the default - can be omitted
                "region": "us-east-1",  # This is the default - can be omitted
                "results": [
                    {
                        "data": json.dumps({"first": "output"}),
                    },
                    {
                        "is_failure": True,
                        "data": "second inference failed",
                    },
                    # other results as required
                ],
            }
            requests.post(
                "http://motoapi.amazonaws.com/moto-api/static/sagemaker/async-endpoint-results",
                json=expected_results,
            )

            client = boto3.client("sagemaker-runtime", region_name="us-east-1")
            details = client.invoke_endpoint_async(EndpointName="asdf", InputLocation="qwer")

        r   F)ÚBodyÚContentTypeÚInvokedProductionVariantÚCustomAttributesÚdefaultÚresponsezsagemaker-output-zresponse.jsonzfailure.json)Ús3_backends)r   zutf-8)Úvaluezs3://ú/)r   r   r   r   ÚjsonÚdumpsÚrandomÚuuid4Úmoto.s3.modelsr'   r	   Ú	partitionÚcreate_bucketr   Ú
put_objectÚencode)r   r   r   Ú
is_failureÚdatar   Ú_typeÚvariantÚattrsÚoutput_bucketÚoutput_locationÚfailure_locationÚresult_locationr'   Ú
s3_backends                  r   Úinvoke_endpoint_asyncz-SageMakerRuntimeBackend.invoke_endpoint_asyncD   s¨  € ðN  × 2Ñ 2Ñ2Ø02ˆD×Ñ˜}Ñ-Ø˜T×/Ñ/°Ñ>Ñ>Ø×%Ñ% mÑ4°^ÑDÐDØ×#Ò#Ø#×7Ñ7×;Ñ;¸AÓ>ÑˆJ™Ø×ÒØˆJØ*.×*<Ñ*<×*@Ñ*@ÀÓ*CÑ'ˆD�%˜ %Ü—:‘:à Ø#(Ø07Ø(-ñ	ó‰Dð ˆJÜ—:‘:˜y¨*Ð5Ó6ˆDà+¬F¯L©L«NÐ+;Ð<ˆØ)ˆØ)ÐÙ.8Ñ*¸oˆÝ.à  §¡Ñ1°$·.±.ÑAˆ
Ø× Ñ  ¸D×<LÑ<LÐ ÔMØ×ÑØ˜?°$·+±+¸gÓ2Fð 	ô 	
ð
 �M�? ! OÐ#4Ð5Ø�M�? !Ð$4Ð#5Ð6ð=
ˆ×Ñ˜=Ñ)¨.Ñ9ð ×!Ñ! -Ñ0°Ñ@Ð@r   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__Ústrr   ÚbytesÚtupler   r=   Ú__classcell__)r   s   @r   r   r      sr   ø„ Ù2ð> Cð >°Sõ >ð18Ø ð18Ø/4ð18à	ˆs�C˜˜cÐ!Ñ	"ó18ðfLAØ ðLAØ25ðLAà	ˆs�Cˆx‰÷LAr   r   zsagemaker-runtime)	r*   Úmoto.core.base_backendr   r   Úmoto.moto_api._internalr   r,   r   Úsagemakerruntime_backends© r   r   ú<module>rJ      s0   ðÛ ç ;Ý 9ôIA˜kô IAñX (Ð(?ÐATÓUÑ r   