
    ŀi<                     h
   U d Z ddlmZ ddlmZ ddlZddd	Z ej                   ej                  d
d      g ej                   ej                  d                  Z ej                  d ej                  d ej                  d            d       ej                  d ej                  d ej                  d            d       ej                  d ej                  d ej                  d       ej                  d            d       ej                  d  ej                  d ej                  d       ej                  d!d"d#$            d%       ej                  d& ej                  d ej                  d       ej                  d!d"ej                   j"                  d'(            d%       ej                  d) ej                  d ej                  d       ej                  d            d*       ej                  d+ ej                  d ej                  d       ej                  d!d"d,d- ej$                  d.      /            d       ej                  d0 ej                  d ej                  d12            d3       ej                  d4 ej                  d ej                  d12       ej                  d!d"d,d- ej$                  d52      d6d7i8            d3       ej                  d9 ej                  d: ej                  d;       ej                  d<d=d> ej$                  d?      d@eA            d%       ej                  dB ej                  d: ej                  d;       ej                  d> ej$                  d?      dCdDeE            dF       ej                  dG ej                  d: ej                  d;       ej                  d> ej$                  d?      dHdIdCdDeJ            dF       ej                  dK ej                  d: ej                  d;       ej                  d<d=d> ej$                  d?      dCdDeL            dF      gZeej                     edM<    ej,                  e e       dNeO      ZdPZej6                  j9                  dQdRS      dT        Zej6                  j9                  dQdRS      dU        Zej6                  j9                  dQdRS      ej6                  j>                  dV               Z y)WzTests for tunings.tune().   )types   )pytest_helper    Nv1beta1z?https://us-central1-autopush-aiplatform.sandbox.googleapis.com/)api_versionbase_urlbleuztest prompt template)nameprompt_templategs://sararob_test/output_uri_prefixgcs_destination)metricsoutput_configtest_dataset_gcs_urigemini-2.5-flashzVgs://cloud-samples-data/ai-platform/generative_ai/gemini-1_5/text/sft_train_data.jsonlgcs_uri)
base_modeltraining_datasetz1gcs_uri parameter is not supported in Gemini API.)r   
parametersexception_if_mldevtest_tune_pretuned_modelzFprojects/801452371447/locations/us-central1/models/9030969596621881344Vgs://cloud-samples-data/ai-platform/generative_ai/gemini-2_0/text/sft_train_data.jsonlzis not supported in Gemini API+test_tune_pretuned_model_with_checkpoint_id3)pre_tuned_model_checkpoint_idr   r   configtest_tune_simple_dpozModel display name   PREFERENCE_TUNING)tuned_model_display_nameepoch_countmethodz)parameter is not supported in Gemini API.test_tune_dpo_with_betag      ?)r&   r'   r(   beta*test_non_pretuned_model_with_checkpoint_idzis not supported in Gemini API.#test_dataset_gcs_uri_all_parameters      ?ADAPTER_SIZE_ONEz[gs://cloud-samples-data/ai-platform/generative_ai/gemini-1_5/text/sft_validation_data.jsonl)r&   r'   learning_rate_multiplieradapter_sizevalidation_dataset$test_dataset_vertex_dataset_resourcezHprojects/801452371447/locations/us-central1/datasets/5779918772206829568)vertex_dataset_resourcezAvertex_dataset_resource parameter is not supported in Gemini API.,test_dataset_dataset_resource_all_parameterszHprojects/801452371447/locations/us-central1/datasets/1168232753779441664testlabelkeytestlabelvalue)r&   r'   r/   r0   r1   labelstest_tune_distillationz#meta/llama3_1@llama-3.1-8b-instructzEgs://nathreya-oss-tuning-sdk-test/distillation-openai-opposites.jsonlDISTILLATIONzdeepseek-ai/deepseek-v3.1-maas   zIgs://nathreya-oss-tuning-sdk-test/distillation-val-openai-opposites.jsonlzDgs://nathreya-oss-tuning-sdk-test/ayushagra-distillation-test-folder)r(   base_teacher_modelr'   r1   
output_urihttp_optionstest_tune_oss_sftzigs://nathreya-oss-tuning-sdk-test/ayushagra-distillation-test-folder/postprocess/node-0/checkpoints/finalz=gs://nathreya-oss-tuning-sdk-test/ayushagra-distillation-test)r'   r1   custom_base_modelr<   r=   znot supported in Gemini APItest_tune_oss_sft_hyperparamsgMb0?TUNING_MODE_FULL)r'   r1   learning_ratetuning_moder?   r<   r=   test_tune_oss_distillation)r(   r;   r'   r1   r?   r<   r=   
test_tableztunings.tune)fileglobals_for_filetest_methodrE   )pytest_asynciozconfig.getoption('--private')zSkipping in pre-public tests)reasonc                 t   | j                   j                  r| j                  j                  dt	        j
                  d      t	        j                  ddddt	        j                  d      t        	      
      }|j                  t        j                  j                  k(  sJ |j                  t        k(  sJ yyzTests tuning with eval config.r   r   r   tuning job with eval configr$   r-   r.   [gs://cloud-samples-data/ai-platform/generative_ai/gemini-2_0/text/sft_validation_data.jsonlr&   r'   r/   r0   r1   evaluation_configr!   N)_api_clientvertexaituningstunegenai_typesTuningDatasetCreateTuningJobConfigTuningValidationDatasetrP   stateJobStateJOB_STATE_PENDINGclient
tuning_jobs     h/var/www/html/content-pipeline/venv/lib/python3.12/site-packages/google/genai/tests/tunings/test_tune.pytest_eval_configr`     s       $$#"00  :R  S..#@#&)(@@s .	 % J {33EEEEE''+<<<<# !    c                 r   | j                   j                  r t        j                  t        j                  dddd      t        j                  d      t        j                  d      gt        j
                  t        j                  d	
            t        j                  dd            }| j                  j                  dt        j                  d      t        j                  ddddt        j                  d      |            }|j                  t        j                  j                  k(  sJ yy)z&Tests tuning with eval config metrics.zprompt-relevancezXHow well does the response address the prompt?: PROMPT: {request}
 RESPONSE: {response}
Tz:You are a cat. Make all evaluations from this perspective.)r   r   return_raw_outputjudge_model_system_instructionr
   )r   rouge_1r   r   r   r$   z
test-model)sampling_countautorater_model)r   r   autorater_configr   r   r   rM   r-   r.   rN   rO   r!   N)rQ   rR   rU   EvaluationConfigMetricOutputConfigGcsDestinationAutoraterConfigrS   rT   rV   rW   rX   rY   rZ   r[   )r]   rP   r^   s      r_   test_eval_config_with_metricsrn     s#      !22' |"&/k	 F+I.	
 "..'66"6

 %44(
!* $$#"00  :R  S..#@#&)(@@s .	 % J {33EEEEEI !ra   c                 z  K   | j                   j                  r| j                  j                  j	                  dt        j                  d      t        j                  ddddt        j                  d      t        	      
       d{   }|j                  t
        j                  j                  k(  sJ yy7 /wrL   )rQ   rR   aiorS   rT   rU   rV   rW   rX   rP   rY   rZ   r[   r\   s     r_   test_eval_config_asyncrq   L  s        zz))..#"00  :R  S..#@#&)(@@s .	 /  J {33EEEEE! !s   BB;	B9
0B;)!__doc__ r   rU   r   pytestVERTEX_HTTP_OPTIONSri   rj   rk   rl   rP   TestTableItemCreateTuningJobParametersrV   rW   TuningMethodr%   rX   rE   list__annotations__setup__file__globals
pytestmarkpytest_pluginsmarkskipifr`   rn   asynciorq    ra   r_   <module>r      sb  "   $   Q 
 /+..8NO ++**2222
		   M#8;88)6[66p
 O	  M'8;88_6[66p
 <	  M:8;88_6[66p 5;44.1
 <  M#8;88)6[66p 5;44)=*

 G  M&8;88)6[66p 5;44)="//AA	
 G   M98;88)6[66p 5;44.1
 =  M28;88)6[66p 5;44)=),/#F;#F#Fy$
 O#&  M38;88)6[66(r
 _	  M;8;88)6[66(r 5;44)=),/#F;#F#F,v$ '(89	
  _%(  M%8;88<6[66_ 5;44%#C#F;#F#Fg$ b0	
  G%(  M 8;88<6[66_ 5;44#F;#F#Fg$ #NZ0
 9#&  M,8;88<6[66_ 5;44#F;#F#Fg$ %. #NZ0

" 9'*  M)8;88<6[66_ 5;44%#C#F;#F#Fg$ #NZ0

" 9'wP1
D,,- Pd !]  	Y	
 % #)  =	=. #)  &F	&FR #)   F 	
Fra   