facebookresearch / ReAgent

A platform for Reasoning systems (Reinforcement Learning, Contextual Bandits, etc.)
https://reagent.ai
BSD 3-Clause "New" or "Revised" License
3.58k stars 521 forks source link

Only try to getattr if hasattr #683

Closed seemethere closed 2 years ago

seemethere commented 2 years ago

Summary: Follow up to https://fb.workplace.com/groups/1013818346200497/posts/1141315933450737

To avoid test failures like

ERROR: test_configure_optimizers (reagent.test.training.test_qrdqn.TestQRDQN)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/data/sandcastle/boxes/eden-trunk-hg-fbcode-fbsource/fbcode/buck-out/dev/gen/reagent/training_tests#binary,link-tree/reagent/test/training/test_qrdqn.py", line 179, in test_configure_optimizers
    optimizers = trainer.configure_optimizers()
  File "/data/sandcastle/boxes/eden-trunk-hg-fbcode-fbsource/fbcode/buck-out/dev/gen/reagent/training_tests#binary,link-tree/reagent/training/qrdqn_trainer.py", line 84, in configure_optimizers
    self.q_network_optimizer.make_optimizer_scheduler(
  File "/data/sandcastle/boxes/eden-trunk-hg-fbcode-fbsource/fbcode/buck-out/dev/gen/reagent/training_tests#binary,link-tree/reagent/optimizer/union.py", line 62, in make_optimizer_scheduler
    return self.value.make_optimizer_scheduler(params)
  File "/data/sandcastle/boxes/eden-trunk-hg-fbcode-fbsource/fbcode/buck-out/dev/gen/reagent/training_tests#binary,link-tree/reagent/optimizer/optimizer.py", line 72, in make_optimizer_scheduler
    filtered_args = {
  File "/data/sandcastle/boxes/eden-trunk-hg-fbcode-fbsource/fbcode/buck-out/dev/gen/reagent/training_tests#binary,link-tree/reagent/optimizer/optimizer.py", line 73, in <dictcomp>
    k: getattr(self, k)
AttributeError: 'Adam' object has no attribute 'fused'

Differential Revision: D39750850

facebook-github-bot commented 2 years ago

This pull request was exported from Phabricator. Differential Revision: D39750850