in src/open_r1/utils/code_providers.py [0:0]
def execute_scripts(self, scripts: List[str], languages: List[str]) -> List[float]:
"""Execute scripts using MorphCloud Sandbox API.
Args:
scripts: List of Python scripts to execute
language: Programming language
Returns:
List of float rewards (one per script)
"""
if hasattr(self, "routed_sandbox"):
try:
results = self.routed_sandbox.run_code(
scripts=scripts,
languages=languages,
timeout=90,
request_timeout=96,
)
rewards = []
for result in results:
try:
reward = float(result.text)
rewards.append(reward)
except (ValueError, AttributeError):
rewards.append(0.0)
return rewards
except Exception as e:
print(f"Error from MorphCloud router: {e}")
return [0.0] * len(scripts)
import asyncio
try:
rewards = asyncio.run(self._run_async(scripts, languages, self.num_parallel))
except Exception as e:
print(f"Error from MorphCloud executor: {e}")
rewards = [0.0] * len(scripts)
return rewards