ansys / ansys/pyensight

Add Improved debugging for the EnSight native Python API

Open
#280 2 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
Python
Stars
10
Forks
2
Avg merge
8h 40m
Merged PRs (30d)
4

Description

### 📝 Description of the feature

The EnSight native Python API uses return codes to report errors. There exists a mechanism (sendmesgoptions) to make those calls throw exceptions instead. The problem with sendmesgoptions is that one cannot leave EnSight in that mode or the GUI/other aspects of EnSight will become non-responsive. The correct use of the function is in a try: finally: clause.

PyEnSight wraps these functions at a higher level and can control this behavior more succinctly. The proposal here is that the Session object have a flag that turns on "native_errors_as_exceptions" just for the native API calls. This would make IDE-based debugging of EnSight scripts much simpler and catch hidden errors.

One question is if the Launcher base class should support the flag as well as 'start()' is the most common way to get a Session instance.

### 💡 Steps for implementing the feature

Add a property to enable/disable the feature on the Session object (in __repr__ as well???).
Modify the codegen core or the Session interface to ideally leverage the exception keyword on native API calls or wrap in sendmesg.
Potentially add the flag to the Launcher class

### 🔗 Useful links and references

https://ensight.docs.pyansys.com/version/dev/_autosummary/ansys.api.pyensight.ensight_api.ensight.sendmesgoptions.html#sendmesgoptions

Note, the above is waiting for a nightly docs build, but should have more information soon.

Contributor guide

Open the contributing guide

Research direction

Start with the Session interface and codegen core, then read the sendmesgoptions documentation linked in the issue. Determine how the proposed Session flag, and possibly Launcher.start(), can scope exceptions to native API calls without leaving EnSight non-responsive. Done means the flag can be enabled and disabled reliably and hidden native errors are surfaced as exceptions.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
api
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.