Skip to content

fix: add TI anchor metadata to result.json#115

Open
Yi-FanLi wants to merge 2 commits into
deepmodeling:develfrom
Yi-FanLi:feat-ti-output-layout-clean
Open

fix: add TI anchor metadata to result.json#115
Yi-FanLi wants to merge 2 commits into
deepmodeling:develfrom
Yi-FanLi:feat-ti-output-layout-clean

Conversation

@Yi-FanLi
Copy link
Copy Markdown
Collaborator

@Yi-FanLi Yi-FanLi commented May 12, 2026

Summary

This PR now includes the complete set of TI output-handling changes that were validated locally.

Included changes

Common TI output behavior (ti and ti_water)

  • store full screen output in result.out
  • keep ti.out
  • stop writing the redundant plain-text result file

Anchor-aware output directory naming

When -H/--hti is 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.json

When -H/--hti is provided, result.json now includes:

  • hti_path
  • T0
  • p0

No--H behavior remains compatible

Without -H, outputs remain at the original root-level locations:

  • JOB/result.json
  • JOB/ti.out
  • JOB/result.out

Validation

Locally verified with:

  • dpti ti compute ti.p -H hti.3 -t 50000

Observed behavior:

  • output directory: ti.p/hti.3.T0_1600.p0_50000/
  • generated files:
    • result.json
    • result.out
    • ti.out
  • result.json contains:
    • hti_path
    • T0
    • p0
  • plain-text result is not created

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 12, 2026

📝 Walkthrough

Walkthrough

This PR adds support for incorporating HTI (Hamiltonian temperature integration) anchor values into TI (thermodynamic integration) result computation. The hti_path parameter is threaded from the CLI through compute_task and post_tasks_mbar, enabling external anchor temperature and pressure values to be loaded and embedded in the final result JSON.

Changes

HTI Anchor Path Integration

Layer / File(s) Summary
Function signature updates for hti_path parameter
dpti/ti.py
post_tasks, post_tasks_mbar, and compute_task function signatures each add an hti_path=None parameter to accept the HTI directory path.
HTI anchor value extraction and injection
dpti/ti.py
In post_tasks_mbar, when hti_path is provided, load result.json and in.json from that directory, extract anchor temperature and pressure via _get_hti_anchor_tp, and inject them into the output info JSON as T0 and/or p0. The plain-text result file write is removed in favor of result.json containing the augmented fields.
End-to-end parameter threading
dpti/ti.py
compute_task forwards hti_path to post_tasks when inte_method == "inte", and handle_compute passes hti_path (from CLI --hti option) into compute_task call.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related PRs

  • deepmodeling/dpti#113: Both PRs modify dpti/ti.py's compute/post-processing paths to accept an HTI-related path and load HTI result.json/in.json for anchoring.
  • deepmodeling/dpti#111: Related effort to add and route HTI anchor temperature/pressure into TI result handling.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title 'fix: add TI anchor metadata to result.json' accurately describes the main change: adding anchor temperature/pressure metadata (T0, p0) to the result.json file.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: e3676cc3-104a-4b59-817b-d7c4223016b1

📥 Commits

Reviewing files that changed from the base of the PR and between 325607c and fc2445d.

📒 Files selected for processing (1)
  • dpti/ti.py

Comment thread dpti/ti.py Outdated
Comment on lines 460 to 461
hti_path=None,
):
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant