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,