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
This commit is contained in:
Jeremy Reizenstein 2022-10-20 03:43:05 -07:00 committed by Facebook GitHub Bot
parent 9535c576e0
commit 8339cf2610

View File

@ -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