Skip to content

Commit

Permalink
fixup! Import example learning agents
Browse files Browse the repository at this point in the history
  • Loading branch information
juztamau5 committed Mar 10, 2024
1 parent f03fc0c commit b7e4aae
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 19 deletions.
6 changes: 4 additions & 2 deletions .github/workflows/python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ jobs:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
- os: ubuntu-20.04
python-version: '3.10'
- os: ubuntu-22.04
python-version: '3.11'

steps:
Expand All @@ -38,7 +40,7 @@ jobs:
uses: actions/cache@v4
with:
path: openai
key: ${{ runner.os }}-cache-openai-${{ hashFiles('openai/**') }}-
key: cache-openai-${{ matrix.os }}-${{ matrix.python-version }}-${{ hashFiles('openai/**') }}

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
Expand Down
2 changes: 1 addition & 1 deletion src/learning/retroai/retro_env.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
)
sys.exit(1)

retro.data.init_core_info(core_path())
retro.data.init_core_info(core_path(os.path.join(openai_root, "retro")))


def retro_get_system_info(system):
Expand Down
12 changes: 0 additions & 12 deletions src/learning/test/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,3 @@

# Add the project root to sys.path
sys.path.insert(0, project_root)

# Calculate the path to the openai directory two levels above the root
openai_root = os.path.join(project_root, "..", "..", "openai")

# Check if the openai directory exists, and add it to sys.path if it does
if os.path.exists(openai_root):
sys.path.insert(1, openai_root)
else:
# Warn the user that they need to build OpenAI files first
print(
"OpenAI directory not found. Please build OpenAI files first: cmake . && make -j"
)
29 changes: 25 additions & 4 deletions src/learning/test/test_random_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,30 @@
#
################################################################################

import retroai.retro_env # noqa: F401
import os
import sys

# Get the absolute path of the current script's directory
current_dir = os.path.dirname(os.path.abspath(__file__))

def test_example():
# Replace with an actual test
assert True
# Get the parent directory of the current directory, which is the project root
project_root = os.path.dirname(current_dir)

# Add the project root to sys.path
sys.path.insert(0, project_root)


import retroai.retro_env


def test_random_agent():
env = retroai.retro_env.retro_make(game="Airstriker-Genesis")

env.reset()
for _ in range(1000):
obs, rew, done, info = env.step(env.action_space.sample())
print(info)
if done:
env.reset()

env.close()

0 comments on commit b7e4aae

Please sign in to comment.