Fix binary_path silently dropped by options_to_kwargs()#726
Merged
Conversation
Agent-Logs-Url: https://github.com/waltsims/k-wave-python/sessions/2b340e29-96d4-4795-be98-d80ae80e5125 Co-authored-by: waltsims <8669206+waltsims@users.noreply.github.com>
Agent-Logs-Url: https://github.com/waltsims/k-wave-python/sessions/2b340e29-96d4-4795-be98-d80ae80e5125 Co-authored-by: waltsims <8669206+waltsims@users.noreply.github.com>
Copilot created this pull request from a session on behalf of
waltsims
May 12, 2026 01:01
View session
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #726 +/- ##
==========================================
+ Coverage 74.82% 75.04% +0.22%
==========================================
Files 56 56
Lines 8095 8107 +12
Branches 1577 1580 +3
==========================================
+ Hits 6057 6084 +27
+ Misses 1422 1404 -18
- Partials 616 619 +3
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Agent-Logs-Url: https://github.com/waltsims/k-wave-python/sessions/fd9e1ab3-1448-4f01-b58c-752897955bcc Co-authored-by: waltsims <8669206+waltsims@users.noreply.github.com>
Agent-Logs-Url: https://github.com/waltsims/k-wave-python/sessions/fd9e1ab3-1448-4f01-b58c-752897955bcc Co-authored-by: waltsims <8669206+waltsims@users.noreply.github.com>
…binary_path Agent-Logs-Url: https://github.com/waltsims/k-wave-python/sessions/fd9e1ab3-1448-4f01-b58c-752897955bcc Co-authored-by: waltsims <8669206+waltsims@users.noreply.github.com>
Agent-Logs-Url: https://github.com/waltsims/k-wave-python/sessions/5cd6f852-070e-4b38-b06a-39410dafaecb Co-authored-by: waltsims <8669206+waltsims@users.noreply.github.com>
Owner
|
@greptile-app |
- _execute(): rename the local from binary_path to resolved so the parameter (str | None) and the resolved Path don't share a name. - compat.py: collapse the WHY-comment on _binary_path access to 2 lines. - test_cpp_simulation.py: fold redundant test_custom_path_returns_path_object into test_custom_path_existing_file_is_returned (equality check already implies the Path type), drop section-separator comments, drop WHAT-only comments inside tests. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Owner
|
@greptile-apps re-review /simplify pass applied (3f48987):
All 23 tests pass; ruff clean. |
os.chmod(mode | S_IEXEC) is a no-op on Windows because Windows determines executability by file extension (.exe), not Unix bits. The production _execute() call is harmless on Windows but the test assertion isn't satisfiable. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
CppSimulation._resolve_binary_path(device, binary_path)static method with type annotations_resolve_binary_path: custom path valid, custom path missing, default OMP, default CUDA, macOS GPU error, non-macOS GPU missing binary_execute()sets executable bit on binarycompat.pyexplaining why_binary_pathis accessed directlyimport kwaveinside the default-path branch to avoid unnecessary import when custom binary is provided (reviewer feedback)Greptile Summary
This PR fixes a bug where
binary_pathset onSimulationExecutionOptionswas silently ignored byoptions_to_kwargs()because the property getter auto-resolved to a default value, making it impossible to distinguish a user-set path from the bundled default. The fix reads_binary_pathdirectly and propagates it throughkspaceFirstOrder→CppSimulation.run→_execute.compat.py: Readsopts._binary_path(the backing attribute) instead ofopts.binary_path(the auto-resolving property), and forwards it askwargs[\"binary_path\"].cpp_simulation.py: Extracts binary-path resolution into_resolve_binary_path()as a testable static method; theimport kwavestatement is correctly deferred inside the default-path branch so the bundled-binary lookup is skipped when a custom path is supplied.tests/: New unit tests cover the resolver's custom-path, default OMP/CUDA, missing-binary, and macOS GPU branches, plus a dedicated test that_execute()sets the executable bit.Confidence Score: 5/5
Safe to merge — the change is a targeted bug fix with no regressions to existing behaviour.
The fix correctly targets the root cause: the
binary_pathproperty onSimulationExecutionOptionsauto-resolves to a default, so reading_binary_pathdirectly is the right approach. Theimport kwavedeferral, the static-method extraction, and all new tests are correct. No existing code paths are altered except adding the missing propagation.No files require special attention.
Important Files Changed
opts._binary_pathdirectly to avoid the auto-resolving property, correctly forwarding user-set binary paths.import kwaveplacement;_executepropagatesbinary_pathcleanly.binary_pathparameter to the public API and threads it through toCppSimulation.run; ignored for non-cpp backends as documented.test_binary_pathtest verifies the compat layer correctly forwards_binary_path; uses constructor-level assignment so the non-existent path doesn't need to exist on disk.chmodside-effect in_execute; patching approach is correct for static methods.Sequence Diagram
sequenceDiagram participant Caller participant compat as options_to_kwargs() participant ksFO as kspaceFirstOrder() participant run as CppSimulation.run() participant exec as CppSimulation._execute() participant resolve as _resolve_binary_path() Caller->>compat: "SimulationExecutionOptions(binary_path=...)" Note over compat: reads opts._binary_path directly compat-->>ksFO: "kwargs["binary_path"] = path" Caller->>ksFO: "kspaceFirstOrder(..., binary_path=path)" ksFO->>run: "cpp_sim.run(..., binary_path=path)" run->>exec: "_execute(..., binary_path=path)" exec->>resolve: _resolve_binary_path(device, binary_path) alt custom binary_path provided resolve-->>exec: Path(binary_path) verified to exist else binary_path is None resolve->>resolve: import kwave Note over resolve: select OMP or CUDA binary resolve-->>exec: resolved Path verified to exist end exec->>exec: "resolved.chmod(... | S_IEXEC)" exec->>exec: subprocess.run([str(resolved), ...])Reviews (7): Last reviewed commit: "Merge branch 'master' into copilot/fix-r..." | Re-trigger Greptile