Skip to content

Commit

Permalink
add script for explicit download roms
Browse files Browse the repository at this point in the history
  • Loading branch information
jjshoots committed Feb 23, 2024
1 parent 01d6b79 commit cc02305
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 108 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,9 @@ jobs:
- name: Build
run: python -m pip install --user --verbose .[test]

- name: Download and extract roms
run: ale-accept-license-install-roms

- name: Test
run: python -m pytest

Expand Down
3 changes: 1 addition & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,12 @@ documentation = "https://github.com/mgbellemare/Arcade-Learning-Environment/tree
changelog = "https://github.com/mgbellemare/Arcade-Learning-Environment/blob/master/CHANGELOG.md"

[project.scripts]
ale-import-roms = "ale_py.scripts.import_roms:main"
ale-accept-license-install-roms = "ale_py.roms:_download_roms"

[tool.setuptools]
packages = [
"ale_py",
"ale_py.roms",
"ale_py.scripts"
]
package-dir = {ale_py = "src/python"}
package-data = {"ale_py" = ["py.typed", "*.pyi", "**/*.pyi"], "ale_py.roms" = ["md5.json"]}
Expand Down
13 changes: 9 additions & 4 deletions src/python/roms/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ def _download_roms():
rom_path = Path(__file__).parent / rom_name
open(rom_path, "wb").write(rom_bytes)

print(f"Downloaded and extracted {rom_name}.")


def get_rom_path(name: str) -> Path | None:
"""Expects name as a snake_case name, returns the full path of the .bin file if it's valid, otherwise returns None."""
Expand All @@ -76,10 +78,13 @@ def get_rom_path(name: str) -> Path | None:
# if the path exists, just return it
return bin_path
else:
# if it doesn't exist, we need to install the roms, then return it
print(f"Could not find rom {name}, downloading roms to device...")
_download_roms()
return bin_path
# if it doesn't exist, prompt the user to download it, just quit here.
print(
f"Looks like the rom {name} could not be found. "
"To install all roms, please run `ale-accept-license-install-roms` "
"to accept the license agreement and install all available roms."
)
exit()


def get_all_rom_ids() -> list[str]:
Expand Down
Empty file removed src/python/scripts/__init__.py
Empty file.
102 changes: 0 additions & 102 deletions src/python/scripts/import_roms.py

This file was deleted.

0 comments on commit cc02305

Please sign in to comment.