
    &`iQ              	          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m	Z	 ddl
mZmZ ddlmZ ddZ	 	 	 	 	 dd
Zedk    rddlZ ej                    Ze                    ddd           e                                \  ZZej        r7 edddej                             ej                    d                     dS  eddd           dS dS )zlAn example showing how to use Pytorch Lightning training, Ray Tune
HPO, and MLflow autologging all together.    N)tune)setup_mlflow)LightningMNISTClassifierMNISTDataModule)TuneReportCallback
   c           	         t          | |                     dd           |                     dd                      t          | |          }t          |d| d                   }ddd	}t          j                                         t          j        ||d
t          |d          g          }|
                    ||           d S )Nexperiment_nametracking_uri)r
   r      
batch_size)data_dirnum_workersr   zptl/val_losszptl/val_accuracy)lossaccr   validation_end)on)
max_epochsgpusprogress_bar_refresh_rate	callbacks)r   getr   r   mlflowpytorchautologplTrainerr   fit)configr   
num_epochsnum_gpusmodeldmmetricstrainers           p/home/jaya/work/projects/VOICE-AGENT/VIET/agent-env/lib/python3.11/site-packages/ray/tune/examples/mlflow_ptl.pytrain_mnist_tuner'      s    

#4d;;ZZ55    %VX66E	qVL5I
 
 
B &.@AAG
Nj"#%g2BCCCD	  G KKr    ptl_autologging_examplec           
         t           j                            t          j                    d          }t          |d                                           t          j        |           t          j	        |           t          j        g d          t          j        g d          t          j        dd          t          j        g d          |t          j                    t           j                            t          j                    d          |d}t          j        t          |||	          }t          j        t          j        |d
|d          t          j        dd|           t          j        d          |          }|                                }	t+          d|	                                j                   d S )Nmnist_data_    )r   r   )r,   @      )r-   r.      g-C6?g?)layer_1layer_2lrr   r
   r   r   r    )r   r    r!   r   )cpugpu)	resourcesr   min)metricmodenum_samples
tune_mnist)name)tune_config
run_configparam_spacez!Best hyperparameters found were: )ospathjointempfile
gettempdirr   prepare_datar   set_tracking_uriset_experimentr   choice
loguniformget_tracking_uriwith_parametersr'   Tunerwith_resources
TuneConfig	RunConfigr   printget_best_resultr   )
r9   r    gpus_per_trialr   r
   r   r   	trainabletunerresultss
             r&   r:   r:   &   s    w||H/11=AAHX"555BBDDD L)))
/*** ;}}}--;~~~..odD))k---00*/11GLL!4!6!6FF 	 	F $	  I JI>1R1RSSSO#
 
 

 >
 
 
   E iikkG	
-w/F/F/H/H/OPPPPPr(   __main__z--smoke-test
store_truezFinish quickly for testing)actionhelpr   mlruns)r9   r    rQ   r   )r9   r    rQ   )Nr   r   )r   r   r   Nr)   )__doc__r?   rB   r   pytorch_lightningr   rayr   ray.air.integrations.mlflowr    ray.tune.examples.mnist_ptl_minir   r   &ray.tune.integration.pytorch_lightningr   r'   r:   __name__argparseArgumentParserparseradd_argumentparse_known_argsargs_
smoke_testr@   rA   rC    r(   r&   <module>rj      s  - - 
			             4 4 4 4 4 4 V V V V V V V V E E E E E E   . -/Q /Q /Q /Qd zOOO$X$&&F
|2N     %%''GD! D
&9h&9&;&;XFF		
 	
 	
 	
 	
 	
 	
rbCCCCCC# r(   