|
24 | 24 |
|
25 | 25 | if typing.TYPE_CHECKING:
|
26 | 26 | from google.cloud.aiplatform.metadata import experiment_resources
|
| 27 | + from google.cloud.aiplatform.metadata import experiment_run_resource |
27 | 28 | from google.cloud.aiplatform import model_evaluation
|
28 | 29 |
|
29 | 30 | _LOGGER = base.Logger(__name__)
|
@@ -168,6 +169,36 @@ def display_experiment_button(experiment: "experiment_resources.Experiment") ->
|
168 | 169 | display_link("View Experiment", uri, "science")
|
169 | 170 |
|
170 | 171 |
|
| 172 | +def display_experiment_run_button( |
| 173 | + experiment_run: "experiment_run_resource.ExperimentRun", |
| 174 | +) -> None: |
| 175 | + """Function to generate a link bound to the Vertex experiment run""" |
| 176 | + if not is_ipython_available(): |
| 177 | + return |
| 178 | + try: |
| 179 | + project = experiment_run.project |
| 180 | + location = experiment_run.location |
| 181 | + experiment_name = experiment_run._experiment._metadata_context.name |
| 182 | + run_name = experiment_run.name |
| 183 | + if ( |
| 184 | + run_name is None |
| 185 | + or experiment_name is None |
| 186 | + or project is None |
| 187 | + or location is None |
| 188 | + ): |
| 189 | + return |
| 190 | + except AttributeError: |
| 191 | + _LOGGER.warning("Unable to fetch experiment run metadata") |
| 192 | + return |
| 193 | + |
| 194 | + uri = ( |
| 195 | + "https://console.cloud.google.com/vertex-ai/experiments/locations/" |
| 196 | + + f"{location}/experiments/{experiment_name}/" |
| 197 | + + f"runs/{experiment_name}-{run_name}?project={project}" |
| 198 | + ) |
| 199 | + display_link("View Experiment Run", uri, "science") |
| 200 | + |
| 201 | + |
171 | 202 | def display_model_evaluation_button(
|
172 | 203 | evaluation: "model_evaluation.ModelEvaluation",
|
173 | 204 | ) -> None:
|
|
0 commit comments