Skip to content

fix: Improve Windows runner path conversion and custom executable workflow - #1337

Merged
Revathyvenugopal162 merged 15 commits into
mainfrom
migration/pr-1328
Sep 24, 2026
Merged

Revathyvenugopal162 merged 15 commits into
mainfrom
migration/pr-1328

Conversation

@pyansys-ci-bot

@pyansys-ci-bot pyansys-ci-bot commented Sep 18, 2026 •

Copy link
Copy Markdown
Collaborator

This PR is a mirror pull request created from fix: handle comma characters in Windows paths to allow the code to access PyDyna CICD secrets.

Check the original PR made by @guhou-hvi for more details.

Closes #1328

Original pull request

fix: handle comma characters in Windows paths

Summary

Convert Windows input and working-directory paths containing commas to short filenames when the filesystem provides a usable short name. This addresses the comma-path case in #1083 without changing the public API.

The helper first queries GetShortPathNameW for the required buffer length, then reads the result. Conversion failure, an insufficient result buffer, or a result still containing commas preserves the original path with a warning. Paths without commas do not call the API.

Short names are not guaranteed on every filesystem. The fallback preserves the supplied path; it does not guarantee that LS-DYNA can run with commas.

Validation

  • 22 tests pass in tests/test_windows_runner.py -m run.
  • WinAPI mocks cover actual commas and spaces, a result longer than 260 characters, successful conversion, zero/error returns, exceptions, unavailable short names, and conversion of both input and working directory.
  • Ruff check and format check pass for both changed files.
  • A local integration with fix: align Windows custom executable workflow with Linux #1329 retains both sets of tests and passes all 27 cases.

The earlier tests named "with comma" did not contain a comma; they are replaced with targeted assertions. The earlier claim of a real OneDrive solve was not backed by saved evidence and is withdrawn here. These checks do not launch LS-DYNA.

Illustrative usage (not a solver execution record):

from ansys.dyna.core.run import run_dyna

run_dyna(
    r"C:\work\Company, Inc\input.k",
    executable=r"C:\Program Files\ANSYS Inc\v241\ansys\bin\winx64\lsdyna_dp.exe",
    working_directory=r"C:\work\Company, Inc",
)

Related to #1083.

PR #1331

Summary

Fix an UnboundLocalError when run_dyna() is called with an explicit container argument. The runner completes, but the function raises instead of returning stdout or the working directory. This exception does not delete solver output files.

Initialize container before the environment fallback. Preserve argument precedence, including explicit container=None disabling PYDYNA_RUN_CONTAINER, and use is not None on the touched lines.

Validation

  • Six unit tests using a mocked runner factory pass without Docker or LS-DYNA. They cover explicit and environment-selected containers, both return modes, argument precedence, and explicit None without automatic container_env.
  • The same minimal reproduction raises after the runner completes on 718b1ae and returns container-stdout with the fix.
  • With the same interpreter, dependencies and test selection, both baseline and fix report 62 passed, 3 skipped, 2 failed for test_docker_runner.py, test_windows_runner.py and test_localrun.py with -m run.
  • The matching failures are test_find_solver_with_version (fixture does not patch the imported lookup binding) and test_find_solver_latest_install (path separator expectation on Windows). This is a baseline comparison, not a fully passing regression suite.
  • Ruff check passes on the changed implementation and test file; Ruff format check passes on the new test file.

The change touches only argument handling and its tests. It shares local_solver.py with #1327 but changes a different region; current merge inspection finds no conflict. No solver or Docker container was executed.

PR #1329

Summary

Align Windows solver discovery with Linux by trying the saved solver path before a requested version or the latest installation. A missing saved file falls through to installation discovery.

When no matching lsprepost directory is found, log a warning and construct the solver command without an LS-Run script. If a matching directory exists, the expected script must still be available. Direct MPI execution requires a working mpiexec command and its libraries in the environment.

Validation and merge order

The existing branch has 19 passing Windows runner tests. A separate local integration with the corrected #1328 keeps both test sets and passes 27 cases. Its test-file conflict resolution is prepared locally; update the later-merged branch against current main before merging.

#1327 documents both fixes. Merge #1328 and #1329 before that documentation. These are mock/command-construction checks, not a real solver execution.

Related to #1083.

PR #1327

Summary

Document local run_dyna discovery and platform prerequisites consistently in the guide and API docstring. Both platforms try an explicit executable, a saved path, a requested version, then the latest installation; Windows additionally checks the saved file exists.

Clarify optional Windows environment scripts, MPI command/library requirements, comma-path conversion limits, the 2024 R1 version identifier (241), and supported memory units (MB/GB). Standalone executables require a prepared environment when no script directory is available.

Dependencies and validation

This describes the behavior after #1328 (including the validation corrections in bc40ff8) and #1329. Merge those changes before this documentation, or adapt the wording if their accepted behavior changes.

Focused Sphinx -E -W --keep-going succeeds from outside the workspace with verified source imports. Both Python examples parse, and the runtime AST is unchanged from 718b1ae after removing docstrings. Vale 3.21.0 reports zero document errors/warnings; the existing configuration emits W101 for its unsupported IgnoredFiles option.

Related to #1083.

guhou-hvi and others added 3 commits September 15, 2026 16:51
LS-DYNA cannot parse paths containing commas. Windows OneDrive paths often contain commas (e.g., 'OneDrive - Company Name'), causing run_dyna to fail for many users.

Add _get_short_path() helper that uses Windows GetShortPathNameW API to convert paths with commas to 8.3 short format. The conversion is applied in set_input() for both input_file and working_directory. If conversion fails, the original path is used with a warning.

Related to #1083
@Revathyvenugopal162 Revathyvenugopal162 changed the title migrated (PR 1328): fix: handle comma characters in Windows paths fix: handle comma characters in Windows paths Sep 18, 2026
@ansys-cla-bot

ansys-cla-bot Bot commented Sep 22, 2026 •

Copy link
Copy Markdown

All Contributor License Agreement (CLA) signatures have been captured successfully. Thanks for contributing!

@Revathyvenugopal162 Revathyvenugopal162 changed the title fix: handle comma characters in Windows paths fix: Improve Windows runner path conversion and custom executable workflow Sep 22, 2026
@github-actions github-actions Bot added the documentation Improvements or additions to documentation label Sep 22, 2026
@Revathyvenugopal162

Copy link
Copy Markdown
Contributor

#1327, #1328, #1329, #1331 are merged together as this all related to run-dyna module. @koubaa could you please review this PR? Thank you @guhou-hvi for the hard work behind this PR.

@Revathyvenugopal162
Revathyvenugopal162 enabled auto-merge (squash) September 23, 2026 15:03
@Revathyvenugopal162
Revathyvenugopal162 merged commit b92eb73 into main Sep 24, 2026
17 checks passed
@Revathyvenugopal162
Revathyvenugopal162 deleted the migration/pr-1328 branch September 24, 2026 13:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation testing Anything related to testing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants