mirror of
https://github.com/open-thought/reasoning-gym.git
synced 2026-04-23 16:55:05 +00:00
black formatting
This commit is contained in:
parent
5a7cbe7c24
commit
c8fcb6ca02
6 changed files with 4291 additions and 3733 deletions
|
|
@ -1,33 +1,32 @@
|
|||
import os
|
||||
import importlib.util
|
||||
import os
|
||||
from datetime import datetime
|
||||
from typing import Dict, Any
|
||||
from typing import Any, Dict
|
||||
|
||||
|
||||
def test_generator_files(directory_path: str) -> None:
|
||||
"""Test all generator files in directory"""
|
||||
|
||||
|
||||
# Setup logging
|
||||
timestamp = datetime.now().strftime("%Y%m%d_%H%M%S")
|
||||
log_file = f"generator_tests_{timestamp}.log"
|
||||
|
||||
with open(log_file, 'w') as log:
|
||||
|
||||
with open(log_file, "w") as log:
|
||||
# Walk through directory
|
||||
for root, _, files in os.walk(directory_path):
|
||||
for file in files:
|
||||
if not file.endswith('.py'):
|
||||
if not file.endswith(".py"):
|
||||
continue
|
||||
|
||||
|
||||
filepath = os.path.join(root, file)
|
||||
try:
|
||||
# Import module dynamically
|
||||
spec = importlib.util.spec_from_file_location(
|
||||
file[:-3], filepath
|
||||
)
|
||||
spec = importlib.util.spec_from_file_location(file[:-3], filepath)
|
||||
module = importlib.util.module_from_spec(spec)
|
||||
spec.loader.exec_module(module)
|
||||
|
||||
|
||||
# Check for original_example function
|
||||
if hasattr(module, 'original_example'):
|
||||
if hasattr(module, "original_example"):
|
||||
try:
|
||||
result = module.original_example()
|
||||
if isinstance(result, dict):
|
||||
|
|
@ -38,16 +37,16 @@ def test_generator_files(directory_path: str) -> None:
|
|||
message = f"ERROR: {file} - execution failed: {str(e)}\n"
|
||||
else:
|
||||
message = f"ERROR: {file} - no original_example() found\n"
|
||||
|
||||
|
||||
except Exception as e:
|
||||
message = f"ERROR: {file} - import failed: {str(e)}\n"
|
||||
|
||||
|
||||
# Log result
|
||||
log.write(message)
|
||||
print(message, end='')
|
||||
print(message, end="")
|
||||
|
||||
|
||||
# Usage
|
||||
if __name__ == "__main__":
|
||||
generator_path = "../reasoning_gym/arithmetic/gsm_symbolic"
|
||||
test_generator_files(generator_path)
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue