Spaces:
Sleeping
Sleeping
fix: add mandatory [START]/[STEP]/[END] blocks to inference.py
Browse files- 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 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 180 |
results = run_batch_inference(tickers)
|
| 181 |
-
|
| 182 |
-
|
| 183 |
-
|
| 184 |
-
|
| 185 |
-
|
| 186 |
-
|
| 187 |
-
|
| 188 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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)
|