Skip to content
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
10 changes: 10 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,11 @@ jobs:
PYFLUENT_LAUNCH_CONTAINER: 1
FLUENT_IMAGE_TAG: v22.2.0

- name: Print 22.2 Fluent version info
run: |
cat src/ansys/fluent/core/fluent_version_222.py
python -c "from ansys.fluent.core.solver.settings_222 import SHASH; print(f'SETTINGS_HASH = {SHASH}')"

- name: Cache 23.1 API Code
uses: actions/cache@v3
id: cache-231-api-code
Expand Down Expand Up @@ -334,6 +339,11 @@ jobs:
PYFLUENT_LAUNCH_CONTAINER: 1
FLUENT_IMAGE_TAG: v23.1.0

- name: Print 23.1 Fluent version info
run: |
cat src/ansys/fluent/core/fluent_version_231.py
python -c "from ansys.fluent.core.solver.settings_231 import SHASH; print(f'SETTINGS_HASH = {SHASH}')"

- name: Install again after codegen
run: |
rm -rf dist
Expand Down
37 changes: 37 additions & 0 deletions codegen/settingsgen.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,18 @@ def _populate_hash_dict(name, info, cls):
else:
commands_hash = None

queries = info.get("queries")
if queries:
queries_hash = []
for qname, qinfo in queries.items():
for query in getattr(cls, "query_names", None):
query_cls = getattr(cls, query)
if qname == query_cls.fluent_name:
queries_hash.append(_populate_hash_dict(qname, qinfo, query_cls))
break
else:
queries_hash = None

arguments = info.get("arguments")
if arguments:
arguments_hash = []
Expand Down Expand Up @@ -106,6 +118,7 @@ def _populate_hash_dict(name, info, cls):
info.get("help"),
children_hash,
commands_hash,
queries_hash,
arguments_hash,
object_hash,
)
Expand All @@ -115,6 +128,7 @@ def _populate_hash_dict(name, info, cls):
cls,
children_hash,
commands_hash,
queries_hash,
arguments_hash,
object_hash,
)
Expand All @@ -131,6 +145,7 @@ def _populate_classes(parent_dir):
cls,
children_hash,
commands_hash,
queries_hash,
arguments_hash,
object_hash,
) in hash_dict.items():
Expand All @@ -141,6 +156,7 @@ def _populate_classes(parent_dir):
cls1,
children_hash1,
commands_hash1,
queries_hash1,
arguments_hash1,
object_hash1,
) in hash_dict.values():
Expand Down Expand Up @@ -171,6 +187,7 @@ def _populate_classes(parent_dir):
cls,
children_hash,
commands_hash,
queries_hash,
arguments_hash,
object_hash,
) in hash_dict.items():
Expand Down Expand Up @@ -205,6 +222,11 @@ def _populate_classes(parent_dir):
pchild_name = hash_dict.get(child)[0].__name__
f.write(f"from .{files_dict.get(child)} import {pchild_name}\n")

if queries_hash:
for child in queries_hash:
pchild_name = hash_dict.get(child)[0].__name__
f.write(f"from .{files_dict.get(child)} import {pchild_name}\n")

if arguments_hash:
for child in arguments_hash:
pchild_name = hash_dict.get(child)[0].__name__
Expand Down Expand Up @@ -261,6 +283,21 @@ def _populate_classes(parent_dir):
f.write(f"{istr1}{command} command of {cls_name}.")
f.write(f'\n{istr1}"""\n')

# write query objects
query_names = getattr(cls, "query_names", None)
if query_names:
f.write(f"{istr1}query_names = \\\n")
strout = io.StringIO()
pprint.pprint(query_names, stream=strout, compact=True, width=70)
mn = ("\n" + istr2).join(strout.getvalue().strip().split("\n"))
f.write(f"{istr2}{mn}\n\n")

for query in query_names:
f.write(f"{istr1}{query}: {query} = {query}\n")
f.write(f'{istr1}"""\n')
f.write(f"{istr1}{query} query of {cls_name}.")
f.write(f'\n{istr1}"""\n')

# write arguments
arguments = getattr(cls, "argument_names", None)
if arguments:
Expand Down
21 changes: 21 additions & 0 deletions src/ansys/fluent/core/services/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@ def get_static_info(self, request):
def execute_cmd(self, request):
return self.__stub.ExecuteCommand(request, metadata=self.__metadata)

@catch_grpc_error
def execute_query(self, request):
return self.__stub.ExecuteQuery(request, metadata=self.__metadata)

@catch_grpc_error
def get_attrs(self, request):
return self.__stub.GetAttrs(request, metadata=self.__metadata)
Expand Down Expand Up @@ -220,6 +224,11 @@ def _extract_static_info(self, info):
child.name: self._extract_static_info(child.value)
for child in info.commands
}
if hasattr(info, "queries") and info.queries:
ret["queries"] = {
child.name: self._extract_static_info(child.value)
for child in info.queries
}
if info.arguments:
ret["arguments"] = {
child.name: self._extract_static_info(child.value)
Expand Down Expand Up @@ -273,6 +282,18 @@ def execute_cmd(self, path: str, command: str, **kwds) -> Any:
response = self.__service_impl.execute_cmd(request)
return self._get_state_from_value(response.reply)

@_trace
def execute_query(self, path: str, query: str, **kwds) -> Any:
"""Execute a given query with the provided keyword arguments."""
request = _get_request_instance_for_path(
SettingsModule.ExecuteQueryRequest, path
)
request.query = query
self._set_state_from_value(request.args, kwds)

response = self.__service_impl.execute_query(request)
return self._get_state_from_value(response.reply)

@_trace
def _parse_attrs(self, response):
ret = {}
Expand Down
8 changes: 8 additions & 0 deletions src/ansys/fluent/core/solver/flobject.py
Original file line number Diff line number Diff line change
Expand Up @@ -699,6 +699,14 @@ def __call__(self, **kwds):
class Query(Base):
"""Query object."""

def __init__(self, name: str = None, parent=None):
"""__init__ of Query class."""
super().__init__(name, parent)
if hasattr(self, "argument_names"):
for argument in self.argument_names:
cls = getattr(self.__class__, argument)
self._setattr(argument, cls(None, self))

def __call__(self, **kwds):
"""Call a query with the specified keyword arguments."""
newkwds = _get_new_keywords(self, kwds)
Expand Down