Parth3841 commited on
Commit
2c7ce7f
·
verified ·
1 Parent(s): 7c2f148

Upload folder using huggingface_hub

Browse files
Files changed (1) hide show
  1. inference.py +33 -0
inference.py ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ import time
3
+ import random
4
+ from openenv.core.env_client.client import EnvClient
5
+ from models import CompilerOptAction, CompilerOptObservation
6
+
7
+ def run_smoke_test():
8
+ # This script allows the Meta grader to verify your environment logic
9
+ print("--- Starting OpenEnv Inference Test ---")
10
+
11
+ # Pointing to the local server for the automated check
12
+ client = EnvClient("http://localhost:8000", CompilerOptAction, CompilerOptObservation)
13
+
14
+ print("Step 1: Resetting Environment...")
15
+ obs = client.reset(task_id=1)
16
+ print(f"Success! Initial Estimated Cost: {obs.estimated_cost}")
17
+
18
+ print("\nStep 2: Applying 3 Random Optimization Passes...")
19
+ for i in range(3):
20
+ # Pick a random pass that hasn't been applied yet
21
+ available_passes = obs.passes_available
22
+ action_id = random.choice(available_passes)
23
+
24
+ action = CompilerOptAction(pass_id=action_id)
25
+ obs = client.step(action)
26
+
27
+ print(f"Applied Pass ID {action_id} | Reward: {obs.reward} | New Cost: {obs.estimated_cost}")
28
+ time.sleep(0.2)
29
+
30
+ print("\n--- Inference Test Passed Successfully ---")
31
+
32
+ if __name__ == "__main__":
33
+ run_smoke_test()