diff --git a/doc/changelog.d/1577.added.md b/doc/changelog.d/1577.added.md new file mode 100644 index 0000000000..d61b89ae6d --- /dev/null +++ b/doc/changelog.d/1577.added.md @@ -0,0 +1 @@ +allow for debug mode execution \ No newline at end of file diff --git a/src/ansys/geometry/core/modeler.py b/src/ansys/geometry/core/modeler.py index 288f4abf97..bbdc1fdfa2 100644 --- a/src/ansys/geometry/core/modeler.py +++ b/src/ansys/geometry/core/modeler.py @@ -27,7 +27,7 @@ from grpc import Channel -from ansys.api.dbu.v0.dbuapplication_pb2 import RunScriptFileRequest +from ansys.api.dbu.v0.dbuapplication_pb2 import RunScriptFileRequest, RunScriptType from ansys.api.dbu.v0.dbuapplication_pb2_grpc import DbuApplicationStub from ansys.api.dbu.v0.designs_pb2 import OpenRequest from ansys.api.dbu.v0.designs_pb2_grpc import DesignsStub @@ -382,6 +382,7 @@ def run_discovery_script_file( script_args: dict[str, str] | None = None, import_design: bool = False, api_version: int | str | ApiVersions = None, + enable_debug_features: bool = False, ) -> tuple[dict[str, str], Optional["Design"]]: """Run a Discovery script file. @@ -430,6 +431,9 @@ def run_discovery_script_file( the specified API version. If the API version is not supported, the service will raise an error. If you are using Discovery or SpaceClaim, the product will determine the API version to use, so there is no need to specify this parameter. + enable_debug_features : bool, default: False + Whether to enable debug features for the script. By default, debug features are + disabled. Debug features are only available starting on 2025R1. Returns ------- @@ -475,6 +479,13 @@ def run_discovery_script_file( api_version=api_version.value if api_version is not None else None, ) + # Enable debug features if requested + if enable_debug_features: + if self.client.backend_version > (25, 1, 0): + request.script_type = RunScriptType.DEBUG + else: # pragma: no cover + self.client.log.warning("Debug features are only available starting on 2025R1.") + self.client.log.debug(f"Running Discovery script file at {file_path}...") response = ga_stub.RunScriptFile(request) diff --git a/tests/integration/test_runscript.py b/tests/integration/test_runscript.py index f0c0ce0e41..7f017ef060 100644 --- a/tests/integration/test_runscript.py +++ b/tests/integration/test_runscript.py @@ -129,3 +129,19 @@ def test_dscript_simple_script(modeler: Modeler): assert len(result) == 2 assert pattern_db.match(result["design_body"]) assert pattern_doc.match(result["design"]) + + +# Discovery (.dscript) +def test_dscript_simple_script_debug_mode(modeler: Modeler): + # Skip on Linux + skip_if_linux(modeler, test_dscript_simple_script.__name__, "run_discovery_script_file") + + result = modeler.run_discovery_script_file( + DSCOSCRIPTS_FILES_DIR / "simple_script.dscript", enable_debug_features=True + ) + assert len(result) == 2 + pattern_db = re.compile(r"SpaceClaim\.Api\.[A-Za-z0-9]+\.DesignBody", re.IGNORECASE) + pattern_doc = re.compile(r"SpaceClaim\.Api\.[A-Za-z0-9]+\.Document", re.IGNORECASE) + assert len(result) == 2 + assert pattern_db.match(result["design_body"]) + assert pattern_doc.match(result["design"])