fix: add TI anchor metadata to result.json#115
Conversation
📝 WalkthroughWalkthroughThis PR adds support for incorporating HTI (Hamiltonian temperature integration) anchor values into TI (thermodynamic integration) result computation. The ChangesHTI Anchor Path Integration
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@dpti/ti.py`:
- Around line 460-461: post_tasks currently ignores the newly added hti_path
parameter and continues to emit the deprecated plain-text "result" file; update
the post_tasks function to include hti metadata (hti_path and derived keys like
"T0" and "p0") into the JSON result object that is written out (ensure the
hti_path parameter passed into post_tasks is referenced and inserted into the
result dict created in post_tasks), and remove or stop writing the legacy
plain-text result file (the code block that writes the simple "result" file in
the same function should be deleted or disabled) so only the updated JSON with
hti_path/T0/p0 is produced.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
| hti_path=None, | ||
| ): |
There was a problem hiding this comment.
post_tasks still misses HTI metadata and still writes deprecated result file.
hti_path is added at Line 460 but never used in post_tasks, so result.json from the default inte flow does not include hti_path/T0/p0. Also, Line 692 still writes the plain-text result file that this PR intends to remove.
Suggested patch
@@
- info = {"start_point_info": info0, "end_point_info": info1, "data": data}
+ info = {"start_point_info": info0, "end_point_info": info1, "data": data}
+ if hti_path is not None:
+ info["hti_path"] = os.path.abspath(hti_path)
+ hti_result_json = os.path.join(hti_path, "result.json")
+ hti_input_json = os.path.join(hti_path, "in.json")
+ if os.path.isfile(hti_result_json) and os.path.isfile(hti_input_json):
+ with open(hti_result_json) as fp:
+ jdata_hti = json.load(fp)
+ with open(hti_input_json) as fp:
+ jdata_hti_in = json.load(fp)
+ t0, p0 = _get_hti_anchor_tp(jdata_hti, jdata_hti_in)
+ if t0 is not None:
+ info["T0"] = t0
+ if p0 is not None:
+ info["p0"] = p0
@@
- with open(os.path.join(output_dir, "result"), "w") as f:
- f.write(result)
with open(os.path.join(output_dir, "result.json"), "w") as f:
f.write(json.dumps(info))Also applies to: 692-695
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@dpti/ti.py` around lines 460 - 461, post_tasks currently ignores the newly
added hti_path parameter and continues to emit the deprecated plain-text
"result" file; update the post_tasks function to include hti metadata (hti_path
and derived keys like "T0" and "p0") into the JSON result object that is written
out (ensure the hti_path parameter passed into post_tasks is referenced and
inserted into the result dict created in post_tasks), and remove or stop writing
the legacy plain-text result file (the code block that writes the simple
"result" file in the same function should be deleted or disabled) so only the
updated JSON with hti_path/T0/p0 is produced.
Summary
This PR now includes the complete set of TI output-handling changes that were validated locally.
Included changes
Common TI output behavior (
tiandti_water)result.outti.outresultfileAnchor-aware output directory naming
When
-H/--htiis provided, write outputs under:JOB/<hti_name>.T0_<...>.p0_<...>/This avoids name collisions when different HTI anchors reuse the same HTI folder name.
Anchor metadata in
result.jsonWhen
-H/--htiis provided,result.jsonnow includes:hti_pathT0p0No-
-Hbehavior remains compatibleWithout
-H, outputs remain at the original root-level locations:JOB/result.jsonJOB/ti.outJOB/result.outValidation
Locally verified with:
dpti ti compute ti.p -H hti.3 -t 50000Observed behavior:
ti.p/hti.3.T0_1600.p0_50000/result.jsonresult.outti.outresult.jsoncontains:hti_pathT0p0resultis not created