Skip to content

fix: select the newest file in last_created (migrated PR 4932) - #4967

Merged
germa89 merged 4 commits into
mainfrom
migration/pr-4932
Nov 20, 2026
Merged

germa89 merged 4 commits into
mainfrom
migration/pr-4932

Conversation

@pyansys-ci-bot

Copy link
Copy Markdown
Contributor

This PR is a mirror pull request created from fix: select the newest file in last_created to allow the code to access PyMAPDL CICD secrets.

Check the original PR made by @Tonylo-lab for more details.

Closes #4932

Original pull request

fix: select the newest file in last_created

Description

last_created() currently returns the last filename for every nonempty input, regardless of creation times. len(set(ctimes)) is always nonzero for such inputs, so the already-computed np.argmax result is never used.

Change this condition to len(set(ctimes)) == 1. This selects the newest file when times differ while preserving the documented rule of returning the last filename when all creation times are equal.

Add 10 parameterized/edge cases in tests/test_misc.py: all six orders of three files with distinct times, three equal-time/single-file cases, and the existing empty-input error behavior.

Issue linked

This addresses a locally reproduced defect on main at 154828f; no new issue was opened. The helper is used by result-file selection, including MapdlGrpc._distributed_result_file. With a newer file0.rth and an older file0.rst, that getter currently chooses the older .rst file.

Validation

Tested on Windows, Python 3.12.15, PyMAPDL 0.74.dev0, pytest 9.1.1 and NumPy 2.5.4.

  • The same targeted selection in tests/test_misc.py gives 4 failed / 7 passed before the fix and 11 passed after it (40 unrelated cases deselected). This includes the existing real-file creation-time test.
  • The regression cases fix only the timestamp helper's return values for deterministic cross-platform testing and execute the real selection function.
  • A separate probe creates three real files with distinct Windows creation times. The original selects correctly for 2 of their 6 permutations; the fix selects correctly for all 6.
  • The same probe exercises the actual _distributed_result_file getter with a minimal local context and real files: it selects the older .rst before the fix and the newer .rth afterward. These are synthetic files, with no MAPDL connection or solver-generated contents.
  • last_created() has 100% line and branch coverage (5 statements and 2 branches).
  • All 15 pre-commit hooks applicable to the two changed files pass, including mypy, numpydoc, Black, isort, flake8, Bandit, spelling, license and text checks.
  • git diff --check passes, and the final patch matches the reviewed draft exactly.

Known baseline check failure: full pre-commit run --all-files stops at src/ansys/mapdl/core/errors.py:601: Module has no attribute "SIGKILL". Windows does not provide signal.SIGKILL. The same single error reproduces on unmodified 154828f (325 source files checked); it is tracked separately in #4903 / #4904. This PR does not change that code.

Not run: MAPDL live-server/solver tests or the full test suite. No MAPDL process was launched.

Checklist

  • Tested the change locally and added regression tests.
  • Verified the changed function's coverage and applicable checks.
  • Reviewed the complete two-file diff.
  • Followed the branch and PR naming conventions.
  • The existing docstring already specifies the intended behavior; no documentation or hand-written changelog fragment is needed for this correction.

Prepared and verified with assistance from Codex.

@pyansys-ci-bot
pyansys-ci-bot requested a review from a team as a code owner November 19, 2026 15:09
@github-actions github-actions Bot added the bug Issue, problem or error in PyMAPDL label Nov 19, 2026
@germa89 germa89 changed the title fix: select the newest file in last_created (migrated PR #4932) fix: select the newest file in last_created (migrated PR 4932) Nov 19, 2026
@codecov

codecov Bot commented Nov 19, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.92%. Comparing base (8d31092) to head (4b6a631).
⚠️ Report is 14 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4967      +/-   ##
==========================================
- Coverage   91.94%   91.92%   -0.03%     
==========================================
  Files         247      247              
  Lines       18545    18546       +1     
==========================================
- Hits        17052    17049       -3     
- Misses       1493     1497       +4     
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@germa89
germa89 merged commit 8316e5d into main Nov 20, 2026
59 checks passed
@germa89
germa89 deleted the migration/pr-4932 branch November 20, 2026 07:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Issue, problem or error in PyMAPDL

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants