From 619e6d98cc67f9b3cab0d26462edc175d8719dc0 Mon Sep 17 00:00:00 2001 From: Bernie Beckerman Date: Tue, 13 Jun 2023 07:13:23 -0700 Subject: [PATCH] Load Experiment without runners and metrics in the case where search space and optimization config are immutable Summary: `load_experiment` was previously failing when `skip_runners_and_metrics=True` for experiments with immutable search space and optimization config. See [Lena's comment](https://www.internalfb.com/diff/D46595953?dst_version_fbid=263061986396665&transaction_fbid=639853311380999) for more detail. Differential Revision: D46595953 fbshipit-source-id: 7591b2d968fdf53bb86f96f6cdfe455d0e094217 --- ax/storage/sqa_store/load.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/ax/storage/sqa_store/load.py b/ax/storage/sqa_store/load.py index d6cd5b92469..b4461e562d5 100644 --- a/ax/storage/sqa_store/load.py +++ b/ax/storage/sqa_store/load.py @@ -28,6 +28,7 @@ from ax.utils.common.constants import Keys from ax.utils.common.typeutils import not_none from sqlalchemy.orm import defaultload, lazyload, noload +from sqlalchemy.orm.exc import DetachedInstanceError # ---------------------------- Loading `Experiment`. --------------------------- @@ -135,10 +136,13 @@ def _load_experiment( for sqa_metric in experiment_sqa.metrics: sqa_metric.metric_type = 0 - for sqa_trial in experiment_sqa.trials: - for sqa_generator_run in sqa_trial.generator_runs: - for sqa_metric in sqa_generator_run.metrics: - sqa_metric.metric_type = 0 + try: + for sqa_trial in experiment_sqa.trials: + for sqa_generator_run in sqa_trial.generator_runs: + for sqa_metric in sqa_generator_run.metrics: + sqa_metric.metric_type = 0 + except DetachedInstanceError: + pass return decoder.experiment_from_sqa( experiment_sqa=experiment_sqa,