Spaces:
Sleeping
Sleeping
| import time | |
| import random | |
| from openenv.core.env_client.client import EnvClient | |
| from models import CompilerOptAction, CompilerOptObservation | |
| def run_smoke_test(): | |
| # This script allows the Meta grader to verify your environment logic | |
| print("--- Starting OpenEnv Inference Test ---") | |
| # Pointing to the local server for the automated check | |
| client = EnvClient("http://localhost:8000", CompilerOptAction, CompilerOptObservation) | |
| print("Step 1: Resetting Environment...") | |
| obs = client.reset(task_id=1) | |
| print(f"Success! Initial Estimated Cost: {obs.estimated_cost}") | |
| print("\nStep 2: Applying 3 Random Optimization Passes...") | |
| for i in range(3): | |
| # Pick a random pass that hasn't been applied yet | |
| available_passes = obs.passes_available | |
| action_id = random.choice(available_passes) | |
| action = CompilerOptAction(pass_id=action_id) | |
| obs = client.step(action) | |
| print(f"Applied Pass ID {action_id} | Reward: {obs.reward} | New Cost: {obs.estimated_cost}") | |
| time.sleep(0.2) | |
| print("\n--- Inference Test Passed Successfully ---") | |
| if __name__ == "__main__": | |
| run_smoke_test() |