Skip to content

feat: Support unsuppressing prompts in scheme_eval #3963

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

Merged
merged 2 commits into from
Apr 28, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions doc/changelog.d/3963.added.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Support unsuppressing prompts in scheme_eval
26 changes: 20 additions & 6 deletions src/ansys/fluent/core/services/scheme_eval.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,15 @@ def string_eval(
return self.__stub.StringEval(request, metadata=self.__metadata)

def scheme_eval(
self, request: SchemeEvalProtoModule.SchemeEvalRequest
self,
request: SchemeEvalProtoModule.SchemeEvalRequest,
metadata: list[tuple[str, str]] = None,
) -> SchemeEvalProtoModule.SchemeEvalResponse:
"""SchemeEval RPC of SchemeEval service."""
return self.__stub.SchemeEval(request, metadata=self.__metadata)
new_metadata = self.__metadata
if metadata:
new_metadata = self.__metadata + metadata
return self.__stub.SchemeEval(request, metadata=new_metadata)


class Symbol:
Expand Down Expand Up @@ -271,14 +276,17 @@ def __init__(self, service: SchemeEvalService) -> None:
except Exception: # for pypim launch
self.version = FluentVersion.v231.value

def eval(self, val: Any) -> Any:
def eval(self, val: Any, suppress_prompts: bool = True) -> Any:
"""Evaluates a scheme expression.

Parameters
----------
val : Any
Input scheme expression represented as Python datatype

suppress_prompts : bool, optional
Whether to suppress prompts in Fluent, by default True

Returns
-------
Any
Expand All @@ -292,7 +300,10 @@ def eval(self, val: Any) -> Any:
else:
request = SchemeEvalProtoModule.SchemeEvalRequest()
_convert_py_value_to_scheme_pointer(val, request.input, self.version)
response = self.service.scheme_eval(request)
metadata = []
if not suppress_prompts:
metadata.append(("no-suppress-prompts", "1"))
response = self.service.scheme_eval(request, metadata)
return _convert_scheme_pointer_to_py_value(response.output, self.version)

def exec(
Expand Down Expand Up @@ -343,14 +354,17 @@ def string_eval(self, input: str) -> str:
response = self.service.string_eval(request)
return response.output

def scheme_eval(self, input: str) -> Any:
def scheme_eval(self, input: str, suppress_prompts: bool = True) -> Any:
"""Evaluates a scheme expression in string format.

Parameters
----------
input : str
Input scheme expression in string format

suppress_prompts : bool, optional
Whether to suppress prompts in Fluent, by default True

Returns
-------
Any
Expand All @@ -362,7 +376,7 @@ def scheme_eval(self, input: str) -> Any:
(S("with-input-from-string"), input, S("read")),
S("user-initial-environment"),
)
return self.eval(val)
return self.eval(val, suppress_prompts)

def is_defined(self, symbol: str) -> bool:
"""Check if a symbol is defined in the scheme environment.
Expand Down