Create and manage experiment runs

Use the Vertex AI SDK for Python to create and manage your experiment runs. You can use the Google Cloud console to delete experiment runs.

Vertex AI SDK for Python

The following samples use the methods init , start_run , and end_run from the aiplatform Package functions , and delete from the ExperimentClass .

Create and start run

Python

  from 
  
 typing 
  
 import 
 Optional 
 , 
 Union 
 from 
  
 google.cloud 
  
 import 
 aiplatform 
 def 
  
 create_experiment_run_sample 
 ( 
 experiment_name 
 : 
 str 
 , 
 run_name 
 : 
 str 
 , 
 experiment_run_tensorboard 
 : 
 Optional 
 [ 
 Union 
 [ 
 str 
 , 
 aiplatform 
 . 
 Tensorboard 
 ]], 
 project 
 : 
 str 
 , 
 location 
 : 
 str 
 , 
 ): 
 aiplatform 
 . 
 init 
 ( 
 experiment 
 = 
 experiment_name 
 , 
 project 
 = 
 project 
 , 
 location 
 = 
 location 
 ) 
 aiplatform 
 . 
 start_run 
 ( 
 run 
 = 
 run_name 
 , 
 tensorboard 
 = 
 experiment_run_tensorboard 
 ) 
 
  • experiment_name : Provide the name of your experiment. You can find your list of experiments in the Google Cloud console by selecting "Experiments" in the section nav.
  • run_name : Specify a run name to associate with your current session. See start_run in the Vertex AI SDK reference documentation.
  • experiment_run_tensorboard : Optional. A backing TensorBoard resource to enable and store time series metrics logged to this experiment run using log_time_series_metrics .
  • project : . You can find these IDs in the Google Cloud console welcome page.
  • location : See List of available locations

End run

Python

  from 
  
 google.cloud 
  
 import 
 aiplatform 
 def 
  
 end_experiment_run_sample 
 ( 
 experiment_name 
 : 
 str 
 , 
 run_name 
 : 
 str 
 , 
 project 
 : 
 str 
 , 
 location 
 : 
 str 
 , 
 ): 
 aiplatform 
 . 
 init 
 ( 
 experiment 
 = 
 experiment_name 
 , 
 project 
 = 
 project 
 , 
 location 
 = 
 location 
 ) 
 aiplatform 
 . 
 start_run 
 ( 
 run 
 = 
 run_name 
 , 
 resume 
 = 
 True 
 ) 
 aiplatform 
 . 
 end_run 
 () 
 
  • experiment_name : Provide the name of your experiment. You can find your list of experiments in the Google Cloud console by selecting "Experiments" in the section nav.
  • run_name : Specify a run name.
  • project : . You can find these in the Google Cloud console welcome page.
  • location : See List of available locations

Resume run

Python

  from 
  
 google.cloud 
  
 import 
 aiplatform 
 def 
  
 resume_experiment_run_sample 
 ( 
 experiment_name 
 : 
 str 
 , 
 run_name 
 : 
 str 
 , 
 project 
 : 
 str 
 , 
 location 
 : 
 str 
 , 
 ): 
 aiplatform 
 . 
 init 
 ( 
 experiment 
 = 
 experiment_name 
 , 
 project 
 = 
 project 
 , 
 location 
 = 
 location 
 ) 
 aiplatform 
 . 
 start_run 
 ( 
 run 
 = 
 run_name 
 , 
 resume 
 = 
 True 
 ) 
 
  • experiment_name : Provide the name of your experiment. You can find your list of experiments in the Google Cloud console by selecting "Experiments" in the section nav.
  • run_name : Specify name of run that you want to resume.
  • project : . You can find these in the Google Cloud console welcome page.
  • location : See List of available locations

Delete run

Python

  from 
  
 typing 
  
 import 
 Union 
 from 
  
 google.cloud 
  
 import 
 aiplatform 
 def 
  
 delete_experiment_run_sample 
 ( 
 run_name 
 : 
 str 
 , 
 experiment 
 : 
 Union 
 [ 
 str 
 , 
 aiplatform 
 . 
 Experiment 
 ], 
 project 
 : 
 str 
 , 
 location 
 : 
 str 
 , 
 delete_backing_tensorboard_run 
 : 
 bool 
 = 
 False 
 , 
 ): 
 experiment_run 
 = 
 aiplatform 
 . 
 ExperimentRun 
 ( 
 run_name 
 = 
 run_name 
 , 
 experiment 
 = 
 experiment 
 , 
 project 
 = 
 project 
 , 
 location 
 = 
 location 
 ) 
 experiment_run 
 . 
 delete 
 ( 
 delete_backing_tensorboard_run 
 = 
 delete_backing_tensorboard_run 
 ) 
 
  • experiment : The name or instance of this experiment. You can find your list of experiments in the Google Cloud console by selecting "Experiments" in the section nav.
  • run_name : Specify name of run that you want to delete.
  • project : . You can find these in the Google Cloud console welcome page.
  • location : See List of available locations
  • delete_backing_tensorboard_run : Whether to delete the backing Vertex AI TensorBoard run that stores time series metrics for this run.

Manage status

Python

  from 
  
 typing 
  
 import 
 Union 
 from 
  
 google.cloud 
  
 import 
 aiplatform 
 def 
  
 update_experiment_run_state_sample 
 ( 
 run_name 
 : 
 str 
 , 
 experiment 
 : 
 Union 
 [ 
 str 
 , 
 aiplatform 
 . 
 Experiment 
 ], 
 project 
 : 
 str 
 , 
 location 
 : 
 str 
 , 
 state 
 : 
 aiplatform 
 . 
 gapic 
 . 
 Execution 
 . 
 State 
 , 
 ) 
 - 
> None 
 : 
 experiment_run 
 = 
 aiplatform 
 . 
 ExperimentRun 
 ( 
 run_name 
 = 
 run_name 
 , 
 experiment 
 = 
 experiment 
 , 
 project 
 = 
 project 
 , 
 location 
 = 
 location 
 , 
 ) 
 experiment_run 
 . 
 update_state 
 ( 
 state 
 ) 
 
  • run_name : run name associated with your experiment
  • experiment_name : name of your experiment. You can find your list of experiments in the Google Cloud console by selecting Experiments in the section nav.
  • project : . You can find these Project IDs in the Google Cloud console welcome page.
  • location : See List of available locations
  • state : Possible values for state , which shows up as "status" in the Google Cloud console, are:
    • aiplatform.gapic.Execution.State.CACHED
    • aiplatform.gapic.Execution.State.CANCELLED
    • aiplatform.gapic.Execution.State.COMPLETE
    • aiplatform.gapic.Execution.State.FAILED
    • aiplatform.gapic.Execution.State.NEW
    • aiplatform.gapic.Execution.State.RUNNING

Google Cloud console

Follow these steps to delete an experiment run .
  1. In the Google Cloud console, go to the Experiments page.
    Go to Experiments
  2. In the experiment details page, click the name of the experiment that is associated with the experiment run you want to delete. The Experiment runs page appears with the list of all the experiment runs for that experiment.
  3. Select the checkbox associated with the run that you want to delete. The Delete button appears.
  4. Click Delete
    • Alternatively, you can go to the  options menu that's in the same row as the experiment run and select delete .

View list of experiment runs and run details

The Google Cloud console provides a visualization of the data associated with these runs.

What's next

Design a Mobile Site
View Site in Mobile | Classic
Share by: