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
70 changes: 36 additions & 34 deletions codegen/settingsgen.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def _populate_hash_dict(name, info, cls, api_tree):
children_hash = []
for cname, cinfo in children.items():
for child in getattr(cls, "child_names", None):
child_cls = getattr(cls, child)
child_cls = cls._child_classes[child]
if cname == child_cls.fluent_name:
api_tree[child] = {}
children_hash.append(
Expand All @@ -80,7 +80,7 @@ def _populate_hash_dict(name, info, cls, api_tree):
commands_hash = []
for cname, cinfo in commands.items():
for command in getattr(cls, "command_names", None):
command_cls = getattr(cls, command)
command_cls = cls._child_classes[command]
if cname == command_cls.fluent_name:
api_tree[command] = "Command"
commands_hash.append(
Expand All @@ -95,7 +95,7 @@ def _populate_hash_dict(name, info, cls, api_tree):
queries_hash = []
for qname, qinfo in queries.items():
for query in getattr(cls, "query_names", None):
query_cls = getattr(cls, query)
query_cls = cls._child_classes[query]
if qname == query_cls.fluent_name:
api_tree[query] = "Query"
queries_hash.append(
Expand All @@ -110,7 +110,7 @@ def _populate_hash_dict(name, info, cls, api_tree):
arguments_hash = []
for aname, ainfo in arguments.items():
for argument in getattr(cls, "argument_names", None):
argument_cls = getattr(cls, argument)
argument_cls = cls._child_classes[argument]
if aname == argument_cls.fluent_name:
arguments_hash.append(
_populate_hash_dict(aname, ainfo, argument_cls, {})
Expand Down Expand Up @@ -286,18 +286,15 @@ def _populate_classes(parent_dir):
f.write("from ansys.fluent.core.solver.flobject import *\n\n")
if stubf:
stubf.write("from typing import Union, List, Tuple\n\n")
f.write(
"from ansys.fluent.core.solver.flobject import _ChildNamedObjectAccessorMixin\n\n"
)
f.write(
"from ansys.fluent.core.solver.flobject import _CreatableNamedObjectMixin\n\n"
)
f.write(
"from ansys.fluent.core.solver.flobject import _NonCreatableNamedObjectMixin\n\n"
)
f.write(
"from ansys.fluent.core.solver.flobject import _HasAllowedValuesMixin\n\n"
)
f.write("from ansys.fluent.core.solver.flobject import (\n")
f.write(f"{istr1}_ChildNamedObjectAccessorMixin,\n")
f.write(f"{istr1}_CreatableNamedObjectMixin,\n")
f.write(f"{istr1}_NonCreatableNamedObjectMixin,\n")
f.write(f"{istr1}_HasAllowedValuesMixin,\n")
f.write(f"{istr1}_InputFile,\n")
f.write(f"{istr1}_OutputFile,\n")
f.write(")\n\n")

if children_hash:
for child in children_hash:
pchild_name = hash_dict.get(child)[0].__name__
Expand Down Expand Up @@ -351,6 +348,8 @@ def _populate_classes(parent_dir):
if stubf:
stubf.write(f"{istr1}fluent_name = ...\n")

child_class_strings = []

# write children objects
child_names = getattr(cls, "child_names", None)
if child_names:
Expand All @@ -363,10 +362,7 @@ def _populate_classes(parent_dir):
stubf.write(f"{istr1}child_names = ...\n")

for child in child_names:
f.write(f"{istr1}{child}: {child}_cls = {child}_cls\n")
f.write(f'{istr1}"""\n')
f.write(f"{istr1}{child} child of {cls_name}.")
f.write(f'\n{istr1}"""\n')
child_class_strings.append(f"{child}={child}_cls")
if stubf:
stubf.write(f"{istr1}{child} = ...\n")

Expand All @@ -383,10 +379,7 @@ def _populate_classes(parent_dir):

commands_info = _get_commands_info(commands_hash)
for command in command_names:
f.write(f"{istr1}{command}: {command}_cls = {command}_cls\n")
f.write(f'{istr1}"""\n')
f.write(f"{istr1}{command} command of {cls_name}.")
f.write(f'\n{istr1}"""\n')
child_class_strings.append(f"{command}={command}_cls")
# function annotation for commands
if stubf:
command_info = commands_info[command]
Expand All @@ -403,13 +396,12 @@ def _populate_classes(parent_dir):
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")
if stubf:
stubf.write(f"{istr1}query_names = ...\n\n")

queries_info = _get_commands_info(queries_hash)
for query in query_names:
f.write(f"{istr1}{query}: {query}_cls = {query}_cls\n")
f.write(f'{istr1}"""\n')
f.write(f"{istr1}{query} query of {cls_name}.")
f.write(f'\n{istr1}"""\n')
child_class_strings.append(f"{query}={query}_cls")
# function annotation for queries
if stubf:
query_info = queries_info[query]
Expand All @@ -430,16 +422,26 @@ def _populate_classes(parent_dir):
stubf.write(f"{istr1}argument_names = ...\n")

for argument in arguments:
argument_cls = getattr(cls, argument)
f.write(
f"{istr1}{argument}: {argument_cls.__name__}_cls = {argument_cls.__name__}_cls\n"
argument_cls = cls._child_classes[argument]
child_class_strings.append(
f"{argument}={argument_cls.__name__}_cls"
)
f.write(f'{istr1}"""\n')
f.write(f"{istr1}{argument} argument of {cls_name}.")
f.write(f'\n{istr1}"""\n')
if stubf:
stubf.write(f"{istr1}{argument} = ...\n")

if child_class_strings:
f.write(f"{istr1}_child_classes = dict(\n")
f.writelines(
[f"{istr2}{cls_str},\n" for cls_str in child_class_strings]
)
f.write(f"{istr1})\n\n")

child_aliases = getattr(cls, "_child_aliases", None)
if child_aliases:
f.write(f"{istr1}_child_aliases = dict(\n")
f.writelines([f'{istr2}{k}="{v}",\n' for k, v in child_aliases.items()])
f.write(f"{istr1})\n\n")

# write object type
child_object_type = getattr(cls, "child_object_type", None)
if child_object_type:
Expand Down
26 changes: 13 additions & 13 deletions doc/settings_rstgen.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def _generate_table_for_rst(r, data_dict={}):
def _populate_parents_list(cls):
if hasattr(cls, "child_names"):
for child in cls.child_names:
child_cls = getattr(cls, child)
child_cls = cls._child_classes[child]
child_file = child_cls.__module__.split(".")[-1]
if not parents_dict.get(child_file):
parents_dict[child_file] = []
Expand All @@ -67,7 +67,7 @@ def _populate_parents_list(cls):

if hasattr(cls, "command_names"):
for child in cls.command_names:
child_cls = getattr(cls, child)
child_cls = cls._child_classes[child]
child_file = child_cls.__module__.split(".")[-1]
if not parents_dict.get(child_file):
parents_dict[child_file] = []
Expand All @@ -76,7 +76,7 @@ def _populate_parents_list(cls):

if hasattr(cls, "argument_names"):
for child in cls.argument_names:
child_cls = getattr(cls, child)
child_cls = cls._child_classes[child]
child_file = child_cls.__module__.split(".")[-1]
if not parents_dict.get(child_file):
parents_dict[child_file] = []
Expand All @@ -93,15 +93,15 @@ def _populate_parents_list(cls):

if hasattr(cls, "child_names"):
for child in cls.child_names:
_populate_parents_list(getattr(cls, child))
_populate_parents_list(cls._child_classes[child])

if hasattr(cls, "command_names"):
for child in cls.command_names:
_populate_parents_list(getattr(cls, child))
_populate_parents_list(cls._child_classes[child])

if hasattr(cls, "argument_names"):
for child in cls.argument_names:
_populate_parents_list(getattr(cls, child))
_populate_parents_list(cls._child_classes[child])

if hasattr(cls, "child_object_type"):
_populate_parents_list(getattr(cls, "child_object_type"))
Expand Down Expand Up @@ -132,7 +132,7 @@ def _populate_rst_from_settings(rst_dir, cls, version):
data_dict = {}
data_dict["Attribute"] = "Summary"
for child in cls.child_names:
child_cls = getattr(cls, child)
child_cls = cls._child_classes[child]
ref_string = f":ref:`{child} <{child_cls.__module__.split('.')[-1]}>`"
data_dict[ref_string] = child_cls.__doc__.strip("\n").split("\n")[0]
_generate_table_for_rst(r, data_dict)
Expand All @@ -142,7 +142,7 @@ def _populate_rst_from_settings(rst_dir, cls, version):
data_dict = {}
data_dict["Method"] = "Summary"
for child in cls.command_names:
child_cls = getattr(cls, child)
child_cls = cls._child_classes[child]
ref_string = f":ref:`{child} <{child_cls.__module__.split('.')[-1]}>`"
data_dict[ref_string] = child_cls.__doc__.strip("\n").split("\n")[0]
_generate_table_for_rst(r, data_dict)
Expand All @@ -152,7 +152,7 @@ def _populate_rst_from_settings(rst_dir, cls, version):
data_dict = {}
data_dict["Argument"] = "Summary"
for child in cls.argument_names:
child_cls = getattr(cls, child)
child_cls = cls._child_classes[child]
ref_string = f":ref:`{child} <{child_cls.__module__.split('.')[-1]}>`"
data_dict[ref_string] = child_cls.__doc__.strip("\n").split("\n")[0]
_generate_table_for_rst(r, data_dict)
Expand Down Expand Up @@ -181,15 +181,15 @@ def _populate_rst_from_settings(rst_dir, cls, version):
rst_list.append(rstpath)
if has_children:
for child in cls.child_names:
_populate_rst_from_settings(rst_dir, getattr(cls, child), version)
_populate_rst_from_settings(rst_dir, cls._child_classes[child], version)

if has_commands:
for child in cls.command_names:
_populate_rst_from_settings(rst_dir, getattr(cls, child), version)
_populate_rst_from_settings(rst_dir, cls._child_classes[child], version)

if has_arguments:
for child in cls.argument_names:
_populate_rst_from_settings(rst_dir, getattr(cls, child), version)
_populate_rst_from_settings(rst_dir, cls._child_classes[child], version)

if has_named_object:
_populate_rst_from_settings(
Expand All @@ -213,7 +213,7 @@ def _populate_rst_from_settings(rst_dir, cls, version):
if not os.path.exists(rst_dir):
os.makedirs(rst_dir)

image_tag = os.getenv("FLUENT_IMAGE_TAG", "v23.2.0")
image_tag = os.getenv("FLUENT_IMAGE_TAG", "v24.1.0")
version = get_version_for_file_name(image_tag.lstrip("v"))
settings = importlib.import_module(f"ansys.fluent.core.solver.settings_{version}")
_populate_parents_list(settings.root)
Expand Down
1 change: 1 addition & 0 deletions src/ansys/fluent/core/session_solver.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ def _root(self):
flproxy=self._settings_service,
version=self._version,
remote_file_handler=self._remote_file_handler,
scheme_eval=self.fluent_connection.scheme_eval.scheme_eval,
)
return self._settings_root

Expand Down
Loading