Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions rl_unplugged/atari_dqn.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
"!pip install dm-acme[reverb]\n",
"!pip install dm-acme[tf]\n",
"!pip install dm-sonnet\n",
"!pip install gin-config==0.3.0\n",
"!pip install dopamine-rl==3.1.2\n",
"!pip install atari-py\n",
"!git clone https://github.com/deepmind/deepmind-research.git\n",
Expand Down
1 change: 1 addition & 0 deletions rl_unplugged/bsuite.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
"!pip install dm-acme[reverb]\n",
"!pip install dm-acme[tf]\n",
"!pip install dm-sonnet\n",
"!pip install gin-config==0.3.0\n",
"!pip install dopamine-rl==3.1.2\n",
"!pip install atari-py\n",
"!pip install dm_env\n",
Expand Down
81 changes: 81 additions & 0 deletions rl_unplugged/test_atari_import.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
# Copyright 2020 DeepMind Technologies Limited.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Test script to verify the atari module can be imported without gin-config errors.

This test verifies the fix for GitHub issue #428:
https://github.com/google-deepmind/deepmind-research/issues/428

The issue was that newer versions of gin-config renamed the 'blacklist' parameter
to 'denylist' in gin.configurable(), causing a TypeError when importing the atari
module (which depends on dopamine-rl, which uses gin-config).

The fix is to pin gin-config==0.3.0 which still supports the 'blacklist' parameter.
"""

import sys
import unittest


class TestAtariImport(unittest.TestCase):
"""Test that the atari module can be imported without errors."""

def test_import_atari_module(self):
"""Test that importing rl_unplugged.atari does not raise TypeError.

This test verifies that the gin-config blacklist/denylist issue is fixed.
The error that was occurring:
TypeError: configurable() got an unexpected keyword argument 'blacklist'
"""
try:
# This import chain triggers the gin-config issue:
# atari.py -> dopamine.discrete_domains.atari_lib -> gin.configurable
from rl_unplugged import atari
# If we get here without TypeError, the fix is working
self.assertTrue(True)
except ImportError as e:
# Dependencies not installed - skip the test
self.skipTest(f"Dependencies not installed: {e}")
except TypeError as e:
if "blacklist" in str(e) or "denylist" in str(e):
self.fail(
f"gin-config compatibility issue not fixed: {e}\n"
"Make sure gin-config==0.3.0 is installed."
)
raise

def test_atari_module_has_expected_attributes(self):
"""Test that the atari module has expected functions after import."""
try:
from rl_unplugged import atari

# Check that key functions exist
self.assertTrue(hasattr(atari, 'dataset'))
self.assertTrue(hasattr(atari, 'environment'))
self.assertTrue(hasattr(atari, 'AtariDopamineWrapper'))
self.assertTrue(hasattr(atari, 'TUNING_SUITE'))
self.assertTrue(hasattr(atari, 'TESTING_SUITE'))
self.assertTrue(hasattr(atari, 'ALL'))
except ImportError as e:
self.skipTest(f"Dependencies not installed: {e}")
except TypeError as e:
if "blacklist" in str(e) or "denylist" in str(e):
self.fail(
f"gin-config compatibility issue not fixed: {e}\n"
"Make sure gin-config==0.3.0 is installed."
)
raise


if __name__ == '__main__':
unittest.main()