Skip to content

fix(explorer): absolutize spliced stat-mech file paths to the source's directory - #201

Merged
alongd merged 1 commit into
i019-seed-labelfrom
i021-spliced-path
Aug 25, 2026
Merged

fix(explorer): absolutize spliced stat-mech file paths to the source's directory#201
alongd merged 1 commit into
i019-seed-labelfrom
i021-spliced-path

Conversation

@alongd

@alongd alongd commented Aug 23, 2026

Copy link
Copy Markdown
Member

Stacked on #200#199#198#197. Base is i020-generated-modelchem, so this diff shows only its own change; GitHub retargets as each parent merges. Review in order.

What this fixes

T3's hybrid writer references a QM transition state's stat-mech data by a relative path — transitionState('TS2', 'qm/TS2.py'), with the qm/ tree vendored beside the hybrid. That convention is deliberate and keeps a run directory portable. But input_file.py splices that line verbatim into a generated Arkane input in a different directory, and Arkane then cannot find the file:

FileNotFoundError: [Errno 2] No such file or directory: 'qm/TS2.py'
  at arkane/statmech.py:372

The mechanism is worth stating precisely, because the obvious reading is wrong. arkane/input.py:690 does job.path = os.path.join(directory, job.path) — Arkane does rebase, against the input file's directory. That is exactly the problem: the input file is the generated explorer input, not the hybrid, so a path meaningful relative to the hybrid is rebased against a directory with no qm/ tree in it.

The change

Each spliced species() / transitionState() external file path — Arkane's <name>(label, path) form — is rewritten from relative to absolute, anchored at the source file's own directory, where the vendored qm/ tree actually lives. Adds _stat_mech_file_path_node, an edit in the existing AST walk, and a stat_mech_paths_absolutized record on ExplorerInputSummary.

The hybrid writer's relative convention is untouched — only the spliced copy is rewritten, so hybrids stay portable. A string literal remains a string literal, so neither the inbound source guard nor the outbound self-check is weakened, and there is no chdir.

Position-dependence sweep

Since this is the second defect caused by the same verbatim splice moving text into a new context, the other position-dependent references were enumerated rather than assumed:

  • species() / transitionState() external paths — the defect; fixed for both call names.
  • Log('logs/TS2/...') inside qm/TS2.py — a different level. statmech.py:319 rebases those against the species file's own directory, which is now correct, so they resolve. Confirmed by the run reading them.
  • database() carries library names, not paths.

Testing

  • Driven on the real artifact. The emitted line is now transitionState('TS2', '/abs/path/to/qm/TS2.py'); Arkane loads the transition state and its logs and proceeds to the master-equation solve. No cluster, no quantum chemistry.
  • test_real_hybrid_transition_state_path_is_absolutized_to_an_existing_file asserts os.path.isfile(emitted_path) — that it resolves to a file that exists, not merely that it is absolute.
  • The real qm/TS2.py is committed beside the existing hybrid fixture so that assertion is meaningful.
  • Mutation: neutralising the absolutization branch turns it red; restored, green.
  • tests/test_pdep: 1930 passed, 133 s.

Known next failure, not chased

The run now gets all the way to the physics and stops there: numpy.linalg.LinAlgError: Singular matrix at rmgpy/pdep/msc.pyx:147, in the Modified Strong Collision solve. That is a numerical/scientific issue rather than a plumbing one, and it is tracked separately. With this change, the round-0 → round-1 handoff no longer fails on any file-contract defect.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes explorer handoffs by converting relative stat-mechanics paths to absolute source-relative paths when generating inputs.

Changes:

  • Absolutizes species() and transitionState() external paths.
  • Records rewritten paths in ExplorerInputSummary.
  • Adds regression coverage and a real stat-mechanics fixture.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Summary
t3/pdep/explorer/input_file.py Rewrites and records stat-mechanics paths. Moderate issue: positional-label species(label, path) forms are rewritten but not fully supported by species registration and bath-gas handling.
tests/test_pdep/test_explorer_input_file.py Tests path absolutization and resolution to an existing file.
tests/data/pdep_hybrid/cho2_round0/qm/TS2.py Adds the referenced stat-mechanics fixture.
Suppressed comments (1)

t3/pdep/explorer/input_file.py:367

  • This new branch explicitly promises to absolutize both species() and transitionState() file references, but the regression coverage only drives the latter. Please add an end-to-end case for the positional species('S', 'qm/S.py') form (and assert its summary record/path), so a species-specific argument-handling regression cannot pass unnoticed.
        if call_name in ('species', 'transitionState'):
            path_node = _stat_mech_file_path_node(call)
            if path_node is not None and not os.path.isabs(path_node.value):
                absolute_path = os.path.join(source_dir, path_node.value)

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread t3/pdep/explorer/input_file.py
Base automatically changed from i020-generated-modelchem to i019-seed-label August 25, 2026 05:30
@alongd
alongd force-pushed the i021-spliced-path branch from eaa2c31 to 0f9a870 Compare August 25, 2026 06:38
…s directory

The hybrid writer emits transitionState('TS2', 'qm/TS2.py') with the qm/ tree
vendored beside the hybrid -- a path relative to the hybrid, deliberately portable.
But write_arkane_explorer_input_file splices that block verbatim into a generated
Arkane explorer input in a DIFFERENT directory with no qm/ sibling, so Arkane
resolves the raw 'qm/TS2.py' against its own working directory and dies with
FileNotFoundError at arkane/statmech.py load time.

Rewrite each spliced species()/transitionState() external file path (Arkane's
<name>(label, path) form) from relative to absolute, anchored at the SOURCE file's
own directory, so it resolves wherever the generated file lands and whatever cwd
Arkane runs in. An absolute path is passed through Arkane's os.path.join rebase
unchanged; the inner Log('logs/...') references then rebase (statmech.py:319)
relative to the now-correct species-file directory and resolve too. The hybrid's
relative convention is untouched -- only the spliced copy is edited -- and a string
literal stays a string literal, so both guards in the module still accept it. The
rewrite is recorded in ExplorerInputSummary.stat_mech_paths_absolutized.

Regression test drives the real committed round-0 hybrid through the writer into an
unrelated directory and asserts the emitted path resolves to a file that exists
(os.path.isfile), with the real qm/TS2.py vendored beside the fixture.
@alongd
alongd force-pushed the i021-spliced-path branch from 0f9a870 to 963aa83 Compare August 25, 2026 08:51
@alongd
alongd merged commit 0a31c35 into i019-seed-label Aug 25, 2026
@alongd
alongd deleted the i021-spliced-path branch August 25, 2026 09:03
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.

2 participants