From 23b9a617d588fcb562dcbec2a1c2a7b391dd5534 Mon Sep 17 00:00:00 2001 From: dimakarp1996 Date: Tue, 31 Jan 2023 22:49:19 +0300 Subject: [PATCH] Minor fixes in chainer, for the convenience of debugging --- deeppavlov/core/common/chainer.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/deeppavlov/core/common/chainer.py b/deeppavlov/core/common/chainer.py index 373cf8291e..7514112568 100644 --- a/deeppavlov/core/common/chainer.py +++ b/deeppavlov/core/common/chainer.py @@ -216,7 +216,8 @@ def _compute(*args, param_names, pipe, targets): final_pipe.append(((in_keys, in_params), out_params, component)) final_pipe.reverse() if not expected.issubset(param_names): - raise RuntimeError(f'{expected} are required to compute {targets} but were not found in memory or inputs') + missing_params = [k for k in expected if k not in param_names] + raise RuntimeError(f'{missing_params} are required to compute {targets} but were not found in memory or inputs') pipe = final_pipe mem = dict(zip(param_names, args)) @@ -232,8 +233,10 @@ def _compute(*args, param_names, pipe, targets): mem[out_params[0]] = res else: mem.update(zip(out_params, res)) - - res = [mem[k] for k in targets] + try: + res = [mem[k] for k in targets] + except Exception as e: + raise Exception(f'In memory {mem.keys()} targets {targets}: {e}') if len(res) == 1: res = res[0] return res