From 8339cf2610d3e1bbbe9ba4e86d65a216518ccceb Mon Sep 17 00:00:00 2001 From: Jeremy Reizenstein Date: Thu, 20 Oct 2022 03:43:05 -0700 Subject: [PATCH] hydra/OC.structured: don't hide error Summary: Keep the cause of hydra errors visible in some more cases. Reviewed By: shapovalov Differential Revision: D40516202 fbshipit-source-id: 8d214be5cc808a37738add77cc305fe099788546 --- pytorch3d/implicitron/tools/config.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/pytorch3d/implicitron/tools/config.py b/pytorch3d/implicitron/tools/config.py index 44cdb2ed9..2f0bc40e6 100644 --- a/pytorch3d/implicitron/tools/config.py +++ b/pytorch3d/implicitron/tools/config.py @@ -522,8 +522,12 @@ def get_default_args(C, *, _do_not_process: Tuple[type, ...] = ()) -> DictConfig try: out: DictConfig = OmegaConf.structured(C) - except Exception as e: - raise ValueError(f"OmegaConf.structured({C}) failed") from e + except Exception: + print(f"### OmegaConf.structured({C}) failed ###") + # We don't use `raise From` here, because that gets the original + # exception hidden by the OC_CAUSE logic in the case where we are + # called by hydra. + raise exclude = getattr(C, "_processed_members", ()) with open_dict(out): for field in exclude: @@ -545,8 +549,9 @@ def get_default_args(C, *, _do_not_process: Tuple[type, ...] = ()) -> DictConfig try: out: DictConfig = OmegaConf.structured(dataclass) - except Exception as e: - raise ValueError(f"OmegaConf.structured failed for {dataclass_name}") from e + except Exception: + print(f"### OmegaConf.structured failed for {C.__name__} ###") + raise return out