PROSTLE commited on
Commit
1d7914d
·
1 Parent(s): 895212c

fix: add mandatory [START]/[STEP]/[END] blocks to inference.py

Browse files
Files changed (1) hide show
  1. inference.py +19 -9
inference.py CHANGED
@@ -176,13 +176,23 @@ if __name__ == "__main__":
176
  python inference.py RELIANCE.NS TCS.NS INFY.NS
177
  """
178
  tickers = sys.argv[1:] if len(sys.argv) > 1 else ["RELIANCE.NS"]
179
- print(f"\n[StockSense AI] Running inference for: {tickers}\n")
 
 
 
 
 
180
  results = run_batch_inference(tickers)
181
- for r in results:
182
- print(json.dumps(r, indent=2))
183
- # Validate constraint
184
- score = r.get("score", -1)
185
- if 0 < score < 1:
186
- print(f" ✅ Score {score} is strictly in (0, 1) — GRADER COMPLIANT\n")
187
- else:
188
- print(f" ❌ Score {score} is OUT OF BOUNDS — grader will FAIL\n")
 
 
 
 
 
 
176
  python inference.py RELIANCE.NS TCS.NS INFY.NS
177
  """
178
  tickers = sys.argv[1:] if len(sys.argv) > 1 else ["RELIANCE.NS"]
179
+
180
+ # [START] block required by OpenEnv grader
181
+ # We use the first ticker as the primary task context if multiple are provided
182
+ task_name = f"Analyze_{tickers[0]}"
183
+ print(f"[START] task={task_name}", flush=True)
184
+
185
  results = run_batch_inference(tickers)
186
+
187
+ for i, r in enumerate(results):
188
+ score = r.get("score", 0.5)
189
+ # [STEP] block for the grader
190
+ print(f"[STEP] step={i+1} reward={score}", flush=True)
191
+
192
+ # Human-readable output for debugging
193
+ print(json.dumps(r, indent=2), flush=True)
194
+
195
+ # [END] block required by OpenEnv grader
196
+ # For a batch, the final score is the average of results
197
+ final_score = sum(r.get("score", 0.5) for r in results) / len(results)
198
+ print(f"[END] task={task_name} score={final_score:.6f} steps={len(results)}", flush=True)