
    h*                         S SK Jr  S SKJr  S SKJr  S SKJrJrJ	r	  S SK
JrJrJr  SrSS\S	\S
\4S jjrS rSS\4S jjrS rSS\S\4S jjrSS\S\4S jjrS\S\S
S4S jrg)    )HUBDatasetStats)Auth)HUBTrainingSession)HUB_API_ROOTHUB_WEB_ROOTPREFIX)LOGGERSETTINGSchecks)
r   r   r   loginlogoutreset_modelexport_fmts_hubexport_model
get_exportcheck_datasetNapi_keysavereturnc                    [         R                  " S5        SSKJn  [         S3n[
        R                  " S5      nU =(       d    UnU(       a
  US:w  a  SU0OSnU" U5      nUR                  (       as  U(       a2  UR                  U:w  a"  [
        R                  " SUR                  05        UR                  U :X  d  U(       d  SOS	n[        R                  " [         U 35        g
[        R                  " [         SU S35        g)a9  
Log in to the Ultralytics HUB API using the provided API key.

The session is not stored; a new session is created when needed using the saved SETTINGS or the HUB_API_KEY
environment variable if successfully authenticated.

Args:
    api_key (str, optional): API key to use for authentication. If not provided, it will be retrieved from
        SETTINGS or HUB_API_KEY environment variable.
    save (bool, optional): Whether to save the API key to SETTINGS if authentication is successful.

Returns:
    (bool): True if authentication is successful, False otherwise.
zhub-sdk>=0.0.12r   )	HUBClientz/settings?tab=api+keysr    Nu!   New authentication successful ✅u   Authenticated ✅TzGet API key from z" and then run 'yolo login API_KEY'F)r   check_requirementshub_sdkr   r   r
   getauthenticatedr   updater	   infor   )	r   r   r   api_key_url	saved_key
active_keycredentialsclientlog_messages	            R/home/james-whalen/.local/lib/python3.13/site-packages/ultralytics/hub/__init__.pyr   r      s     /0!!N"89KY'I%IJ-7J"<L9j)RVK{#F FNNi/OOY78 4:>>W3LT_/ex 	 	vh{m,- 	vh/}<^_`    c                  P    S[         S'   [        R                  " [         S35        g)zJLog out of Ultralytics HUB by removing the API key from the settings file.r   r   u2   logged out ✅. To log in again, use 'yolo login'.N)r
   r	   r   r    r&   r%   r   r   C   s     HY
KK6(LMNr&   model_idc                 0   SSK nUR                  [         S3SU 0S[        5       R                  0S9nUR
                  S:X  a  [        R                  " [         S35        g[        R                  " [         S	UR
                   S
UR                   35        g)z,Reset a trained model to an untrained state.r   Nz/model-resetmodelId	x-api-keyjsonheaders   zModel reset successfullyzModel reset failure  )requestspostr   r   r   status_coder	   r   r   warningreason)r)   r2   rs      r%   r   r   I   s~    l39h:OZegkgmguguYvwA}}vh678
NNfX1!--!((LMr&   c                  D    SSK Jn   [        U " 5       S   SS 5      SS/-   $ )z.Return a list of HUB-supported export formats.r   export_formatsArgument   Nultralytics_tfliteultralytics_coreml)ultralytics.engine.exporterr:   listr9   s    r%   r   r   T   s+    : ,QR015IK_4```r&   formatc                 d   SSK nU[        5       ;   d   SU S[        5        35       eUR                  [         SU  S3SU0S[	        5       R
                  0S	9nUR                  S
:X  d)   [         U SUR                   SUR                   35       e[        R                  " [         U S35        g)a  
Export a model to a specified format for deployment via the Ultralytics HUB API.

Args:
    model_id (str): The ID of the model to export. An empty string will use the default model.
    format (str): The format to export the model to. Must be one of the supported formats returned by
        export_fmts_hub().

Raises:
    AssertionError: If the specified format is not supported or if the export request fails.

Examples:
    >>> from ultralytics import hub
    >>> hub.export_model(model_id="your_model_id", format="torchscript")
r   NUnsupported export format '', valid formats are z/v1/models/z/exportrA   r,   r-   r0   z export failure r1   u    export started ✅)r2   r   r3   r   r   r   r4   r   r6   r	   r   r)   rA   r2   r7   s       r%   r   r   [   s      _&&v*EfXMbcrctbu(vv&.H:W5Xv<NYdfjflftftXu 	 	A ==C^F8F83CAMM?RSTUT\T\S]!^^
KK6(6("567r&   c                 d   SSK nU[        5       ;   d   SU S[        5        35       eUR                  [         S3[	        5       R
                  XS.S[	        5       R
                  0S9nUR                  S	:X  d)   [         U S
UR                   SUR                   35       eUR                  5       $ )a\  
Retrieve an exported model in the specified format from Ultralytics HUB using the model ID.

Args:
    model_id (str): The ID of the model to retrieve from Ultralytics HUB.
    format (str): The export format to retrieve. Must be one of the supported formats returned by
        export_fmts_hub().

Returns:
    (dict): JSON response containing the exported model information.

Raises:
    AssertionError: If the specified format is not supported or if the API request fails.

Examples:
    >>> from ultralytics import hub
    >>> result = hub.get_export(model_id="your_model_id", format="torchscript")
r   NrC   rD   z/get-export)apiKeyr+   rA   r,   r-   r0   z get_export failure r1   )
r2   r   r3   r   r   r   r4   r   r6   r.   rE   s       r%   r   r   u   s    & _&&v*EfXMbcrctbu(vv&.$8Ndfnn- 	 	A
 ==CbF8F83GVWXYX`X`Wa!bb668Or&   pathtaskc                 n    [        XS9R                  5         [        R                  " S[         S35        g)af  
Check HUB dataset Zip file for errors before upload.

Args:
    path (str): Path to data.zip (with data.yaml inside data.zip).
    task (str): Dataset task. Options are 'detect', 'segment', 'pose', 'classify', 'obb'.

Examples:
    >>> from ultralytics.hub import check_dataset
    >>> check_dataset("path/to/coco8.zip", task="detect")  # detect dataset
    >>> check_dataset("path/to/coco8-seg.zip", task="segment")  # segment dataset
    >>> check_dataset("path/to/coco8-pose.zip", task="pose")  # pose dataset
    >>> check_dataset("path/to/dota8.zip", task="obb")  # OBB dataset
    >>> check_dataset("path/to/imagenet10.zip", task="classify")  # classification dataset

Notes:
    Download *.zip files from https://github.com/ultralytics/hub/tree/main/example_datasets
    i.e. https://github.com/ultralytics/hub/raw/main/example_datasets/coco8.zip for coco8.zip.
rH   rI   u7   Checks completed correctly ✅. Upload this dataset to z/datasets/.N)r   get_jsonr	   r   r   rK   s     r%   r   r      s,    ( )224
KKI,Wbcdr&   )NT)r   )r   torchscript)ultralytics.data.utilsr   ultralytics.hub.authr   ultralytics.hub.sessionr   ultralytics.hub.utilsr   r   r   ultralytics.utilsr	   r
   r   __all__strboolr   r   r   r   r   r   r   r(   r&   r%   <module>rV      s    3 % 6 D D 6 6)3 )T )T )XON# Na83 8S 84 3 >e e3 e4 er&   