File tree Expand file tree Collapse file tree 2 files changed +1
-8
lines changed
src/lightning/pytorch/utilities
tests/tests_pytorch/models Expand file tree Collapse file tree 2 files changed +1
-8
lines changed Original file line number Diff line number Diff line change @@ -169,12 +169,6 @@ def save_hyperparameters(
169169 elif is_dataclass (obj ):
170170 obj_fields = fields (obj )
171171 init_args = {f .name : getattr (obj , f .name ) for f in obj_fields if f .init }
172- if any (not f .init for f in obj_fields ):
173- rank_zero_warn (
174- "Detected a dataclass with fields with `init=False`. This is not supported by `save_hyperparameters`"
175- " and will not save those fields in `self.hparams`. Consider removing `init=False` and just"
176- " re-initialize the attributes in the `__post_init__` method of the dataclass."
177- )
178172 else :
179173 init_args = {}
180174
Original file line number Diff line number Diff line change @@ -895,8 +895,7 @@ def __post_init__(self):
895895 super ().__init__ ()
896896 self .save_hyperparameters ()
897897
898- with pytest .warns (UserWarning , match = "Detected a dataclass with fields with `init=False`" ):
899- model = DataClassWithInitFalseFieldsModel (33 , optional = "cocofruit" )
898+ model = DataClassWithInitFalseFieldsModel (33 , optional = "cocofruit" )
900899
901900 expected_hparams = {"mandatory" : 33 , "optional" : "cocofruit" }
902901 assert model .hparams == expected_hparams
You can’t perform that action at this time.
0 commit comments