o
    xi~                     @  s   d dl mZ d dlZd dlmZmZ d dlZd dlmZ ddl	m
Z
 er*d dlmZ dd	 Z			dddd
Z			ddddZdS )    )annotationsN)TYPE_CHECKINGCallable)env   )wandb_login_WandbControllerc                 C  s   | j rB| ddu r|  }|dr| d|d  | d}|s$dS | drDdj| jtj	| dtj	|tj	|dS dS dS )z)Return sweep url if we can figure it out.entityNprojectz*{base}/{entity}/{project}/sweeps/{sweepid})baser
   r   sweepid)
api_keysettingsviewergetset_settingformatapp_urlurllibparsequote)apisweep_idr   r    r   I/home/ubuntu/.local/lib/python3.10/site-packages/wandb/sdk/wandb_sweep.py_get_sweep_url   s"   




r   sweepdict | Callabler
   
str | Noner   
prior_runslist[str] | Nonereturnstrc           
      C  s   ddl m} ddlm} t| r|  } 	 |du r#t| tr#| dd}|r*t	| |r1t
| tjdu r<tjdd | }|j| |d\}}|| td	| t||}	|	r]td
|	 |S )aB  Initialize a hyperparameter sweep.

    Search for hyperparameters that optimizes a cost function
    of a machine learning model by testing various combinations.

    Make note the unique identifier, `sweep_id`, that is returned.
    At a later step provide the `sweep_id` to a sweep agent.

    See [Sweep configuration structure](https://docs.wandb.ai/guides/sweeps/define-sweep-configuration)
    for information on how to define your sweep.

    Args:
      sweep: The configuration of a hyperparameter search.
        (or configuration generator).
        If you provide a callable, ensure that the callable does
        not take arguments and that it returns a dictionary that
        conforms to the W&B sweep config spec.
      entity: The username or team name where you want to send W&B
        runs created by the sweep to. Ensure that the entity you
        specify already exists. If you don't specify an entity,
        the run will be sent to your default entity,
        which is usually your username.
      project: The name of the project where W&B runs created from
        the sweep are sent to. If the project is not specified, the
        run is sent to a project labeled 'Uncategorized'.
      prior_runs: The run IDs of existing runs to add to this sweep.

    Returns:
      str: A unique identifier for the sweep.
    r   )InternalApi)handle_sweep_config_violationsNr   T)_silent)r    zCreate sweep with ID:z
Sweep URL:)
wandb.apisr$   wandb.sdk.launch.sweeps.utilsr%   callable
isinstancedictr   r   
set_entityset_projectwandbrunr   _loginupsert_sweepprintr   )
r   r
   r   r    r$   r%   r   r   warnings	sweep_urlr   r   r   r   "   s*   $





sweep_id_or_configstr | dict | Noner	   c                 C  s   ddl m} || ||d}|S )zPublic sweep controller constructor.

    Examples:
    ```python
    import wandb

    tuner = wandb.controller(...)
    print(tuner.sweep_config)
    print(tuner.sweep_id)
    tuner.configure_search(...)
    tuner.configure_stopping(...)
    ```

       r   )r5   r
   r   )wandb_controllerr	   )r5   r
   r   r	   cr   r   r   
controllerc   s
   r:   )NNN)
r   r   r
   r   r   r   r    r!   r"   r#   )r5   r6   r
   r   r   r   r"   r	   )
__future__r   urllib.parser   typingr   r   r.   r    r   wandb.wandb_controllerr	   r   r   r:   r   r   r   r   <module>   s"    B