From cac78ab215de58ea936374b9d66e33fc4040c48a Mon Sep 17 00:00:00 2001 From: tanmoyio Date: Wed, 1 Jun 2022 19:42:00 +0530 Subject: [PATCH 1/2] Resolving conflict for duplicate args --- pytorch_lightning/utilities/parsing.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pytorch_lightning/utilities/parsing.py b/pytorch_lightning/utilities/parsing.py index 92675bc9919d0..a63c56bb74725 100644 --- a/pytorch_lightning/utilities/parsing.py +++ b/pytorch_lightning/utilities/parsing.py @@ -182,7 +182,7 @@ def collect_init_args( if "__class__" in local_vars: local_args = get_init_args(frame) # recursive update - path_args.append(local_args) + path_args.insert(0, local_args) return collect_init_args(frame.f_back, path_args, inside=True) if not inside: return collect_init_args(frame.f_back, path_args, inside) From 5cb31c777150c85bfd6c5e7579663a6bd78874cc Mon Sep 17 00:00:00 2001 From: tanmoyio Date: Wed, 1 Jun 2022 20:36:17 +0530 Subject: [PATCH 2/2] unit test fixed --- tests/utilities/test_parsing.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/utilities/test_parsing.py b/tests/utilities/test_parsing.py index 2fbed03de84c2..13c98ade6f31b 100644 --- a/tests/utilities/test_parsing.py +++ b/tests/utilities/test_parsing.py @@ -265,8 +265,8 @@ def __init__(self, anyarg, childarg, anykw=42, childkw=42, **kwargs): super().__init__(anyarg, anykw=anykw, **kwargs) my_class = AutomaticArgsChild("test1", "test2", anykw=32, childkw=22, otherkw=123) - assert my_class.result[0] == {"anyarg": "test1", "anykw": 32, "otherkw": 123} - assert my_class.result[1] == {"anyarg": "test1", "childarg": "test2", "anykw": 32, "childkw": 22, "otherkw": 123} + assert my_class.result[0] == {"anyarg": "test1", "childarg": "test2", "anykw": 32, "childkw": 22, "otherkw": 123} + assert my_class.result[1] == {"anyarg": "test1", "anykw": 32, "otherkw": 123} def test_attribute_dict(tmpdir):