Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Correction to file path error messaging #453

Merged
merged 4 commits into from
Jul 26, 2024

Conversation

cmbenne3
Copy link
Contributor

Summary

Small bug fix to improve the error messaging when aviary cannot find a file path.
Aviary now correctly displays the 'relative' path that was searched.

Related Issues

No issue number - discovered and fixed whilst debugging an Aviary aircraft model.

Details:

Aviary searches for 'path' in following order:

  1. absolute
  2. relative to current working directory
  3. relative to aviary package
  4. built in models

After each block of logic 'path' is overwritten so the next 'if' can determine whether 'path' exists.
The relative path string wasn't saved, and so the error message unhelpfully displayed the aviary_based path twice e.g:

FileNotFoundError: File not found in absolute path: concepts_library/a320neo/propulsion/aviaryPW1127G_eng_deck.csv, relative path: C:\Users\user\Git\Aviary\aviary\concepts_library\a320neo\propulsion\aviaryPW1127G_eng_deck.csv, or Aviary-based path: C:\Users\user\Git\Aviary\aviary\concepts_library\a320neo\propulsion\aviaryPW1127G_eng_deck.csv

This PR fixes the issue by saving the relative path string so that the error message can help the user identify where aviary is actually looking for the file:

FileNotFoundError: File not found in absolute path: concepts_library/a320neo/propulsion/aviaryPW1127G_eng_deck.csv, relative path: C:\Users\user\Git\ConceptsLibrary\concepts_library\a320neo\concepts_library\a320neo\propulsion\aviaryPW1127G_eng_deck.csv, or Aviary-based path: C:\Users\user\Git\Aviary\aviary\concepts_library\a320neo\propulsion\aviaryPW1127G_eng_deck.csv

Backwards incompatibilities

None

New Dependencies

None

Bennett added 2 commits July 23, 2024 19:14
@cmbenne3
Copy link
Contributor Author

It seems like autopep8 has broken the f string onto multiple lines, but won't allow you to put the explicit line break character in (it gets removed by autopep8)...
I found this issue hhatto/autopep8#712 which claims to have been fixed... Any ideas greatly appreciated!

@jkirk5 jkirk5 self-requested a review July 24, 2024 20:28
@jkirk5 jkirk5 added this pull request to the merge queue Jul 26, 2024
Merged via the queue into OpenMDAO:main with commit c0e93b8 Jul 26, 2024
6 checks passed
@cmbenne3 cmbenne3 deleted the rel_path_msg_fix branch July 31, 2024 16:43
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.

4 participants