-
Notifications
You must be signed in to change notification settings - Fork 142
feat: improving inquire #4035
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
feat: improving inquire #4035
Conversation
|
Thanks for opening a Pull Request. If you want to perform a review write a comment saying: @ansys-reviewer-bot review |
Reviewer's GuideRefactors the inquire method to add non-interactive exit handling, streamline multiline output processing, support boolean responses for certain functions, and enable numeric fallback parsing. File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @germa89 - I've reviewed your changes - here's some feedback:
- Update the
inquiremethod docstring to mention the new None return in non-interactive mode. - Add a guard to check for an '=' in the response before splitting, to avoid unexpected
IndexError. - Include a unit test for the branch that raises on unexpected boolean output to ensure correct error handling.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Update the `inquire` method docstring to mention the new None return in non-interactive mode.
- Add a guard to check for an '=' in the response before splitting, to avoid unexpected `IndexError`.
- Include a unit test for the branch that raises on unexpected boolean output to ensure correct error handling.
## Individual Comments
### Comment 1
<location> `src/ansys/mapdl/core/mapdl_extended.py:1466` </location>
<code_context>
+
+ # Check if the function is to check existence
+ # so it makes sense to return a boolean
+ if func.upper() in ["EXIST", "WRITE", "READ", "EXEC"]:
+ if "1.0" in response:
+ return True
+ elif "0.0" in response:
+ return False
+ else:
+ raise MapdlRuntimeError(
+ f"Unexpected output from 'mapdl.inquire' function:\n{response}"
+ )
- return response
</code_context>
<issue_to_address>
String matching for boolean response may be fragile.
Using substring matching for '1.0' and '0.0' may cause incorrect results if these values appear elsewhere in the response. Use an exact match to ensure correct boolean conversion.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
…sys/pymapdl into feat/improving-inquire
|
@pyansys-ci-bot LGTM. |
pyansys-ci-bot
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #4035 +/- ##
==========================================
+ Coverage 89.05% 89.14% +0.09%
==========================================
Files 187 187
Lines 14970 14993 +23
==========================================
+ Hits 13331 13365 +34
+ Misses 1639 1628 -11 🚀 New features to boost your workflow:
|
… file existence checks

Description
As the title.
Issue linked
Extracted from #1300.
Checklist
draftif it is not ready to be reviewed yet.feat: adding new MAPDL command)Summary by Sourcery
Improve the inquire method to provide typed and consistent return values, handle missing responses gracefully, and support boolean queries.
Enhancements: