Error while fitting model in Benchmark

I’m getting this error while trying to fit the benchmark model:
“AttributeError: ‘functools.partial’ object has no attribute ‘name’”
While Googling around I couldn’t find an obvious answer. Upgrading python from 3.7 to 3.9 wasn’t the answer ( and a bigger pain then I expected ).

versions:
Python 3.9.6
pytorch-lightning: 1.4.2
torch: 1.9.0
tensorboard: 2.6.0

Here’s the full trace:
AttributeError Traceback (most recent call last)
~\AppData\Local\Temp/ipykernel_16544/4191702415.py in
22
23 flood_model = FloodModel(hparams=hparams)
—> 24 flood_model.fit()

~\AppData\Local\Temp/ipykernel_16544/1333484537.py in fit(self)
194 # Set up and fit Trainer object
195 self.trainer = pl.Trainer(**self.trainer_params)
–> 196 self.trainer.fit(self)

c:\development\data_science_competitions\drivendata_floodwater_v2\venv\lib\site-packages\pytorch_lightning\trainer\trainer.py in fit(self, model, train_dataloaders, val_dataloaders, datamodule, train_dataloader)
551 self.checkpoint_connector.resume_start()
552
–> 553 self._run(model)
554
555 assert self.state.stopped

c:\development\data_science_competitions\drivendata_floodwater_v2\venv\lib\site-packages\pytorch_lightning\trainer\trainer.py in _run(self, model)
910
911 # plugin will setup fitting (e.g. ddp will launch child processes)
–> 912 self._pre_dispatch()
913
914 # restore optimizers, etc.

c:\development\data_science_competitions\drivendata_floodwater_v2\venv\lib\site-packages\pytorch_lightning\trainer\trainer.py in _pre_dispatch(self)
939 def _pre_dispatch(self):
940 self.accelerator.pre_dispatch(self)
–> 941 self._log_hyperparams()
942
943 def _log_hyperparams(self):

c:\development\data_science_competitions\drivendata_floodwater_v2\venv\lib\site-packages\pytorch_lightning\trainer\trainer.py in _log_hyperparams(self)
968 self.logger.log_hyperparams(hparams_initial)
969 self.logger.log_graph(self.lightning_module)
–> 970 self.logger.save()
971
972 def _post_dispatch(self):

c:\development\data_science_competitions\drivendata_floodwater_v2\venv\lib\site-packages\pytorch_lightning\utilities\distributed.py in wrapped_fn(*args, **kwargs)
46 def wrapped_fn(*args, **kwargs):
47 if rank_zero_only.rank == 0:
—> 48 return fn(*args, **kwargs)
49
50 return wrapped_fn

c:\development\data_science_competitions\drivendata_floodwater_v2\venv\lib\site-packages\pytorch_lightning\loggers\tensorboard.py in save(self)
248 # save the metatags file if it doesn’t exist and the log directory exists
249 if self._fs.isdir(dir_path) and not self._fs.isfile(hparams_file):
–> 250 save_hparams_to_yaml(hparams_file, self.hparams)
251
252 @rank_zero_only

c:\development\data_science_competitions\drivendata_floodwater_v2\venv\lib\site-packages\pytorch_lightning\core\saving.py in save_hparams_to_yaml(config_yaml, hparams)
403 for k, v in hparams.items():
404 try:
–> 405 yaml.dump(v)
406 except TypeError:
407 warn(f"Skipping ‘{k}’ parameter because it is not possible to safely dump to YAML.")

c:\development\data_science_competitions\drivendata_floodwater_v2\venv\lib\site-packages\yaml_init_.py in dump(data, stream, Dumper, **kwds)
288 If stream is None, return the produced string instead.
289 “”"
–> 290 return dump_all([data], stream, Dumper=Dumper, **kwds)
291
292 def safe_dump_all(documents, stream=None, **kwds):

c:\development\data_science_competitions\drivendata_floodwater_v2\venv\lib\site-packages\yaml_init_.py in dump_all(documents, stream, Dumper, default_style, default_flow_style, canonical, indent, width, allow_unicode, line_break, encoding, explicit_start, explicit_end, version, tags, sort_keys)
276 dumper.open()
277 for data in documents:
–> 278 dumper.represent(data)
279 dumper.close()
280 finally:

c:\development\data_science_competitions\drivendata_floodwater_v2\venv\lib\site-packages\yaml\representer.py in represent(self, data)
25
26 def represent(self, data):
—> 27 node = self.represent_data(data)
28 self.serialize(node)
29 self.represented_objects = {}

c:\development\data_science_competitions\drivendata_floodwater_v2\venv\lib\site-packages\yaml\representer.py in represent_data(self, data)
50 for data_type in data_types:
51 if data_type in self.yaml_multi_representers:
—> 52 node = self.yaml_multi_representers[data_type](self, data)
53 break
54 else:

c:\development\data_science_competitions\drivendata_floodwater_v2\venv\lib\site-packages\yaml\representer.py in represent_object(self, data)
340 if not args and not listitems and not dictitems
341 and isinstance(state, dict) and newobj:
–> 342 return self.represent_mapping(
343 ‘tag:yaml.org,2002:python/object:’+function_name, state)
344 if not listitems and not dictitems \

c:\development\data_science_competitions\drivendata_floodwater_v2\venv\lib\site-packages\yaml\representer.py in represent_mapping(self, tag, mapping, flow_style)
116 for item_key, item_value in mapping:
117 node_key = self.represent_data(item_key)
–> 118 node_value = self.represent_data(item_value)
119 if not (isinstance(node_key, ScalarNode) and not node_key.style):
120 best_style = False

c:\development\data_science_competitions\drivendata_floodwater_v2\venv\lib\site-packages\yaml\representer.py in represent_data(self, data)
50 for data_type in data_types:
51 if data_type in self.yaml_multi_representers:
—> 52 node = self.yaml_multi_representers[data_type](self, data)
53 break
54 else:

c:\development\data_science_competitions\drivendata_floodwater_v2\venv\lib\site-packages\yaml\representer.py in represent_object(self, data)
344 if not listitems and not dictitems
345 and isinstance(state, dict) and not state:
–> 346 return self.represent_sequence(tag+function_name, args)
347 value = {}
348 if args:

c:\development\data_science_competitions\drivendata_floodwater_v2\venv\lib\site-packages\yaml\representer.py in represent_sequence(self, tag, sequence, flow_style)
90 best_style = True
91 for item in sequence:
—> 92 node_item = self.represent_data(item)
93 if not (isinstance(node_item, ScalarNode) and not node_item.style):
94 best_style = False

c:\development\data_science_competitions\drivendata_floodwater_v2\venv\lib\site-packages\yaml\representer.py in represent_data(self, data)
46 data_types = type(data).mro
47 if data_types[0] in self.yaml_representers:
—> 48 node = self.yaml_representers[data_types[0]](self, data)
49 else:
50 for data_type in data_types:

c:\development\data_science_competitions\drivendata_floodwater_v2\venv\lib\site-packages\yaml\representer.py in represent_tuple(self, data)
284
285 def represent_tuple(self, data):
–> 286 return self.represent_sequence(‘tag:yaml.org,2002:python/tuple’, data)
287
288 def represent_name(self, data):

c:\development\data_science_competitions\drivendata_floodwater_v2\venv\lib\site-packages\yaml\representer.py in represent_sequence(self, tag, sequence, flow_style)
90 best_style = True
91 for item in sequence:
—> 92 node_item = self.represent_data(item)
93 if not (isinstance(node_item, ScalarNode) and not node_item.style):
94 best_style = False

c:\development\data_science_competitions\drivendata_floodwater_v2\venv\lib\site-packages\yaml\representer.py in represent_data(self, data)
50 for data_type in data_types:
51 if data_type in self.yaml_multi_representers:
—> 52 node = self.yaml_multi_representers[data_type](self, data)
53 break
54 else:

c:\development\data_science_competitions\drivendata_floodwater_v2\venv\lib\site-packages\yaml\representer.py in represent_object(self, data)
329 if dictitems is not None:
330 dictitems = dict(dictitems)
–> 331 if function.name == ‘newobj’:
332 function = args[0]
333 args = args[1:]

AttributeError: ‘functools.partial’ object has no attribute ‘name

Thanks a bunch!

Hi, try setting your pandas version to 1.2.5, details on the bug.

1 Like