Ë
    ö%9jŠ�  ã                   ó"  — d Z ddlZddlZddlZddlZddlmZ ddlZddlZddl	Z	ddl	m
Z
 ddl	mZ ddl	mZ 	 ddl	mZ dZ	 ddlZdZd
ZdZ ej*                  d«      Z ej*                  d«      Z ej*                  d«      Z ej*                  d«      Z ej*                  d«      Z ej*                  d«      Z ej*                  d«      Zd„ Zd:d„Zd:d„Zd:d„Z d:d„Z!d:d„Z"d;d„Z#d:d„Z$ G d„ d«      Z% G d„ d«      Z& G d„ de&«      Z' G d „ d!«      Z( G d"„ d#«      Z) G d$„ d%e(«      Z* G d&„ d'e(«      Z+ G d(„ d)«      Z, G d*„ d+«      Z-d,„ Z.d:d-„Z/d.„ Z0d/„ Z1d0„ Z2d1„ Z3d2„ Z4d3„ Z5d4„ Z6d5„ Z7d6„ Z8d7„ Z9 G d8„ d9«      Z:y# e$ r d	ZY �Œ?w xY w# e$ r d	ZY �ŒFw xY w)<z˜Firebase ML module.

This module contains functions for creating, updating, getting, listing,
deleting, publishing and unpublishing Firebase ML models.
é    N)Úparse)Ú_http_client)Ú_utils)Ú
exceptions)ÚstorageTFÚ_mléd   z^[A-Za-z0-9_-]{1,60}$z^[A-Za-z0-9_-]{1,32}$z;^gs://(?P<bucket_name>[a-z0-9_.-]{3,63})/(?P<blob_name>.+)$zm^projects/(?P<project_id>[a-z0-9-]{6,30})/locations/(?P<location_id>[^/]+)/models/(?P<model_id>[A-Za-z0-9]+)$zS^projects/(?P<project_id>[a-z0-9-]{6,30})/models/(?P<model_id>[A-Za-z0-9_-]{1,60})$z;^projects/(?P<project_id>[a-z0-9-]{6,30})/operations/[^/]+$c                 ó@   — t        j                  | t        t        «      S )a   Returns an _MLService instance for an App.

    Args:
      app: A Firebase App instance (or None to use the default App).

    Returns:
      _MLService: An _MLService for the specified App instance.

    Raises:
      ValueError: If the app argument is invalid.
    )r   Úget_app_serviceÚ_ML_ATTRIBUTEÚ
_MLService©Úapps    úM/var/www/html/truck-me/venv/lib/python3.12/site-packages/firebase_admin/ml.pyÚ_get_ml_servicer   B   s   € ô ×!Ñ! #¤}´jÓAÐAó    c                 ód   — t        |«      }t        j                  |j                  | «      |¬«      S )zõCreates a model in the current Firebase project.

    Args:
        model: An ml.Model to create.
        app: A Firebase app instance (or None to use the default app).

    Returns:
        Model: The model that was created in Firebase ML.
    r   )r   ÚModelÚ	from_dictÚcreate_model©Úmodelr   Ú
ml_services      r   r   r   Q   ó,   € ô ! Ó%€JÜ�?‰?˜:×2Ñ2°5Ó9¸sˆ?ÓCÐCr   c                 ód   — t        |«      }t        j                  |j                  | «      |¬«      S )z×Updates a model's metadata or model file.

    Args:
        model: The ml.Model to update.
        app: A Firebase app instance (or None to use the default app).

    Returns:
        Model: The updated model.
    r   )r   r   r   Úupdate_modelr   s      r   r   r   _   r   r   c                 óh   — t        |«      }t        j                  |j                  | d¬«      |¬«      S )a  Publishes a Firebase ML model.

    A published model can be downloaded to client apps.

    Args:
        model_id: The id of the model to publish.
        app: A Firebase app instance (or None to use the default app).

    Returns:
        Model: The published model.
    T©Úpublishr   ©r   r   r   Úset_published©Úmodel_idr   r   s      r   Úpublish_modelr$   m   s2   € ô ! Ó%€JÜ�?‰?˜:×3Ñ3°HÀdÐ3ÓKÐQTˆ?ÓUÐUr   c                 óh   — t        |«      }t        j                  |j                  | d¬«      |¬«      S )zßUnpublishes a Firebase ML model.

    Args:
        model_id: The id of the model to unpublish.
        app: A Firebase app instance (or None to use the default app).

    Returns:
        Model: The unpublished model.
    Fr   r   r    r"   s      r   Úunpublish_modelr&   }   s2   € ô ! Ó%€JÜ�?‰?˜:×3Ñ3°HÀeÐ3ÓLÐRUˆ?ÓVÐVr   c                 ód   — t        |«      }t        j                  |j                  | «      |¬«      S )zÝGets the model specified by the given ID.

    Args:
        model_id: The id of the model to get.
        app: A Firebase app instance (or None to use the default app).

    Returns:
     Model: The requested model.
    r   )r   r   r   Ú	get_modelr"   s      r   r(   r(   ‹   s,   € ô ! Ó%€JÜ�?‰?˜:×/Ñ/°Ó9¸sˆ?ÓCÐCr   c                 óL   — t        |«      }t        |j                  | |||¬«      S )a0  Lists the current project's models.

    Args:
        list_filter: a list filter string such as ``tags:'tag_1'``. None will return all models.
        page_size: A number between 1 and 100 inclusive that specifies the maximum
            number of models to return per page. None for default.
        page_token: A next page token returned from a previous page of results. None
            for first page of results.
        app: A Firebase app instance (or None to use the default app).

    Returns:
        ListModelsPage: A (filtered) list of models.
    r   )r   ÚListModelsPageÚlist_models)Úlist_filterÚ	page_sizeÚ
page_tokenr   r   s        r   r+   r+   ™   s.   € ô ! Ó%€JÜØ×Ñ ¨Y¸
ÈôMð Mr   c                 ó<   — t        |«      }|j                  | «       y)zºDeletes a model from the current project.

    Args:
        model_id: The id of the model you wish to delete.
        app: A Firebase app instance (or None to use the default app).
    N)r   Údelete_modelr"   s      r   r0   r0   ¬   s   € ô ! Ó%€JØ×Ñ˜HÕ%r   c                   óx  — e Zd ZdZdd„Zedd„«       Zd„ Zd„ Zd„ Z	e
d„ «       Ze
d	„ «       Zej                  d
„ «       Zed„ «       Ze
d„ «       Ze
d„ «       Ze
d„ «       Ze
d„ «       Ze
d„ «       Ze
d„ «       Ze
d„ «       Zej                  d„ «       Ze
d„ «       Zdd„Ze
d„ «       Zej                  d„ «       Zdd„Zy)r   aI  A Firebase ML Model object.

    Args:
        display_name: The display name of your model - used to identify your model in code.
        tags: Optional list of strings associated with your model. Can be used in list queries.
        model_format: A subclass of ModelFormat. (e.g. TFLiteFormat) Specifies the model details.
    Nc                 óf   — d | _         i | _        d | _        |�|| _        |�|| _        |�|| _        y y ©N)Ú_appÚ_dataÚ_model_formatÚdisplay_nameÚtagsÚmodel_format)Úselfr7   r8   r9   s       r   Ú__init__zModel.__init__¿   sF   € ØˆŒ	ØˆŒ
Ø!ˆÔàÐ#Ø ,ˆDÔØÐØˆDŒIØÐ#Ø ,ˆDÕð $r   c                 óÊ   — t        |«      }d}|j                  dd«      }|j                  dd«       |rt        j                  |«      }t	        |¬«      }||_        ||_        |S )ú-Create an instance of the object from a dict.NÚtfliteModelú@type©r9   )ÚdictÚpopÚTFLiteFormatr   r   r5   r4   )ÚclsÚdatar   Ú	data_copyÚtflite_formatÚtflite_format_datar   s          r   r   zModel.from_dictË   sb   € ô ˜“Jˆ	ØˆØ&Ÿ]™]¨=¸$Ó?ÐØ�‰�g˜tÔ$ÙÜ(×2Ñ2Ð3EÓFˆMÜ =Ô1ˆØˆŒØˆŒ
Øˆr   c                 ór   — t         j                  |«      }|j                  | _        |j                  | _        y r3   )r   r   r9   r5   )r:   rE   Úcopys      r   Ú_update_from_dictzModel._update_from_dictÙ   s)   € Ü�‰˜tÓ$ˆØ ×-Ñ-ˆÔØ—Z‘Zˆ�
r   c                 ó˜   — t        || j                  «      r4| j                  |j                  k(  xr | j                  |j                  k(  S y©NF)Ú
isinstanceÚ	__class__r5   r6   ©r:   Úothers     r   Ú__eq__zModel.__eq__Þ   ó<   € Ü�e˜TŸ^™^Ô,à—:‘: §¡Ñ,ÒZ°×1CÑ1CÀu×GZÑGZÑ1ZÐZØr   c                 ó&   — | j                  |«       S r3   ©rR   rP   s     r   Ú__ne__zModel.__ne__ä   ó   € Ø—;‘;˜uÓ%Ð%Ð%r   c                 óŒ   — | j                   j                  d«      syt        | j                   j                  d«      «      \  }}|S )z&The model's ID, unique to the project.ÚnameN)r5   ÚgetÚ_validate_and_parse_name)r:   Ú_r#   s      r   r#   zModel.model_idç   s7   € ð �z‰z�~‰~˜fÔ%ØÜ.¨t¯z©z¯~©~¸fÓ/EÓF‰ˆˆ8Øˆr   c                 ó8   — | j                   j                  d«      S )zaThe model's display name, used to refer to the model in code and in
        the Firebase console.ÚdisplayName©r5   rZ   ©r:   s    r   r7   zModel.display_nameï   s   € ð �z‰z�~‰~˜mÓ,Ð,r   c                 ó6   — t        |«      | j                  d<   | S )Nr^   )Ú_validate_display_namer5   )r:   r7   s     r   r7   zModel.display_nameõ   s   € ä$:¸<Ó$Hˆ�
‰
�=Ñ!Øˆr   c                 óÌ   — | sy d}t         j                   j                  d«      }t         j                   j                  | |«      }t        ||z
  j	                  «       dz  «      }|S )Nz%Y-%m-%dT%H:%M:%S.%fZr   iè  )ÚdatetimeÚutcfromtimestampÚstrptimeÚintÚtotal_seconds)Údate_stringÚ
format_strÚepochÚdatetime_objectÚmilliss        r   Ú_convert_to_milliszModel._convert_to_millisú   s]   € áØØ,ˆ
Ü×!Ñ!×2Ñ2°1Ó5ˆÜ"×+Ñ+×4Ñ4°[À*ÓMˆÜ�o¨Ñ-×<Ñ<Ó>ÀÑEÓFˆØˆr   c                 ó`   — t         j                  | j                  j                  dd«      «      S )zThe time the model was created.Ú
createTimeN©r   rn   r5   rZ   r`   s    r   Úcreate_timezModel.create_time  ó$   € ô ×'Ñ'¨¯
©
¯©°|ÀTÓ(JÓKÐKr   c                 ó`   — t         j                  | j                  j                  dd«      «      S )z$The time the model was last updated.Ú
updateTimeNrq   r`   s    r   Úupdate_timezModel.update_time	  rs   r   c                 óx   — | j                   j                  di «      j                  di «      j                  d«      S )zValidation error message.ÚstateÚvalidationErrorÚmessager_   r`   s    r   Úvalidation_errorzModel.validation_error  s2   € ð �z‰z�~‰~˜g rÓ*×.Ñ.Ð/@À"ÓE×IÑIÈ)ÓTÐTr   c                 ój   — t        | j                  j                  di «      j                  d«      «      S )zMTrue if the model is published and available for clients to
        download.rx   Ú	published)Úboolr5   rZ   r`   s    r   r}   zModel.published  s)   € ô �D—J‘J—N‘N 7¨BÓ/×3Ñ3°KÓ@ÓAÐAr   c                 ó8   — | j                   j                  d«      S )z,The entity tag (ETag) of the model resource.Úetagr_   r`   s    r   r€   z
Model.etag  ó   € ð �z‰z�~‰~˜fÓ%Ð%r   c                 ó8   — | j                   j                  d«      S )z SHA256 hash of the model binary.Ú	modelHashr_   r`   s    r   Ú
model_hashzModel.model_hash  ó   € ð �z‰z�~‰~˜kÓ*Ð*r   c                 ó8   — | j                   j                  d«      S )z.Tag strings, used for filtering query results.r8   r_   r`   s    r   r8   z
Model.tags#  r�   r   c                 ó6   — t        |«      | j                  d<   | S )Nr8   )Ú_validate_tagsr5   )r:   r8   s     r   r8   z
Model.tags(  s   € ä+¨DÓ1ˆ�
‰
�6ÑØˆr   c                 óœ   — t        | j                  j                  d«      xr' t        | j                  j                  d«      «      dkD  «      S )z:True if the Model object is locked by an active operation.ÚactiveOperationsr   )r~   r5   rZ   Úlenr`   s    r   ÚlockedzModel.locked-  sD   € ô �D—J‘J—N‘NÐ#5Ó6ò @Ü˜Ÿ
™
Ÿ™Ð'9Ó:Ó;¸aÑ?óAð 	Ar   c                 ó
  — | j                   syt        | j                  «      }| j                  j	                  d«      d   j	                  d«      }|j                  |j                  |«      d|¬«      }| j                  |«       y)aQ  Waits for the model to be unlocked. (All active operations complete)

        Args:
            max_time_seconds: The maximum number of seconds to wait for the model to unlock.
                (None for no limit)

        Raises:
            exceptions.DeadlineExceeded: If max_time_seconds passed and the model is still locked.
        NrŠ   r   rY   T)Úwait_for_operationÚmax_time_seconds)rŒ   r   r4   r5   rZ   Úhandle_operationÚget_operationrK   )r:   r�   r   Úop_nameÚ
model_dicts        r   Úwait_for_unlockedzModel.wait_for_unlocked3  sx   € ð �{Š{ØÜ$ T§Y¡YÓ/ˆ
Ø—*‘*—.‘.Ð!3Ó4°QÑ7×;Ñ;¸FÓCˆØ×0Ñ0Ø×$Ñ$ WÓ-Ø#Ø-ð 1ó /ˆ
ð 	×Ñ˜zÕ*r   c                 ó   — | j                   S )zeThe model's ``ModelFormat`` object, which represents the model's
        format and storage location.)r6   r`   s    r   r9   zModel.model_formatG  s   € ð ×!Ñ!Ð!r   c                 ó.   — |�t        |«       || _        | S r3   )Ú_validate_model_formatr6   )r:   r9   s     r   r9   zModel.model_formatM  s   € àÐ#Ü" <Ô0Ø)ˆÔØˆr   c                 óž   — t        | j                  «      }| j                  r+|j                  | j                  j	                  |¬«      «       |S )ú4Returns a serializable representation of the object.©Ú
for_upload)rA   r5   r6   ÚupdateÚas_dict©r:   r›   rJ   s      r   r�   zModel.as_dictT  s>   € ä�D—J‘JÓˆØ×ÒØ�K‰K˜×*Ñ*×2Ñ2¸jÐ2ÓIÔJØˆr   )NNNr3   ©F)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r;   Úclassmethodr   rK   rR   rV   Úpropertyr#   r7   ÚsetterÚstaticmethodrn   rr   rv   r{   r}   r€   r„   r8   rŒ   r”   r9   r�   © r   r   r   r   ·   s  „ ñó
-ð òó ðò ò
ò&ð ñó ðð ñ-ó ð-ð
 ×Ññó ðð ñó ðð ñLó ðLð ñLó ðLð ñUó ðUð ñBó ðBð
 ñ&ó ð&ð ñ+ó ð+ð ñ&ó ð&ð 
‡[�[ñó ðð ñAó ðAó
+ð( ñ"ó ð"ð
 ×Ññó ðôr   r   c                   ó   — e Zd ZdZdd„Zy)ÚModelFormatz?Abstract base class representing a Model Format such as TFLite.c                 ó   — t         ‚©r™   ©ÚNotImplementedError©r:   r›   s     r   r�   zModelFormat.as_dict^  ó   € ä!Ð!r   NrŸ   ©r    r¡   r¢   r£   r�   r¨   r   r   rª   rª   \  s
   „ ÙIô"r   rª   c                   ó�   — e Zd ZdZdd„Zed„ «       Zd„ Zd„ Ze	d„ «       Z
ed„ «       Zej                  d	„ «       Zed
„ «       Zdd„Zy)rC   z™Model format representing a TFLite model.

    Args:
        model_source: A TFLiteModelSource sub class. Specifies the details of the model source.
    Nc                 ó4   — i | _         d | _        |�|| _        y y r3   )r5   Ú_model_sourceÚmodel_source©r:   rµ   s     r   r;   zTFLiteFormat.__init__i  s$   € ØˆŒ
Ø!ˆÔàÐ#Ø ,ˆDÕð $r   c                 ó`   — t        |«      }t        | j                  |«      ¬«      }||_        |S )r=   )rµ   )rA   rC   Ú_init_model_sourcer5   )rD   rE   rF   rG   s       r   r   zTFLiteFormat.from_dictp  s0   € ô ˜“Jˆ	Ü$°#×2HÑ2HÈÓ2SÔTˆØ'ˆÔØÐr   c                 ó˜   — t        || j                  «      r4| j                  |j                  k(  xr | j                  |j                  k(  S yrM   )rN   rO   r5   r´   rP   s     r   rR   zTFLiteFormat.__eq__x  rS   r   c                 ó&   — | j                  |«       S r3   rU   rP   s     r   rV   zTFLiteFormat.__ne__~  rW   r   c                 ó¸   — | j                  dd«      }|rt        |¬«      S | j                  dd«      }|r&t        j                  dt        «       t        |¬«      S y)zInitialize the ML model source.ÚgcsTfliteUriN)Úgcs_tflite_uriÚautomlModelúQAutoML model support is deprecated and will be removed in the next major version.)Úauto_ml_model)rB   ÚTFLiteGCSModelSourceÚwarningsÚwarnÚDeprecationWarningÚTFLiteAutoMlSource)rE   r½   rÀ   s      r   r¸   zTFLiteFormat._init_model_source�  sX   € ð Ÿ™ .°$Ó7ˆÙÜ'°~ÔFÐFØŸ™ °Ó5ˆÙÜ�M‰Mð +Ü,>ô@ä%°MÔBÐBØr   c                 ó   — | j                   S )zThe TF Lite model's location.)r´   r`   s    r   rµ   zTFLiteFormat.model_sourceŽ  s   € ð ×!Ñ!Ð!r   c                 óL   — |�t        |t        «      st        d«      ‚|| _        y )Nz0Model source must be a TFLiteModelSource object.)rN   ÚTFLiteModelSourceÚ	TypeErrorr´   r¶   s     r   rµ   zTFLiteFormat.model_source“  s'   € àÐ#Ü˜lÔ,=Ô>ÜÐ RÓSÐSØ)ˆÕr   c                 ó8   — | j                   j                  d«      S )z'The size in bytes of the TF Lite model.Ú	sizeBytesr_   r`   s    r   Ú
size_byteszTFLiteFormat.size_bytesš  r…   r   c                 ó¢   — t        | j                  «      }| j                  r+|j                  | j                  j	                  |¬«      «       d|iS )r™   rš   r>   )rA   r5   r´   rœ   r�   rž   s      r   r�   zTFLiteFormat.as_dictŸ  sD   € ä�D—J‘JÓˆØ×ÒØ�K‰K˜×*Ñ*×2Ñ2¸jÐ2ÓIÔJØ˜tÐ$Ð$r   r3   rŸ   )r    r¡   r¢   r£   r;   r¤   r   rR   rV   r§   r¸   r¥   rµ   r¦   rÌ   r�   r¨   r   r   rC   rC   c  s…   „ ñó
-ð ñó ðòò&ð ñ
ó ð
ð ñ"ó ð"ð ×Ññ*ó ð*ð ñ+ó ð+ô%r   rC   c                   ó   — e Zd ZdZdd„Zy)rÈ   zIAbstract base class representing a model source for TFLite format models.c                 ó   — t         ‚r¬   r­   r¯   s     r   r�   zTFLiteModelSource.as_dict©  r°   r   NrŸ   r±   r¨   r   r   rÈ   rÈ   §  s
   „ ÙSô"r   rÈ   c                   óX   — e Zd ZdZdZdZed„ «       Zed„ «       Zed„ «       Z	ed„ «       Z
y)	Ú_CloudStorageClientzCloud Storage helper classzgs://{0}/{1}zFirebase/ML/Models/{0}c                  ó&   — t         st        d«      ‚y )NznFailed to import the Cloud Storage library for Python. Make sure to install the "google-cloud-storage" module.)Ú_GCS_ENABLEDÚImportErrorr¨   r   r   Ú_assert_gcs_enabledz'_CloudStorageClient._assert_gcs_enabled´  s   € åÜð Nó Oð Oð r   c                 óŠ   — t         j                  | «      }|st        d«      ‚|j                  d«      |j                  d«      fS )Nú!GCS TFLite URI format is invalid.Úbucket_nameÚ	blob_name)Ú_GCS_TFLITE_URI_PATTERNÚmatchÚ
ValueErrorÚgroup)ÚuriÚmatchers     r   Ú_parse_gcs_tflite_uriz)_CloudStorageClient._parse_gcs_tflite_uriº  s@   € ô *×/Ñ/°Ó4ˆÙÜÐ@ÓAÐAØ�}‰}˜]Ó+¨W¯]©]¸;Ó-GÐGÐGr   c                 ól  — t         j                  «        t        j                  j	                  |«      }t        j                  | |¬«      }t         j                  j                  |«      }|j                  |«      }|j                  |«       t         j                  j                  |j                  |«      S )z4Upload a model file to the specified Storage bucket.r   )rÑ   rÕ   ÚosÚpathÚbasenamer   ÚbucketÚ	BLOB_NAMEÚformatÚblobÚupload_from_filenameÚGCS_URIrY   )rØ   Úmodel_file_namer   Ú	file_namerå   rÙ   rè   s          r   Úuploadz_CloudStorageClient.uploadÃ  sƒ   € ô 	×/Ñ/Ô1ä—G‘G×$Ñ$ _Ó5ˆ	Ü—‘ °Ô5ˆÜ'×1Ñ1×8Ñ8¸ÓCˆ	Ø�{‰{˜9Ó%ˆØ×!Ñ! /Ô2Ü"×*Ñ*×1Ñ1°&·+±+¸yÓIÐIr   c                 óú   — t         j                  «        t         j                  | «      \  }}t        j                  ||¬«      }|j                  |«      }|j                  dt        j                  d¬«      d¬«      S )zHMakes the gcs_tflite_uri readable for GET for 10 minutes via signed_uri.r   Úv4é
   )ÚminutesÚGET)ÚversionÚ
expirationÚmethod)	rÑ   rÕ   rà   r   rå   rè   Úgenerate_signed_urlrd   Ú	timedelta)r½   r   rØ   rÙ   rå   rè   s         r   Úsign_uriz_CloudStorageClient.sign_uriÏ  so   € ô 	×/Ñ/Ô1Ü!4×!JÑ!JÈ>Ó!ZÑˆ�YÜ—‘ °Ô5ˆØ�{‰{˜9Ó%ˆØ×'Ñ'ØÜ×)Ñ)°"Ô5Øð (ó 
ð 	
r   N)r    r¡   r¢   r£   rê   ræ   r§   rÕ   rà   rí   rø   r¨   r   r   rÑ   rÑ   ®  sc   „ Ù$à€GØ(€IàñOó ðOð
 ñHó ðHð ñ	Jó ð	Jð ñ

ó ñ

r   rÑ   c                   óâ   — e Zd ZdZ e«       Zdd„Zd„ Zd„ Ze	dd„«       Z
ed„ «       Zed„ «       Zed	„ «       Ze		 	 dd
„«       Ze		 	 dd„«       Zed„ «       Zej&                  d„ «       Zd„ Zdd„Zy)rÁ   zCTFLite model source representing a tflite model file stored in GCS.Nc                 ó2   — || _         t        |«      | _        y r3   )r4   Ú_validate_gcs_tflite_uriÚ_gcs_tflite_uri)r:   r½   r   s      r   r;   zTFLiteGCSModelSource.__init__â  s   € ØˆŒ	Ü7¸ÓGˆÕr   c                 ób   — t        || j                  «      r| j                  |j                  k(  S yrM   )rN   rO   rü   rP   s     r   rR   zTFLiteGCSModelSource.__eq__æ  s*   € Ü�e˜TŸ^™^Ô,Ø×'Ñ'¨5×+@Ñ+@Ñ@Ð@Ør   c                 ó&   — | j                  |«       S r3   rU   rP   s     r   rV   zTFLiteGCSModelSource.__ne__ë  rW   r   c                 ó^   — t         j                  j                  |||«      }t        ||¬«      S )a  Uploads the model file to an existing Google Cloud Storage bucket.

        Args:
            model_file_name: The name of the model file.
            bucket_name: The name of an existing bucket. None to use the default bucket configured
                in the app.
            app: A Firebase app instance (or None to use the default app).

        Returns:
            TFLiteGCSModelSource: The source created from the model_file

        Raises:
            ImportError: If the Cloud Storage Library has not been installed.
        )r½   r   )rÁ   Ú_STORAGE_CLIENTrí   )rD   rë   rØ   r   Úgcs_uris        r   Úfrom_tflite_model_filez+TFLiteGCSModelSource.from_tflite_model_fileî  s,   € ô  '×6Ñ6×=Ñ=¸kÈ?Ð\_Ó`ˆÜ#°7ÀÔDÐDr   c                  ó0  — t         st        d«      ‚t        j                  j                  j                  d«      s\t        j                  j                  j                  d«      s2t        dj                  t        j                  j                  «      «      ‚y y )Nz_Failed to import the tensorflow library for Python. Make sure to install the tensorflow module.ú1.z2.z5Expected tensorflow version 1.x or 2.x, but found {0})Ú_TF_ENABLEDrÔ   Útfró   ÚVERSIONÚ
startswithrç   r¨   r   r   Ú_assert_tf_enabledz'TFLiteGCSModelSource._assert_tf_enabled  sw   € åÜð Bó Cð Cä�z‰z×!Ñ!×,Ñ,¨TÔ2¼2¿:¹:×;MÑ;M×;XÑ;XÐY]Ô;^ÜÐUß%™v¤b§j¡j×&8Ñ&8Ó9ó;ð ;ð <_Ð2r   c                 ót   — t         j                  j                  j                  | «      }|j	                  «       S r3   )r  ÚliteÚTFLiteConverterÚfrom_saved_modelÚconvert)Úsaved_model_dirÚ	converters     r   Ú_tf_convert_from_saved_modelz1TFLiteGCSModelSource._tf_convert_from_saved_model
  s-   € ô —G‘G×+Ñ+×<Ñ<¸_ÓMˆ	Ø× Ñ Ó"Ð"r   c                 ó�  — t         j                  j                  j                  d«      red}t         j                  j
                  j                  | |«       t         j                  j                  j                  |«      }|j                  «       S t         j                  j                  j                  | «      }|j                  «       S )z4Converts the given Keras model into a TF Lite model.r  zfirebase_keras_model.h5)r  ró   r  r  ÚkerasÚmodelsÚ
save_modelr  r  Úfrom_keras_model_fileÚfrom_keras_modelr  )Úkeras_modelÚ
keras_filer  s      r   Ú_tf_convert_from_keras_modelz1TFLiteGCSModelSource._tf_convert_from_keras_model  s�   € ô �:‰:×Ñ×(Ñ(¨Ô.Ø2ˆJÜ�H‰H�O‰O×&Ñ& {°JÔ?ÜŸ™×/Ñ/×EÑEÀjÓQˆIð × Ñ Ó"Ð"ô Ÿ™×/Ñ/×@Ñ@ÀÓMˆIà× Ñ Ó"Ð"r   c                 óæ   — t         j                  «        t         j                  |«      }t        |d«      5 }|j	                  |«       ddd«       t         j                  |||«      S # 1 sw Y   Œ xY w)a§  Creates a Tensor Flow Lite model from the saved model, and uploads the model to GCS.

        Args:
            saved_model_dir: The saved model directory.
            model_file_name: The name that the tflite model will be saved as in Cloud Storage.
            bucket_name: The name of an existing bucket. None to use the default bucket configured
                in the app.
            app: Optional. A Firebase app instance (or None to use the default app)

        Returns:
            TFLiteGCSModelSource: The source created from the saved_model_dir

        Raises:
            ImportError: If the Tensor Flow or Cloud Storage Libraries have not been installed.
        ÚwbN)rÁ   r	  r  ÚopenÚwriter  )rD   r  rë   rØ   r   Útflite_modelÚ
model_files          r   r  z%TFLiteGCSModelSource.from_saved_model  se   € ô$ 	×/Ñ/Ô1Ü+×HÑHÈÓYˆÜ�/ 4Ó(ð 	+¨JØ×Ñ˜\Ô*÷	+ä#×:Ñ:¸?ÈKÐY\Ó]Ð]÷	+ð 	+úó   ¶A'Á'A0c                 óæ   — t         j                  «        t         j                  |«      }t        |d«      5 }|j	                  |«       ddd«       t         j                  |||«      S # 1 sw Y   Œ xY w)a–  Creates a Tensor Flow Lite model from the keras model, and uploads the model to GCS.

        Args:
            keras_model: A tf.keras model.
            model_file_name: The name that the tflite model will be saved as in Cloud Storage.
            bucket_name: The name of an existing bucket. None to use the default bucket configured
                in the app.
            app: Optional. A Firebase app instance (or None to use the default app)

        Returns:
            TFLiteGCSModelSource: The source created from the keras_model

        Raises:
            ImportError: If the Tensor Flow or Cloud Storage Libraries have not been installed.
        r  N)rÁ   r	  r  r  r  r  )rD   r  rë   rØ   r   r  r   s          r   r  z%TFLiteGCSModelSource.from_keras_model5  se   € ô$ 	×/Ñ/Ô1Ü+×HÑHÈÓUˆÜ�/ 4Ó(ð 	+¨JØ×Ñ˜\Ô*÷	+ä#×:Ñ:¸?ÈKÐY\Ó]Ð]÷	+ð 	+úr!  c                 ó   — | j                   S )z'URI of the model file in Cloud Storage.)rü   r`   s    r   r½   z#TFLiteGCSModelSource.gcs_tflite_uriM  s   € ð ×#Ñ#Ð#r   c                 ó$   — t        |«      | _        y r3   )rû   rü   )r:   r½   s     r   r½   z#TFLiteGCSModelSource.gcs_tflite_uriR  s   € ä7¸ÓGˆÕr   c                 ój   — t         j                  j                  | j                  | j                  «      S )zQSigns the GCS uri, so the model file can be uploaded to Firebase ML and verified.)rÁ   r   rø   rü   r4   r`   s    r   Ú_get_signed_gcs_tflite_uriz/TFLiteGCSModelSource._get_signed_gcs_tflite_uriV  s(   € ä#×3Ñ3×<Ñ<¸T×=QÑ=QÐSW×S\ÑS\Ó]Ð]r   c                 óF   — |rd| j                  «       iS d| j                  iS )r™   r¼   )r&  rü   r¯   s     r   r�   zTFLiteGCSModelSource.as_dictZ  s*   € áØ" D×$CÑ$CÓ$EÐFÐFà × 4Ñ 4Ð5Ð5r   r3   )NN)zfirebase_ml_model.tfliteNNrŸ   )r    r¡   r¢   r£   rÑ   r   r;   rR   rV   r¤   r  r§   r	  r  r  r  r  r¥   r½   r¦   r&  r�   r¨   r   r   rÁ   rÁ   Ý  sâ   „ ÙMá)Ó+€OóHòò
&ð òEó ðEð$ ñ;ó ð;ð ñ#ó ð#ð
 ñ
#ó ð
#ð Ø?YØ/3ò^ó ð^ð. Ø;UØ/3ò^ó ð^ð. ñ$ó ð$ð ×ÑñHó ðHò^ô6r   rÁ   c                   ó`   — e Zd ZdZd	d„Zd„ Zd„ Zed„ «       Zej                  d„ «       Zd
d„Z
y)rÅ   z TFLite model source representing a tflite model created with AutoML.

    AutoML model support is deprecated and will be removed in the next major version.
    Nc                 óT   — t        j                  dt        «       || _        || _        y )Nr¿   )rÂ   rÃ   rÄ   r4   rÀ   )r:   rÀ   r   s      r   r;   zTFLiteAutoMlSource.__init__h  s%   € Ü�‰ð 'Ü(:ô	<àˆŒ	Ø*ˆÕr   c                 ób   — t        || j                  «      r| j                  |j                  k(  S yrM   )rN   rO   rÀ   rP   s     r   rR   zTFLiteAutoMlSource.__eq__n  s*   € Ü�e˜TŸ^™^Ô,Ø×%Ñ%¨×)<Ñ)<Ñ<Ð<Ør   c                 ó&   — | j                  |«       S r3   rU   rP   s     r   rV   zTFLiteAutoMlSource.__ne__s  rW   r   c                 ó   — | j                   S )zGResource name of the model, created by the AutoML API or Cloud console.©Ú_auto_ml_modelr`   s    r   rÀ   z TFLiteAutoMlSource.auto_ml_modelv  s   € ð ×"Ñ"Ð"r   c                 ó$   — t        |«      | _        y r3   )Ú_validate_auto_ml_modelr.  )r:   rÀ   s     r   rÀ   z TFLiteAutoMlSource.auto_ml_model{  s   € ä5°mÓDˆÕr   c                 ó   — d| j                   iS )r™   r¾   r-  r¯   s     r   r�   zTFLiteAutoMlSource.as_dict  s   € ð ˜t×2Ñ2Ð3Ð3r   r3   rŸ   )r    r¡   r¢   r£   r;   rR   rV   r¥   rÀ   r¦   r�   r¨   r   r   rÅ   rÅ   b  sK   „ ñó
+òò
&ð ñ#ó ð#ð ×ÑñEó ðEô4r   rÅ   c                   ób   — e Zd ZdZd„ Zed„ «       Zed„ «       Zed„ «       Zed„ «       Z	d„ Z
d„ Zy	)
r*   aF  Represents a page of models in a Firebase project.

    Provides methods for traversing the models included in this page, as well as
    retrieving subsequent pages of models. The iterator returned by
    ``iterate_all()`` can be used to iterate through all the models in the
    Firebase project starting from this page.
    c                 óh   — || _         || _        || _        || _        || _         ||||«      | _        y r3   )Ú_list_models_funcÚ_list_filterÚ
_page_sizeÚ_page_tokenr4   Ú_list_response)r:   Úlist_models_funcr,   r-   r.   r   s         r   r;   zListModelsPage.__init__�  s9   € Ø!1ˆÔØ'ˆÔØ#ˆŒØ%ˆÔØˆŒ	Ù.¨{¸IÀzÓRˆÕr   c                 óž   — | j                   j                  dg «      D �cg c]#  }t        j                  || j                  ¬«      ‘Œ% c}S c c}w )z A list of Models from this page.r  r   )r8  rZ   r   r   r4   )r:   r   s     r   r  zListModelsPage.models•  sI   € ð @D×?RÑ?R×?VÑ?VÐW_ÐacÓ?dö
Ø6;ŒE�O‰O˜E t§y¡yˆOÕ1ò
ð 	
ùò 
s   Ÿ(A
c                 ó   — | j                   S )z,The filter string used to filter the models.)r5  r`   s    r   r,   zListModelsPage.list_filterœ  s   € ð × Ñ Ð r   c                 ó:   — | j                   j                  dd«      S )z+Token identifying the next page of results.ÚnextPageTokenÚ )r8  rZ   r`   s    r   Únext_page_tokenzListModelsPage.next_page_token¡  s   € ð ×"Ñ"×&Ñ& ¸Ó;Ð;r   c                 ó,   — t        | j                  «      S )z!True if more pages are available.)r~   r?  r`   s    r   Úhas_next_pagezListModelsPage.has_next_page¦  s   € ô �D×(Ñ(Ó)Ð)r   c                 óž   — | j                   rAt        | j                  | j                  | j                  | j
                  | j                  «      S y)z�Retrieves the next page of models if available.

        Returns:
            ListModelsPage: Next page of models, or None if this is the last page.
        N)rA  r*   r4  r5  r6  r?  r4   r`   s    r   Úget_next_pagezListModelsPage.get_next_page«  sH   € ð ×ÒÜ!Ø×&Ñ&Ø×!Ñ!Ø—‘Ø×$Ñ$Ø—	‘	óð ð r   c                 ó   — t        | «      S )aC  Retrieves an iterator for Models.

        Returned iterator will iterate through all the models in the Firebase
        project starting from this page. The iterator will never buffer more than
        one page of models in memory at a time.

        Returns:
            iterator: An iterator of Model instances.
        )Ú_ModelIteratorr`   s    r   Úiterate_allzListModelsPage.iterate_allº  s   € ô ˜dÓ#Ð#r   N)r    r¡   r¢   r£   r;   r¥   r  r,   r?  rA  rC  rF  r¨   r   r   r*   r*   …  sg   „ ñòSð ñ
ó ð
ð ñ!ó ð!ð ñ<ó ð<ð ñ*ó ð*òó
$r   r*   c                   ó(   — e Zd ZdZd„ Zd„ Zd„ Zd„ Zy)rE  a  An iterator that allows iterating over models, one at a time.

    This implementation loads a page of models into memory, and iterates on them.
    When the whole page has been traversed, it loads another page. This class
    never keeps more than one page of entries in memory.
    c                 óV   — t        |t        «      st        d«      ‚|| _        d| _        y )Nz%Current page must be a ListModelsPager   )rN   r*   rÉ   Ú_current_pageÚ_index)r:   Úcurrent_pages     r   r;   z_ModelIterator.__init__Î  s'   € Ü˜,¬Ô7ÜÐCÓDÐDØ)ˆÔØˆ�r   c                 óª  — | j                   t        | j                  j                  «      k(  r<| j                  j                  r&| j                  j                  «       | _        d| _         | j                   t        | j                  j                  «      k  r:| j                  j                  | j                      }| xj                   dz  c_         |S t        ‚)Nr   é   )rJ  r‹   rI  r  rA  rC  ÚStopIteration)r:   Úresults     r   Únextz_ModelIterator.nextÔ  sœ   € Ø�;‰;œ#˜d×0Ñ0×7Ñ7Ó8Ò8Ø×!Ñ!×/Ò/Ø%)×%7Ñ%7×%EÑ%EÓ%G�Ô"Ø�”Ø�;‰;œ˜T×/Ñ/×6Ñ6Ó7Ò7Ø×'Ñ'×.Ñ.¨t¯{©{Ñ;ˆFØ�KŠK˜1Ñ�KØˆMÜÐr   c                 ó"   — | j                  «       S r3   )rP  r`   s    r   Ú__next__z_ModelIterator.__next__ß  s   € Ø�y‰y‹{Ðr   c                 ó   — | S r3   r¨   r`   s    r   Ú__iter__z_ModelIterator.__iter__â  s   € Øˆr   N)r    r¡   r¢   r£   r;   rP  rR  rT  r¨   r   r   rE  rE  Ç  s   „ ñòò	òór   rE  c                 óŠ   — t         j                  | «      }|st        d«      ‚|j                  d«      |j                  d«      fS )Nú&Model resource name format is invalid.Ú
project_idr#   )Ú_RESOURCE_NAME_PATTERNrÛ   rÜ   rÝ   )rY   rß   s     r   r[   r[   æ  s@   € ô %×*Ñ*¨4Ó0€GÙÜÐAÓBÐBØ�=‰=˜Ó&¨¯©°jÓ(AÐAÐAr   c                 ón   — t        | t        «      st        d«      ‚|€| j                  st	        d«      ‚y y )NzModel must be an ml.Model.zModel must have a display name.)rN   r   rÉ   r7   rÜ   )r   Úupdate_masks     r   Ú_validate_modelr[  ð  s:   € Ü�eœUÔ#ÜÐ4Ó5Ð5ØÐ 5×#5Ò#5ÜÐ:Ó;Ð;ð $6Ðr   c                 óD   — t         j                  | «      st        d«      ‚y )NzModel ID format is invalid.)Ú_MODEL_ID_PATTERNrÛ   rÜ   )r#   s    r   Ú_validate_model_idr^  ÷  s!   € Ü×"Ñ" 8Ô,ÜÐ6Ó7Ð7ð -r   c                 óF   — t         j                  | «      st        d«      ‚| S )Nz!Operation name format is invalid.)Ú_OPERATION_NAME_PATTERNrÛ   rÜ   )r’   s    r   Ú_validate_operation_namera  ü  s!   € Ü"×(Ñ(¨Ô1ÜÐ<Ó=Ð=Ø€Nr   c                 óF   — t         j                  | «      st        d«      ‚| S )NzDisplay name format is invalid.)Ú_DISPLAY_NAME_PATTERNrÛ   rÜ   )r7   s    r   rb   rb     s"   € Ü ×&Ñ& |Ô4ÜÐ:Ó;Ð;ØÐr   c                 óš   — t        | t        «      rt        d„ | D «       «      st        d«      ‚t        d„ | D «       «      st	        d«      ‚| S )Nc              3   ó<   K  — | ]  }t        |t        «      –— Œ y ­wr3   )rN   Ústr©Ú.0Útags     r   ú	<genexpr>z!_validate_tags.<locals>.<genexpr>
  s   è ø€ Ò1 SŒJ�sœC× Ñ1ùs   ‚zTags must be a list of strings.c              3   óF   K  — | ]  }t         j                  |«      –— Œ y ­wr3   )Ú_TAG_PATTERNrÛ   rg  s     r   rj  z!_validate_tags.<locals>.<genexpr>  s   è ø€ Ò7¨3Œ|×!Ñ! #×&Ñ7ùs   ‚!zTag format is invalid.)rN   ÚlistÚallrÉ   rÜ   )r8   s    r   rˆ   rˆ     sE   € Ü�dœDÔ!ÜÑ1¨DÔ1Ô1ÜÐ9Ó:Ð:ÜÑ7°$Ô7Ô7ÜÐ1Ó2Ð2Ø€Kr   c                 óF   — t         j                  | «      st        d«      ‚| S )Nr×   )rÚ   rÛ   rÜ   )rÞ   s    r   rû   rû     s#   € ô #×(Ñ(¨Ô-ÜÐ<Ó=Ð=Ø€Jr   c                 óF   — t         j                  | «      st        d«      ‚| S )NrV  )Ú_AUTO_ML_MODEL_PATTERNrÛ   rÜ   )r   s    r   r0  r0    s!   € Ü!×'Ñ'¨Ô.ÜÐAÓBÐBØ€Lr   c                 ó<   — t        | t        «      st        d«      ‚| S )Nz*Model format must be a ModelFormat object.)rN   rª   rÉ   r@   s    r   r—   r—     s   € Ü�l¤KÔ0ÜÐDÓEÐEØÐr   c                 ó@   — | �t        | t        «      st        d«      ‚y y )Nz%List filter must be a string or None.©rN   rf  rÉ   )r,   s    r   Ú_validate_list_filterru  $  s(   € ØÐÜ˜+¤sÔ+ÜÐCÓDÐDð ,ð r   c                 óš   — | �It        | «      t        urt        d«      ‚| dk  s	| t        kD  rt	        dj                  t        «      «      ‚y y )Nz#Page size must be a number or None.rM  z6Page size must be a positive integer between 1 and {0})Útyperg   rÉ   Ú_MAX_PAGE_SIZErÜ   rç   )r-   s    r   Ú_validate_page_sizery  *  sV   € ØÐÜ�	‹?¤#Ñ%äÐAÓBÐBØ�qŠ=˜I¬Ò6Üð )ß)/©´Ó)?óAð Að 7ð	 r   c                 ó@   — | �t        | t        «      st        d«      ‚y y )Nz$Page token must be a string or None.rt  )r.   s    r   Ú_validate_page_tokenr{  4  s(   € ØÐÜ˜*¤cÔ*ÜÐBÓCÐCð +ð r   c                   ó`   — e Zd ZdZdZdZdZdZd„ Zd„ Z	d„ Z
dd
„Zd„ Zdd„Zd„ Zd„ Zd„ Zd„ Zy	)r   zFirebase ML service.z7https://firebaseml.googleapis.com/v1beta2/projects/{0}/z*https://firebaseml.googleapis.com/v1beta2/g      ø?é   c                 óö  — |j                   | _        | j                  st        d«      ‚t        j                  j                  | j                  «      | _        ddj                  t        j                  «      i}t        j                  |j                  j                  «       || j                  ¬«      | _        t        j                  |j                  j                  «       |t        j                  ¬«      | _        y )NzqProject ID is required to access ML service. Either set the projectId option, or use service account credentials.zX-FIREBASE-CLIENTzfire-admin-python/{0})Ú
credentialÚheadersÚbase_url)rW  Ú_project_idrÜ   r   ÚPROJECT_URLrç   Ú_project_urlÚfirebase_adminÚ__version__r   ÚJsonHttpClientr  Úget_credentialÚ_clientÚOPERATION_URLÚ_operation_client)r:   r   Ú
ml_headerss      r   r;   z_MLService.__init__B  sÌ   € ØŸ>™>ˆÔØ×ÒÜðHóIð Iô '×2Ñ2×9Ñ9¸$×:JÑ:JÓKˆÔàÐ!8×!?Ñ!?Ä×@ZÑ@ZÓ![ð
ˆ
ô $×2Ñ2Ø—~‘~×4Ñ4Ó6ØØ×&Ñ&ô(ˆŒô ".×!<Ñ!<Ø—~‘~×4Ñ4Ó6ØÜ×-Ñ-ô"/ˆÕr   c                 óÈ   — t        |«       	 | j                  j                  d|¬«      S # t        j                  j
                  $ r}t        j                  |«      ‚d }~ww xY w)NrZ   ©Úurl)ra  r‹  ÚbodyÚrequestsr   ÚRequestExceptionr   Ú#handle_platform_error_from_requests)r:   r’   Úerrors      r   r‘   z_MLService.get_operationU  s[   € Ü  Ô)ð	DØ×)Ñ)×.Ñ.¨u¸'Ð.ÓBÐBøÜ×"Ñ"×3Ñ3ò 	DÜ×<Ñ<¸UÓCÐCûð	Dús   �* ªA!ÁAÁA!c                 ó<  — t        t        j                  |«      }|t        j                  z  }|�X|t        j                  j                  «       z
  j                  «       }|dk  rt        j                  d«      ‚t        ||dz
  «      }t        j                  |«       y)zGSleeps for the appropriate amount of time. Or throws deadline exceeded.NrM  zPolling max time exceeded.)Úpowr   ÚPOLL_EXPONENTIAL_BACKOFF_FACTORÚPOLL_BASE_WAIT_TIME_SECONDSrd   Únowrh   r   ÚDeadlineExceededErrorÚminÚtimeÚsleep)r:   Úcurrent_attemptÚ	stop_timeÚdelay_factorÚwait_time_secondsÚmax_seconds_lefts         r   Ú_exponential_backoffz_MLService._exponential_backoff\  s‰   € äœ:×EÑEÀÓWˆØ(¬:×+QÑ+QÑQÐàÐ Ø )¬H×,=Ñ,=×,AÑ,AÓ,CÑ C×RÑRÓTÐØ !Ò#Ü ×6Ñ6Ð7SÓTÐTÜ #Ð$5Ð7GÈ!Ñ7KÓ LÐÜ�
‰
Ð$Õ%r   Nc                 ó<  — t        |t        «      st        d«      ‚|j                  d«      rm|j                  d«      r|j                  d«      S |j                  d«      r$t	        j
                  |j                  d«      «      ‚t        j                  d¬«      ‚t        |j                  d«      «      }|j                  di «      }|j                  d	d
«      }|j                  d«      st        d«      ‚t        |j                  d«      «      \  }}d}	t        j                  j                  «       }
|€dn|
t        j                  |¬«      z   }|rM|j                  d«      s<| j                  |	|«       | j                  |«      }|	dz  }	|r|j                  d«      sŒ<|j                  d«      rW|j                  d«      r|j                  d«      S |j                  d«      r$t	        j
                  |j                  d«      «      ‚t!        |«      j#                  «       S )aÿ  Handles long running operations.

        Args:
            operation: The operation to handle.
            wait_for_operation: Should we allow polling for the operation to complete.
                If no polling is requested, a locked model will be returned instead.
            max_time_seconds: The maximum seconds to try polling for operation complete.
                (None for no limit)

        Returns:
            dict: A dictionary of the returned model properties.

        Raises:
            TypeError: if the operation is not a dictionary.
            ValueError: If the operation is malformed.
            UnknownError: If the server responds with an unexpected response.
            err: If the operation exceeds polling attempts or stop_time
        zOperation must be a dictionary.ÚdoneÚresponser”  z$Internal Error: Malformed Operation.)rz   rY   Úmetadatar?   r>  ÚModelOperationMetadataz#Unknown type of operation metadata.r   N)ÚsecondsrM  )rN   rA   rÉ   rZ   r   Úhandle_operation_errorr   ÚUnknownErrorra  Úendswithr[   rd   r™  r÷   r£  r‘   r(   r�   )r:   Ú	operationrŽ   r�   r’   r§  Úmetadata_typer\   r#   rž  Ú
start_timerŸ  s               r   r�   z_MLService.handle_operationh  sÇ  € ô& ˜)¤TÔ*ÜÐ=Ó>Ð>à�=‰=˜Ô à�}‰}˜ZÔ(Ø —}‘} ZÓ0Ð0Ø�}‰}˜WÔ%Ü×3Ñ3°I·M±MÀ'Ó4JÓKÐKÜ×)Ñ)Ð2XÔYÐYä*¨9¯=©=¸Ó+@ÓAˆØ—=‘= ¨RÓ0ˆØ Ÿ™ W¨bÓ1ˆØ×%Ñ%Ð&>Ô?ÜÐAÓBÐBÜ.¨x¯|©|¸FÓ/CÓD‰ˆˆ8ØˆÜ×&Ñ&×*Ñ*Ó,ˆ
Ø-Ð5‘TØ¤(×"4Ñ"4Ð=MÔ"NÑNð 	á ¨¯©°vÔ)>ð ×%Ñ% o°yÔAØ×*Ñ*¨7Ó3ˆIØ˜qÑ ˆOñ !¨¯©°vÕ)>ð �=‰=˜Ô Ø�}‰}˜ZÔ(Ø —}‘} ZÓ0Ð0Ø�}‰}˜WÔ%Ü×3Ñ3°I·M±MÀ'Ó4JÓKÐKô ˜Ó"×*Ñ*Ó,Ð,r   c           	      ó  — t        |«       	 | j                  | j                  j                  dd|j	                  d¬«      ¬«      «      S # t
        j                  j                  $ r}t        j                  |«      ‚d }~ww xY w)NÚpostr  Trš   ©r�  Újson)
r[  r�   r‰  r�  r�   r‘  r   r’  r   r“  )r:   r   r”  s      r   r   z_MLService.create_model¡  sy   € Ü˜Ôð	DØ×(Ñ(Ø—‘×!Ñ! &¨h¸U¿]¹]ÐVZ¸]Ó=[Ð!Ó\ó^ð ^øä×"Ñ"×3Ñ3ò 	DÜ×<Ñ<¸UÓCÐCûð	Dús   �<A
 Á
BÁ'A<Á<Bc           	      ól  — t        ||«       dj                  |j                  «      }|�|dj                  |«      z   }	 | j                  | j                  j                  d||j                  d¬«      ¬«      «      S # t        j                  j                  $ r}t        j                  |«      ‚d }~ww xY w)Nú
models/{0}z?updateMask={0}ÚpatchTrš   r²  )r[  rç   r#   r�   r‰  r�  r�   r‘  r   r’  r   r“  )r:   r   rZ  rã   r”  s        r   r   z_MLService.update_model©  s«   € Ü˜˜{Ô+Ø×"Ñ" 5§>¡>Ó2ˆØÐ"ØÐ+×2Ñ2°;Ó?Ñ?ˆDð	DØ×(Ñ(Ø—‘×!Ñ! '¨t¸%¿-¹-ÐSW¸-Ó:XÐ!ÓYó[ð [øä×"Ñ"×3Ñ3ò 	DÜ×<Ñ<¸UÓCÐCûð	Dús   ¿<A< Á<B3ÂB.Â.B3c                 óª   — t        |«       dj                  | j                  |«      }t        j	                  |d|idœ«      }| j                  |d¬«      S )Nzprojects/{0}/models/{1}r}   )rY   rx   zstate.published)rZ  )r^  rç   r‚  r   r   r   )r:   r#   r   Ú
model_namer   s        r   r!   z_MLService.set_published´  s[   € Ü˜8Ô$Ø.×5Ñ5°d×6FÑ6FÈÓQˆ
Ü—‘Øà˜Wðñ!
ó ˆð × Ñ  Ð4EÐ ÓFÐFr   c                 óæ   — t        |«       	 | j                  j                  ddj                  |«      ¬«      S # t        j
                  j                  $ r}t        j                  |«      ‚d }~ww xY w)NrZ   rµ  rŽ  ©	r^  r‰  r�  rç   r‘  r   r’  r   r“  ©r:   r#   r”  s      r   r(   z_MLService.get_model¿  sd   € Ü˜8Ô$ð	DØ—<‘<×$Ñ$ U°×0CÑ0CÀHÓ0MÐ$ÓNÐNøÜ×"Ñ"×3Ñ3ò 	DÜ×<Ñ<¸UÓCÐCûð	Dús   �+9 ¹A0ÁA+Á+A0c                 ó”  — t        |«       t        |«       t        |«       i }|r||d<   |r||d<   |r||d<   d}|r5t        j                  t        |j                  «       «      d«      }|dz   |z   }	 | j                  j                  d|¬«      S # t        j                  j                  $ r}t        j                  |«      ‚d	}~ww xY w)
z lists Firebase ML models.Úfilterr-   r.   r  Tú?rZ   rŽ  N)ru  ry  r{  r   Ú	urlencodeÚsortedÚitemsr‰  r�  r‘  r   r’  r   r“  )r:   r,   r-   r.   Úparamsrã   Ú	param_strr”  s           r   r+   z_MLService.list_modelsÆ  sÆ   € ä˜kÔ*Ü˜IÔ&Ü˜ZÔ(ØˆÙØ*ˆF�8ÑÙØ"+ˆF�;ÑÙØ#-ˆF�<Ñ ØˆÙÜŸ™¬¨v¯|©|«~Ó(>ÀÓEˆIØ˜#‘: 	Ñ)ˆDð	DØ—<‘<×$Ñ$ U°Ð$Ó5Ð5øÜ×"Ñ"×3Ñ3ò 	DÜ×<Ñ<¸UÓCÐCûð	Dús   Á3B ÂCÂ-CÃCc                 óè   — t        |«       	 | j                  j                  ddj                  |«      ¬«       y # t        j
                  j                  $ r}t        j                  |«      ‚d }~ww xY w)NÚdeleterµ  rŽ  rº  r»  s      r   r0   z_MLService.delete_modelÛ  sa   € Ü˜8Ô$ð	DØ�L‰L×Ñ˜h¨L×,?Ñ,?ÀÓ,IÐÕJøÜ×"Ñ"×3Ñ3ò 	DÜ×<Ñ<¸UÓCÐCûð	Dús   �,: ºA1ÁA,Á,A1)FNr3   )r    r¡   r¢   r£   rƒ  rŠ  r—  r˜  r;   r‘   r£  r�   r   r   r!   r(   r+   r0   r¨   r   r   r   r   :  sU   „ ÙàK€KØ@€MØ&)Ð#Ø"#Ðò/ò&Dò
&ó6-òrDó	Dò	GòDòDó*Dr   r   r3   )NNNN);r£   rd   Úrerœ  râ   Úurllibr   rÂ   r‘  r…  r   r   r   r   rÓ   rÔ   Ú
tensorflowr  r  r   rx  Úcompiler]  rc  rl  rÚ   rq  rX  r`  r   r   r   r$   r&   r(   r+   r0   r   rª   rC   rÈ   rÑ   rÁ   rÅ   r*   rE  r[   r[  r^  ra  rb   rˆ   rû   r0  r—   ru  ry  r{  r   r¨   r   r   ú<module>rÊ     sö  ðñó Û 	Û Û 	Ý Û ã ã Ý 'Ý !Ý %ðÝ&Ø€Lð
ÛØ€Kð €Ø€Ø�B—J‘JÐ7Ó8Ð Ø"˜Ÿ
™
Ð#;Ó<Ð Øˆr�z‰zÐ2Ó3€Ø$˜"Ÿ*™*ØBóDÐ à#˜Ÿ™ð*ó+Ð ð $˜Ÿ™ØZó\Ð à$˜"Ÿ*™*ØBóDÐ òBóDóDóVó WóDóMó&&÷bñ b÷J"ñ "ôA%�;ô A%÷H"ñ "÷,
ñ ,
ô^B6Ð,ô B6ôJ 4Ð*ô  4÷F?$ñ ?$÷Dñ ò>Bó<ò8ò
òòòòòòEòAòD÷fDò fDøðe ò ØƒLðûð ò ØƒKðús#   ¸E5 ÁF Å5F Å?F ÆFÆF