ansys-fluent-core 0.28.2__py3-none-any.whl → 0.29.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of ansys-fluent-core might be problematic. Click here for more details.

Files changed (221) hide show
  1. ansys/fluent/core/__init__.py +26 -1
  2. ansys/fluent/core/_stand_alone_datamodel_client/_datamodel_client.py +22 -0
  3. ansys/fluent/core/_version.py +24 -2
  4. ansys/fluent/core/codegen/__init__.py +22 -0
  5. ansys/fluent/core/codegen/allapigen.py +38 -5
  6. ansys/fluent/core/codegen/builtin_settingsgen.py +22 -0
  7. ansys/fluent/core/codegen/data/__init__.py +21 -0
  8. ansys/fluent/core/codegen/data/fluent_gui_help_patch.py +22 -0
  9. ansys/fluent/core/codegen/data/meshing_utilities_examples.py +22 -0
  10. ansys/fluent/core/codegen/datamodelgen.py +40 -4
  11. ansys/fluent/core/codegen/print_fluent_version.py +22 -0
  12. ansys/fluent/core/codegen/settingsgen.py +67 -4
  13. ansys/fluent/core/codegen/tuigen.py +44 -6
  14. ansys/fluent/core/codegen/walk_api.py +67 -18
  15. ansys/fluent/core/codegen/write_settings_yaml.py +22 -0
  16. ansys/fluent/core/data_model_cache.py +22 -0
  17. ansys/fluent/core/examples/__init__.py +22 -0
  18. ansys/fluent/core/examples/downloads.py +22 -0
  19. ansys/fluent/core/exceptions.py +22 -0
  20. ansys/fluent/core/file_session.py +22 -0
  21. ansys/fluent/core/filereader/__init__.py +21 -0
  22. ansys/fluent/core/filereader/case_file.py +22 -0
  23. ansys/fluent/core/filereader/casereader.py +22 -0
  24. ansys/fluent/core/filereader/data_file.py +22 -0
  25. ansys/fluent/core/filereader/lispy.py +22 -0
  26. ansys/fluent/core/fluent_connection.py +23 -1
  27. ansys/fluent/core/generated/api_tree/api_objects.json +1 -1
  28. ansys/fluent/core/generated/datamodel_252/meshing.py +32 -0
  29. ansys/fluent/core/generated/fluent_version_252.py +3 -3
  30. ansys/fluent/core/generated/solver/settings_222.py +0 -72
  31. ansys/fluent/core/generated/solver/settings_222.pyi +0 -307
  32. ansys/fluent/core/generated/solver/settings_231.py +0 -574
  33. ansys/fluent/core/generated/solver/settings_231.pyi +0 -561
  34. ansys/fluent/core/generated/solver/settings_232.py +0 -527
  35. ansys/fluent/core/generated/solver/settings_232.pyi +0 -2803
  36. ansys/fluent/core/generated/solver/settings_241.py +0 -478
  37. ansys/fluent/core/generated/solver/settings_241.pyi +0 -522
  38. ansys/fluent/core/generated/solver/settings_242.py +0 -361
  39. ansys/fluent/core/generated/solver/settings_242.pyi +0 -591
  40. ansys/fluent/core/generated/solver/settings_251.py +0 -399
  41. ansys/fluent/core/generated/solver/settings_251.pyi +0 -629
  42. ansys/fluent/core/generated/solver/settings_252.py +7794 -4185
  43. ansys/fluent/core/generated/solver/settings_252.pyi +6986 -3213
  44. ansys/fluent/core/generated/solver/tui_252.py +537 -181
  45. ansys/fluent/core/get_build_details.py +22 -0
  46. ansys/fluent/core/journaling.py +38 -0
  47. ansys/fluent/core/launcher/__init__.py +22 -0
  48. ansys/fluent/core/launcher/container_launcher.py +65 -56
  49. ansys/fluent/core/launcher/error_handler.py +30 -0
  50. ansys/fluent/core/launcher/fluent_container.py +45 -20
  51. ansys/fluent/core/launcher/launcher.py +53 -5
  52. ansys/fluent/core/launcher/launcher_utils.py +22 -0
  53. ansys/fluent/core/launcher/pim_launcher.py +120 -86
  54. ansys/fluent/core/launcher/process_launch_string.py +22 -0
  55. ansys/fluent/core/launcher/pyfluent_enums.py +22 -0
  56. ansys/fluent/core/launcher/server_info.py +45 -3
  57. ansys/fluent/core/launcher/slurm_launcher.py +25 -3
  58. ansys/fluent/core/launcher/standalone_launcher.py +68 -63
  59. ansys/fluent/core/launcher/watchdog.py +22 -0
  60. ansys/fluent/core/logging.py +24 -0
  61. ansys/fluent/core/logging_config.yaml +3 -0
  62. ansys/fluent/core/meshing/meshing_workflow.py +22 -0
  63. ansys/fluent/core/parametric.py +22 -0
  64. ansys/fluent/core/post_objects/__init__.py +21 -0
  65. ansys/fluent/core/post_objects/check_in_notebook.py +22 -0
  66. ansys/fluent/core/post_objects/meta.py +22 -0
  67. ansys/fluent/core/post_objects/post_helper.py +22 -0
  68. ansys/fluent/core/post_objects/post_object_definitions.py +22 -0
  69. ansys/fluent/core/post_objects/post_objects_container.py +22 -0
  70. ansys/fluent/core/post_objects/singleton_meta.py +22 -0
  71. ansys/fluent/core/post_objects/timing_decorator.py +22 -0
  72. ansys/fluent/core/report.py +77 -0
  73. ansys/fluent/core/rpvars.py +22 -0
  74. ansys/fluent/core/scheduler/__init__.py +22 -0
  75. ansys/fluent/core/scheduler/load_machines.py +22 -0
  76. ansys/fluent/core/scheduler/machine_list.py +22 -0
  77. ansys/fluent/core/search.py +22 -0
  78. ansys/fluent/core/services/__init__.py +22 -0
  79. ansys/fluent/core/services/api_upgrade.py +22 -0
  80. ansys/fluent/core/services/app_utilities.py +38 -0
  81. ansys/fluent/core/services/batch_ops.py +22 -0
  82. ansys/fluent/core/services/datamodel_se.py +26 -1
  83. ansys/fluent/core/services/datamodel_tui.py +22 -0
  84. ansys/fluent/core/services/deprecated_field_data.py +23 -1
  85. ansys/fluent/core/services/events.py +22 -0
  86. ansys/fluent/core/services/field_data.py +285 -2
  87. ansys/fluent/core/services/health_check.py +22 -0
  88. ansys/fluent/core/services/interceptors.py +50 -2
  89. ansys/fluent/core/services/monitor.py +22 -0
  90. ansys/fluent/core/services/reduction.py +22 -0
  91. ansys/fluent/core/services/scheme_eval.py +22 -0
  92. ansys/fluent/core/services/settings.py +22 -0
  93. ansys/fluent/core/services/solution_variables.py +22 -0
  94. ansys/fluent/core/services/streaming.py +22 -0
  95. ansys/fluent/core/services/transcript.py +22 -0
  96. ansys/fluent/core/session.py +39 -2
  97. ansys/fluent/core/session_base_meshing.py +22 -0
  98. ansys/fluent/core/session_meshing.py +22 -0
  99. ansys/fluent/core/session_meshing.pyi +22 -0
  100. ansys/fluent/core/session_pure_meshing.py +22 -0
  101. ansys/fluent/core/session_pure_meshing.pyi +22 -0
  102. ansys/fluent/core/session_shared.py +22 -0
  103. ansys/fluent/core/session_solver.py +43 -0
  104. ansys/fluent/core/session_solver.pyi +22 -0
  105. ansys/fluent/core/session_solver_aero.py +22 -0
  106. ansys/fluent/core/session_solver_icing.py +22 -0
  107. ansys/fluent/core/session_solver_lite.py +22 -0
  108. ansys/fluent/core/solver/__init__.py +22 -0
  109. ansys/fluent/core/solver/error_message.py +22 -0
  110. ansys/fluent/core/solver/flobject.py +22 -0
  111. ansys/fluent/core/solver/flunits.py +22 -0
  112. ansys/fluent/core/solver/function/__init__.py +22 -0
  113. ansys/fluent/core/solver/function/reduction.py +22 -0
  114. ansys/fluent/core/solver/settings_builtin_bases.py +22 -0
  115. ansys/fluent/core/solver/settings_builtin_data.py +22 -0
  116. ansys/fluent/core/solver/settings_external.py +22 -0
  117. ansys/fluent/core/streaming_services/__init__.py +21 -0
  118. ansys/fluent/core/streaming_services/datamodel_event_streaming.py +22 -0
  119. ansys/fluent/core/streaming_services/datamodel_streaming.py +22 -0
  120. ansys/fluent/core/streaming_services/events_streaming.py +22 -0
  121. ansys/fluent/core/streaming_services/field_data_streaming.py +22 -0
  122. ansys/fluent/core/streaming_services/monitor_streaming.py +23 -1
  123. ansys/fluent/core/streaming_services/streaming.py +22 -0
  124. ansys/fluent/core/streaming_services/transcript_streaming.py +22 -0
  125. ansys/fluent/core/systemcoupling.py +22 -0
  126. ansys/fluent/core/utils/__init__.py +22 -0
  127. ansys/fluent/core/utils/data_transfer.py +22 -0
  128. ansys/fluent/core/utils/deprecate.py +24 -1
  129. ansys/fluent/core/utils/dictionary_operations.py +22 -0
  130. ansys/fluent/core/utils/dump_session_data.py +22 -0
  131. ansys/fluent/core/utils/event_loop.py +22 -0
  132. ansys/fluent/core/utils/execution.py +22 -0
  133. ansys/fluent/core/utils/file_transfer_service.py +22 -0
  134. ansys/fluent/core/utils/fix_doc.py +22 -0
  135. ansys/fluent/core/utils/fldoc.py +22 -0
  136. ansys/fluent/core/utils/fluent_version.py +22 -0
  137. ansys/fluent/core/utils/networking.py +22 -0
  138. ansys/fluent/core/utils/setup_for_fluent.py +22 -0
  139. ansys/fluent/core/warnings.py +22 -0
  140. ansys/fluent/core/workflow.py +22 -0
  141. {ansys_fluent_core-0.28.2.dist-info → ansys_fluent_core-0.29.0.dist-info}/LICENSE +8 -8
  142. {ansys_fluent_core-0.28.2.dist-info → ansys_fluent_core-0.29.0.dist-info}/METADATA +56 -33
  143. ansys_fluent_core-0.29.0.dist-info/RECORD +219 -0
  144. {ansys_fluent_core-0.28.2.dist-info → ansys_fluent_core-0.29.0.dist-info}/WHEEL +1 -1
  145. ansys/fluent/core/docs/README.rst +0 -155
  146. ansys/fluent/tests/conftest.py +0 -415
  147. ansys/fluent/tests/fluent_fixtures.py +0 -195
  148. ansys/fluent/tests/integration/test_optislang/test_optislang_integration.py +0 -263
  149. ansys/fluent/tests/parametric/test_local_parametric_run.py +0 -36
  150. ansys/fluent/tests/parametric/test_local_parametric_setup.py +0 -34
  151. ansys/fluent/tests/parametric/test_parametric_workflow.py +0 -279
  152. ansys/fluent/tests/test_aero_session.py +0 -88
  153. ansys/fluent/tests/test_batch_ops.py +0 -39
  154. ansys/fluent/tests/test_builtin_settings.py +0 -761
  155. ansys/fluent/tests/test_cad_to_post_ftm.py +0 -525
  156. ansys/fluent/tests/test_cad_to_post_wtm.py +0 -250
  157. ansys/fluent/tests/test_casereader.py +0 -324
  158. ansys/fluent/tests/test_codegen.py +0 -783
  159. ansys/fluent/tests/test_creatable.py +0 -31
  160. ansys/fluent/tests/test_data_model_cache.py +0 -434
  161. ansys/fluent/tests/test_datamodel_api.py +0 -429
  162. ansys/fluent/tests/test_datamodel_service.py +0 -814
  163. ansys/fluent/tests/test_datareader.py +0 -103
  164. ansys/fluent/tests/test_error_handling.py +0 -24
  165. ansys/fluent/tests/test_events_manager.py +0 -214
  166. ansys/fluent/tests/test_field_data.py +0 -466
  167. ansys/fluent/tests/test_file_session.py +0 -355
  168. ansys/fluent/tests/test_file_transfer_service.py +0 -165
  169. ansys/fluent/tests/test_fix_doc.py +0 -29
  170. ansys/fluent/tests/test_flobject.py +0 -1235
  171. ansys/fluent/tests/test_fluent_fixes.py +0 -106
  172. ansys/fluent/tests/test_fluent_session.py +0 -270
  173. ansys/fluent/tests/test_fluent_version.py +0 -66
  174. ansys/fluent/tests/test_fluent_version_marker.py +0 -65
  175. ansys/fluent/tests/test_icing_session.py +0 -9
  176. ansys/fluent/tests/test_launcher.py +0 -529
  177. ansys/fluent/tests/test_launcher_remote.py +0 -272
  178. ansys/fluent/tests/test_lispy.py +0 -40
  179. ansys/fluent/tests/test_logging.py +0 -16
  180. ansys/fluent/tests/test_mapped_api.py +0 -766
  181. ansys/fluent/tests/test_meshing_utilities.py +0 -2436
  182. ansys/fluent/tests/test_meshing_workflow.py +0 -421
  183. ansys/fluent/tests/test_meshingmode/test_meshing_launch.py +0 -168
  184. ansys/fluent/tests/test_new_meshing_workflow.py +0 -1801
  185. ansys/fluent/tests/test_preferences.py +0 -89
  186. ansys/fluent/tests/test_pure_mesh_vs_mesh_workflow.py +0 -101
  187. ansys/fluent/tests/test_reduction.py +0 -484
  188. ansys/fluent/tests/test_rp_vars.py +0 -77
  189. ansys/fluent/tests/test_scheduler.py +0 -471
  190. ansys/fluent/tests/test_scheme_eval_222.py +0 -338
  191. ansys/fluent/tests/test_scheme_eval_231.py +0 -243
  192. ansys/fluent/tests/test_search.py +0 -344
  193. ansys/fluent/tests/test_session.py +0 -594
  194. ansys/fluent/tests/test_settings_api.py +0 -606
  195. ansys/fluent/tests/test_settings_reader.py +0 -85
  196. ansys/fluent/tests/test_slurm_future.py +0 -67
  197. ansys/fluent/tests/test_solution_variables.py +0 -241
  198. ansys/fluent/tests/test_solver_monitors.py +0 -83
  199. ansys/fluent/tests/test_solvermode/boundaries_periodic_expDict +0 -1712
  200. ansys/fluent/tests/test_solvermode/test_boundaries.py +0 -127
  201. ansys/fluent/tests/test_solvermode/test_calculationactivities.py +0 -20
  202. ansys/fluent/tests/test_solvermode/test_controls.py +0 -131
  203. ansys/fluent/tests/test_solvermode/test_general.py +0 -109
  204. ansys/fluent/tests/test_solvermode/test_initialization.py +0 -83
  205. ansys/fluent/tests/test_solvermode/test_materials.py +0 -40
  206. ansys/fluent/tests/test_solvermode/test_methods.py +0 -65
  207. ansys/fluent/tests/test_solvermode/test_models.py +0 -99
  208. ansys/fluent/tests/test_solvermode/test_named_expressions.py +0 -35
  209. ansys/fluent/tests/test_solvermode/test_post_vector.py +0 -22
  210. ansys/fluent/tests/test_solvermode/test_species_model.py +0 -67
  211. ansys/fluent/tests/test_streaming_services.py +0 -52
  212. ansys/fluent/tests/test_systemcoupling.py +0 -44
  213. ansys/fluent/tests/test_topy.py +0 -179
  214. ansys/fluent/tests/test_tui_api.py +0 -70
  215. ansys/fluent/tests/test_type_stub.py +0 -37
  216. ansys/fluent/tests/test_utils.py +0 -82
  217. ansys/fluent/tests/util/__init__.py +0 -36
  218. ansys/fluent/tests/util/meshing_workflow.py +0 -33
  219. ansys/fluent/tests/util/solver.py +0 -72
  220. ansys_fluent_core-0.28.2.dist-info/AUTHORS +0 -12
  221. ansys_fluent_core-0.28.2.dist-info/RECORD +0 -294
@@ -1,783 +0,0 @@
1
- import ast
2
- import importlib
3
- from pathlib import Path
4
- import pickle
5
- import shutil
6
- import tempfile
7
-
8
- import pytest
9
-
10
- import ansys.fluent.core as pyfluent
11
- from ansys.fluent.core.codegen import StaticInfoType, allapigen
12
- from ansys.fluent.core.search import get_api_tree_file_name
13
- from ansys.fluent.core.utils.fluent_version import get_version_for_file_name
14
-
15
-
16
- @pytest.mark.codegen_required
17
- def test_allapigen_files(new_solver_session):
18
- version = get_version_for_file_name(session=new_solver_session)
19
- importlib.import_module(f"ansys.fluent.core.generated.fluent_version_{version}")
20
- importlib.import_module(f"ansys.fluent.core.generated.meshing.tui_{version}")
21
- importlib.import_module(f"ansys.fluent.core.generated.solver.tui_{version}")
22
- importlib.import_module(f"ansys.fluent.core.generated.datamodel_{version}.meshing")
23
- importlib.import_module(f"ansys.fluent.core.generated.datamodel_{version}.workflow")
24
- importlib.import_module(
25
- f"ansys.fluent.core.generated.datamodel_{version}.preferences"
26
- )
27
- importlib.import_module(
28
- f"ansys.fluent.core.generated.datamodel_{version}.PartManagement"
29
- )
30
- importlib.import_module(
31
- f"ansys.fluent.core.generated.datamodel_{version}.PMFileManagement"
32
- )
33
- importlib.import_module(f"ansys.fluent.core.generated.solver.settings_{version}")
34
-
35
-
36
- def test_codegen_with_no_static_info(monkeypatch):
37
- codegen_outdir = Path(tempfile.mkdtemp())
38
- monkeypatch.setattr(pyfluent, "CODEGEN_OUTDIR", codegen_outdir)
39
- version = "251"
40
- allapigen.generate(version, {})
41
- generated_paths = list(codegen_outdir.iterdir())
42
- assert len(generated_paths) == 1
43
- assert set(p.name for p in generated_paths) == {f"api_tree_{version}.pickle"}
44
- api_tree_file = get_api_tree_file_name(version)
45
- with open(api_tree_file, "rb") as f:
46
- api_tree = pickle.load(f)
47
- assert api_tree == {"<meshing_session>": {}, "<solver_session>": {}}
48
-
49
-
50
- def _get_nth_tui_command_static_info(n):
51
- return {f"C{n}": {"menus": {}, "commands": {}, "help": f"C{n} help"}}
52
-
53
-
54
- def _get_nth_tui_menu_static_info(n, menus_static_info, commands_static_info):
55
- return {
56
- f"M{n}": {
57
- "menus": menus_static_info,
58
- "commands": commands_static_info,
59
- "help": f"M{n} help",
60
- }
61
- }
62
-
63
-
64
- def _get_expected_tui_api_output(mode):
65
- return f'''"""Fluent {mode} TUI commands"""
66
- #
67
- # This is an auto-generated file. DO NOT EDIT!
68
- #
69
- # pylint: disable=line-too-long
70
-
71
- from ansys.fluent.core.services.datamodel_tui import PyMenu, TUIMenu, TUIMethod
72
-
73
-
74
-
75
- class main_menu(TUIMenu):
76
- """
77
- Fluent {mode} main menu.
78
- """
79
- def __init__(self, service, version, mode, path):
80
- self.M1 = self.__class__.M1(service, version, mode, path + ["M1"])
81
- self.C1 = self.__class__.C1(service, version, mode, path + ["C1"])
82
- super().__init__(service, version, mode, path)
83
- class C1(TUIMethod):
84
- """
85
- C1 help.
86
- """
87
-
88
- class M1(TUIMenu):
89
- """
90
- M1 help.
91
- """
92
- def __init__(self, service, version, mode, path):
93
- self.M2 = self.__class__.M2(service, version, mode, path + ["M2"])
94
- self.C2 = self.__class__.C2(service, version, mode, path + ["C2"])
95
- super().__init__(service, version, mode, path)
96
- class C2(TUIMethod):
97
- """
98
- C2 help.
99
- """
100
-
101
- class M2(TUIMenu):
102
- """
103
- M2 help.
104
- """
105
- def __init__(self, service, version, mode, path):
106
- self.C3 = self.__class__.C3(service, version, mode, path + ["C3"])
107
- super().__init__(service, version, mode, path)
108
- class C3(TUIMethod):
109
- """
110
- C3 help.
111
- """'''
112
-
113
-
114
- @pytest.mark.parametrize("mode", ["solver", "meshing"])
115
- def test_codegen_with_tui_solver_static_info(mode, monkeypatch):
116
- codegen_outdir = Path(tempfile.mkdtemp())
117
- monkeypatch.setattr(pyfluent, "CODEGEN_OUTDIR", codegen_outdir)
118
- version = "251"
119
- static_infos = {}
120
- static_info_type = (
121
- StaticInfoType.TUI_SOLVER if mode == "solver" else StaticInfoType.TUI_MESHING
122
- )
123
- static_infos[static_info_type] = {
124
- "menus": _get_nth_tui_menu_static_info(
125
- 1,
126
- _get_nth_tui_menu_static_info(2, {}, _get_nth_tui_command_static_info(3)),
127
- _get_nth_tui_command_static_info(2),
128
- ),
129
- "commands": _get_nth_tui_command_static_info(1),
130
- "help": "Root",
131
- }
132
- allapigen.generate(version, static_infos)
133
- generated_paths = list(codegen_outdir.iterdir())
134
- assert len(generated_paths) == 2
135
- assert set(p.name for p in generated_paths) == {f"api_tree_{version}.pickle", mode}
136
- solver_paths = list((codegen_outdir / mode).iterdir())
137
- assert len(solver_paths) == 1
138
- assert set(p.name for p in solver_paths) == {f"tui_{version}.py"}
139
- with open(codegen_outdir / mode / f"tui_{version}.py", "r") as f:
140
- assert f.read().strip() == _get_expected_tui_api_output(mode)
141
- api_tree_file = get_api_tree_file_name(version)
142
- with open(api_tree_file, "rb") as f:
143
- api_tree = pickle.load(f)
144
- tui_tree = {
145
- "tui": {"M1": {"M2": {"C3": "Command"}, "C2": "Command"}, "C1": "Command"}
146
- }
147
- api_tree_expected = {"<meshing_session>": {}, "<solver_session>": {}}
148
- api_tree_expected[f"<{mode}_session>"] = tui_tree
149
- assert api_tree == api_tree_expected
150
- shutil.rmtree(str(codegen_outdir))
151
-
152
-
153
- _static_info_type_by_rules = {
154
- "workflow": StaticInfoType.DATAMODEL_WORKFLOW,
155
- "meshing": StaticInfoType.DATAMODEL_MESHING,
156
- "PartManagement": StaticInfoType.DATAMODEL_PART_MANAGEMENT,
157
- "PMFileManagement": StaticInfoType.DATAMODEL_PM_FILE_MANAGEMENT,
158
- "flicing": StaticInfoType.DATAMODEL_FLICING,
159
- "preferences": StaticInfoType.DATAMODEL_PREFERENCES,
160
- "solverworkflow": StaticInfoType.DATAMODEL_SOLVER_WORKFLOW,
161
- "MeshingUtilities": StaticInfoType.DATAMODEL_MESHING_UTILITIES,
162
- }
163
-
164
-
165
- def _get_datamodel_entity_static_info(
166
- name, singletons, namedobjects, commands, parameters
167
- ):
168
- return {
169
- name: {
170
- "singletons": singletons,
171
- "namedobjects": namedobjects,
172
- "commands": commands,
173
- "parameters": parameters,
174
- }
175
- }
176
-
177
-
178
- def _get_datamodel_command_static_info(name, args, returntype):
179
- args = [{"name": arg[0], "type": arg[1]} for arg in args]
180
- return {name: {"commandinfo": {"args": args, "returntype": returntype}}}
181
-
182
-
183
- _expected_datamodel_api_output = '''#
184
- # This is an auto-generated file. DO NOT EDIT!
185
- #
186
- # pylint: disable=line-too-long
187
-
188
- from ansys.fluent.core.services.datamodel_se import (
189
- PyMenu,
190
- PyParameter,
191
- PyTextual,
192
- PyNumerical,
193
- PyDictionary,
194
- PyNamedObjectContainer,
195
- PyCommand,
196
- PyQuery
197
- )
198
-
199
-
200
- class Root(PyMenu):
201
- """
202
- Singleton Root.
203
- """
204
- def __init__(self, service, rules, path):
205
- self.N1 = self.__class__.N1(service, rules, path + [("N1", "")])
206
- self.S1 = self.__class__.S1(service, rules, path + [("S1", "")])
207
- self.P1 = self.__class__.P1(service, rules, path + [("P1", "")])
208
- self.C1 = self.__class__.C1(service, rules, "C1", path)
209
- super().__init__(service, rules, path)
210
-
211
- class N1(PyNamedObjectContainer):
212
- """
213
- .
214
- """
215
- class _N1(PyMenu):
216
- """
217
- Singleton _N1.
218
- """
219
- def __init__(self, service, rules, path):
220
- self.S3 = self.__class__.S3(service, rules, path + [("S3", "")])
221
- super().__init__(service, rules, path)
222
-
223
- class S3(PyMenu):
224
- """
225
- Singleton S3.
226
- """
227
- def __init__(self, service, rules, path):
228
- super().__init__(service, rules, path)
229
-
230
- def __getitem__(self, key: str) -> _N1:
231
- return super().__getitem__(key)
232
-
233
- class S1(PyMenu):
234
- """
235
- Singleton S1.
236
- """
237
- def __init__(self, service, rules, path):
238
- self.S2 = self.__class__.S2(service, rules, path + [("S2", "")])
239
- self.P2 = self.__class__.P2(service, rules, path + [("P2", "")])
240
- self.C2 = self.__class__.C2(service, rules, "C2", path)
241
- super().__init__(service, rules, path)
242
-
243
- class S2(PyMenu):
244
- """
245
- Singleton S2.
246
- """
247
- def __init__(self, service, rules, path):
248
- super().__init__(service, rules, path)
249
-
250
- class P2(PyNumerical):
251
- """
252
- Parameter P2 of value type float.
253
- """
254
- pass
255
-
256
- class C2(PyCommand):
257
- """
258
- Command C2.
259
-
260
- Parameters
261
- ----------
262
- A2 : float
263
-
264
- Returns
265
- -------
266
- bool
267
- """
268
- pass
269
-
270
- class P1(PyTextual):
271
- """
272
- Parameter P1 of value type str.
273
- """
274
- pass
275
-
276
- class C1(PyCommand):
277
- """
278
- Command C1.
279
-
280
- Parameters
281
- ----------
282
- A1 : str
283
-
284
- Returns
285
- -------
286
- bool
287
- """
288
- pass'''
289
-
290
-
291
- @pytest.mark.parametrize(
292
- "rules",
293
- [
294
- "workflow",
295
- "meshing",
296
- "PartManagement",
297
- "PMFileManagement",
298
- "preferences",
299
- "solverworkflow",
300
- "MeshingUtilities",
301
- ],
302
- )
303
- def test_codegen_with_datamodel_static_info(monkeypatch, rules):
304
- codegen_outdir = Path(tempfile.mkdtemp())
305
- monkeypatch.setattr(pyfluent, "CODEGEN_OUTDIR", codegen_outdir)
306
- version = "251"
307
- static_infos = {}
308
- static_info_type = _static_info_type_by_rules[rules]
309
- static_infos[static_info_type] = {
310
- "singletons": _get_datamodel_entity_static_info(
311
- "S1",
312
- _get_datamodel_entity_static_info("S2", {}, {}, {}, {}),
313
- {},
314
- _get_datamodel_command_static_info("C2", [("A2", "Real")], "Logical"),
315
- {"P2": {"type": "Real"}},
316
- ),
317
- "namedobjects": _get_datamodel_entity_static_info(
318
- "N1", _get_datamodel_entity_static_info("S3", {}, {}, {}, {}), {}, {}, {}
319
- ),
320
- "commands": _get_datamodel_command_static_info(
321
- "C1", [("A1", "String")], "Logical"
322
- ),
323
- "parameters": {"P1": {"type": "String"}},
324
- "help": "Root",
325
- }
326
- allapigen.generate(version, static_infos)
327
- generated_paths = list(codegen_outdir.iterdir())
328
- assert len(generated_paths) == 2
329
- assert set(p.name for p in generated_paths) == {
330
- f"api_tree_{version}.pickle",
331
- f"datamodel_{version}",
332
- }
333
- datamodel_paths = list((codegen_outdir / f"datamodel_{version}").iterdir())
334
- assert len(datamodel_paths) == 1 or 2
335
- assert set(p.name for p in datamodel_paths) == {f"{rules}.py"} or {f"{rules}.pyi"}
336
- with open(codegen_outdir / f"datamodel_{version}" / f"{rules}.py", "r") as f:
337
- assert f.read().strip() == _expected_datamodel_api_output
338
- api_tree_file = get_api_tree_file_name(version)
339
- with open(api_tree_file, "rb") as f:
340
- api_tree = pickle.load(f)
341
- datamodel_tree = {
342
- rules: {
343
- "C1": "Command",
344
- "N1:<name>": {"S3": {}},
345
- "P1": "Parameter",
346
- "S1": {"C2": "Command", "P2": "Parameter", "S2": {}},
347
- }
348
- }
349
- api_tree_expected = {"<meshing_session>": {}, "<solver_session>": {}}
350
- if rules in [
351
- "workflow",
352
- "meshing",
353
- "PartManagement",
354
- "PMFileManagement",
355
- "preferences",
356
- "MeshingUtilities",
357
- ]:
358
- api_tree_expected["<meshing_session>"] = datamodel_tree
359
- if rules in ["workflow", "flicing", "preferences", "solverworkflow"]:
360
- api_tree_expected["<solver_session>"] = datamodel_tree
361
- assert api_tree == api_tree_expected
362
- shutil.rmtree(str(codegen_outdir))
363
-
364
-
365
- def _get_group_settings_static_info(name, children, commands, queries):
366
- return {
367
- name: {
368
- "children": children,
369
- "commands": commands,
370
- "queries": queries,
371
- "type": "group",
372
- "help": f"{name} help",
373
- }
374
- }
375
-
376
-
377
- def _get_named_object_settings_static_info(name, object_type, children):
378
- return {
379
- name: {
380
- "object-type": object_type,
381
- "children": children,
382
- "type": "named-object",
383
- "help": f"{name} help",
384
- }
385
- }
386
-
387
-
388
- def _get_parameter_settings_static_info(name, type_):
389
- return {name: {"type": type_, "help": f"{name} help"}}
390
-
391
-
392
- def _get_command_settings_static_info(name, args):
393
- args = {arg[0]: {"type": arg[1], "help": f"{arg[0]} help"} for arg in args}
394
- return {name: {"arguments": args, "type": "command", "help": f"{name} help"}}
395
-
396
-
397
- def _get_query_settings_static_info(name, args):
398
- args = {arg[0]: {"type": arg[1], "help": f"{arg[0]} help"} for arg in args}
399
- return {name: {"arguments": args, "type": "query", "help": f"{name} help"}}
400
-
401
-
402
- _settings_static_info = {
403
- "children": (
404
- _get_group_settings_static_info(
405
- "G1",
406
- (
407
- (
408
- _get_group_settings_static_info(
409
- "G2",
410
- _get_parameter_settings_static_info("P3", "integer"),
411
- {},
412
- {},
413
- )
414
- )
415
- | _get_parameter_settings_static_info("P2", "real")
416
- ),
417
- _get_command_settings_static_info("C2", [("A2", "real")]),
418
- _get_query_settings_static_info("Q2", [("A2", "real")]),
419
- )
420
- | _get_parameter_settings_static_info("P1", "string")
421
- | _get_named_object_settings_static_info(
422
- "N1",
423
- _get_group_settings_static_info("G3", {}, {}, {})["G3"],
424
- _get_parameter_settings_static_info("P4", "string"),
425
- )
426
- ),
427
- "commands": _get_command_settings_static_info("C1", [("A1", "string")]),
428
- "queries": _get_query_settings_static_info("Q1", [("A1", "string")]),
429
- "type": "group",
430
- }
431
-
432
-
433
- _expected_settings_api_output = '''#
434
- # This is an auto-generated file. DO NOT EDIT!
435
- #
436
-
437
- from ansys.fluent.core.solver.flobject import *
438
-
439
- from ansys.fluent.core.solver.flobject import (
440
- _ChildNamedObjectAccessorMixin,
441
- _NonCreatableNamedObjectMixin,
442
- _InputFile,
443
- _OutputFile,
444
- _InOutFile,
445
- )
446
-
447
- SHASH = "3e6d76a4601701388ea8258912d145b7b7c436699a50b6c7fe9a29f41eeff194"
448
-
449
- class P3(Integer):
450
- """
451
- P3 help.
452
- """
453
- version = '251'
454
- fluent_name = 'P3'
455
- _python_name = 'P3'
456
-
457
- class G2(Group):
458
- """
459
- G2 help.
460
- """
461
- version = '251'
462
- fluent_name = 'G2'
463
- _python_name = 'G2'
464
- child_names = ['P3']
465
- _child_classes = dict(
466
- P3=P3,
467
- )
468
-
469
- class P2(Real):
470
- """
471
- P2 help.
472
- """
473
- version = '251'
474
- fluent_name = 'P2'
475
- _python_name = 'P2'
476
-
477
- class A2(Real):
478
- """
479
- A2 help.
480
- """
481
- version = '251'
482
- fluent_name = 'A2'
483
- _python_name = 'A2'
484
-
485
- class C2(Command):
486
- """
487
- C2 help.
488
-
489
- Parameters
490
- ----------
491
- A2 : real
492
- A2 help.
493
- """
494
- version = '251'
495
- fluent_name = 'C2'
496
- _python_name = 'C2'
497
- argument_names = ['A2']
498
- _child_classes = dict(
499
- A2=A2,
500
- )
501
-
502
- class Q2(Query):
503
- """
504
- Q2 help.
505
-
506
- Parameters
507
- ----------
508
- A2 : real
509
- A2 help.
510
- """
511
- version = '251'
512
- fluent_name = 'Q2'
513
- _python_name = 'Q2'
514
- argument_names = ['A2']
515
- _child_classes = dict(
516
- A2=A2,
517
- )
518
-
519
- class G1(Group):
520
- """
521
- G1 help.
522
- """
523
- version = '251'
524
- fluent_name = 'G1'
525
- _python_name = 'G1'
526
- child_names = ['G2', 'P2']
527
- command_names = ['C2']
528
- query_names = ['Q2']
529
- _child_classes = dict(
530
- G2=G2,
531
- P2=P2,
532
- C2=C2,
533
- Q2=Q2,
534
- )
535
-
536
- class P1(String):
537
- """
538
- P1 help.
539
- """
540
- version = '251'
541
- fluent_name = 'P1'
542
- _python_name = 'P1'
543
-
544
- class P4(String):
545
- """
546
- P4 help.
547
- """
548
- version = '251'
549
- fluent_name = 'P4'
550
- _python_name = 'P4'
551
-
552
- class N1_child(Group):
553
- """
554
- 'child_object_type' of N1.
555
- """
556
- version = '251'
557
- fluent_name = 'child-object-type'
558
- _python_name = 'N1_child'
559
-
560
- class N1(NamedObject[N1_child], _NonCreatableNamedObjectMixin[N1_child]):
561
- """
562
- N1 help.
563
- """
564
- version = '251'
565
- fluent_name = 'N1'
566
- _python_name = 'N1'
567
- child_names = ['P4']
568
- _child_classes = dict(
569
- P4=P4,
570
- )
571
- child_object_type = N1_child
572
-
573
- class A1(String):
574
- """
575
- A1 help.
576
- """
577
- version = '251'
578
- fluent_name = 'A1'
579
- _python_name = 'A1'
580
-
581
- class C1(Command):
582
- """
583
- C1 help.
584
-
585
- Parameters
586
- ----------
587
- A1 : str
588
- A1 help.
589
- """
590
- version = '251'
591
- fluent_name = 'C1'
592
- _python_name = 'C1'
593
- argument_names = ['A1']
594
- _child_classes = dict(
595
- A1=A1,
596
- )
597
-
598
- class Q1(Query):
599
- """
600
- Q1 help.
601
-
602
- Parameters
603
- ----------
604
- A1 : str
605
- A1 help.
606
- """
607
- version = '251'
608
- fluent_name = 'Q1'
609
- _python_name = 'Q1'
610
- argument_names = ['A1']
611
- _child_classes = dict(
612
- A1=A1,
613
- )
614
-
615
- class root(Group):
616
- """
617
- 'root' object.
618
- """
619
- version = '251'
620
- fluent_name = ''
621
- _python_name = 'root'
622
- child_names = ['G1', 'P1', 'N1']
623
- command_names = ['C1']
624
- query_names = ['Q1']
625
- _child_classes = dict(
626
- G1=G1,
627
- P1=P1,
628
- N1=N1,
629
- C1=C1,
630
- Q1=Q1,
631
- )''' # noqa: W293
632
-
633
-
634
- def test_codegen_with_settings_static_info(monkeypatch):
635
- codegen_outdir = Path(tempfile.mkdtemp())
636
- monkeypatch.setattr(pyfluent, "CODEGEN_OUTDIR", codegen_outdir)
637
- version = "251"
638
- static_infos = {}
639
- static_infos[StaticInfoType.SETTINGS] = _settings_static_info
640
- allapigen.generate(version, static_infos)
641
- generated_paths = list(codegen_outdir.iterdir())
642
- assert len(generated_paths) == 2
643
- assert set(p.name for p in generated_paths) == {
644
- f"api_tree_{version}.pickle",
645
- "solver",
646
- }
647
- solver_paths = list((codegen_outdir / "solver").iterdir())
648
- assert len(solver_paths) == 2
649
- assert set(p.name for p in solver_paths) == {
650
- f"settings_{version}.py",
651
- f"settings_{version}.pyi",
652
- }
653
- with open(codegen_outdir / "solver" / f"settings_{version}.py", "r") as f:
654
- assert f.read().strip() == _expected_settings_api_output
655
- api_tree_file = get_api_tree_file_name(version)
656
- with open(api_tree_file, "rb") as f:
657
- api_tree = pickle.load(f)
658
- settings_tree = {
659
- "C1": "Command",
660
- "G1": {
661
- "C2": "Command",
662
- "G2": {"P3": "Parameter"},
663
- "P2": "Parameter",
664
- "Q2": "Query",
665
- },
666
- "N1:<name>": {"P4": "Parameter"},
667
- "P1": "Parameter",
668
- "Q1": "Query",
669
- }
670
- api_tree_expected = {}
671
- api_tree_expected["<meshing_session>"] = {}
672
- api_tree_expected["<solver_session>"] = settings_tree
673
- assert api_tree == api_tree_expected
674
- shutil.rmtree(str(codegen_outdir))
675
-
676
-
677
- _settings_static_info_duplicate_parameters = {
678
- "children": (
679
- _get_group_settings_static_info(
680
- "G1",
681
- (
682
- (
683
- _get_group_settings_static_info(
684
- "G2",
685
- _get_parameter_settings_static_info("P1", "string"),
686
- {},
687
- {},
688
- )
689
- )
690
- | _get_parameter_settings_static_info("P1", "string")
691
- ),
692
- {},
693
- {},
694
- )
695
- ),
696
- "commands": {},
697
- "queries": {},
698
- "type": "group",
699
- }
700
-
701
- _settings_static_info_different_parameters_with_same_name = {
702
- "children": (
703
- _get_group_settings_static_info(
704
- "G1",
705
- (
706
- (
707
- _get_group_settings_static_info(
708
- "G2",
709
- _get_parameter_settings_static_info("P1", "real"),
710
- {},
711
- {},
712
- )
713
- )
714
- | _get_parameter_settings_static_info("P1", "string")
715
- ),
716
- {},
717
- {},
718
- )
719
- ),
720
- "commands": {},
721
- "queries": {},
722
- "type": "group",
723
- }
724
-
725
-
726
- _settings_static_info_combined_case = {
727
- "children": (
728
- _get_group_settings_static_info(
729
- "G1",
730
- (
731
- (
732
- _get_group_settings_static_info(
733
- "G2",
734
- (
735
- _get_parameter_settings_static_info("P1", "real")
736
- | _get_parameter_settings_static_info("P2", "string")
737
- ),
738
- {},
739
- {},
740
- )
741
- )
742
- | _get_parameter_settings_static_info("P1", "string")
743
- | _get_parameter_settings_static_info("P2", "string")
744
- ),
745
- {},
746
- {},
747
- )
748
- ),
749
- "commands": {},
750
- "queries": {},
751
- "type": "group",
752
- }
753
-
754
-
755
- @pytest.mark.parametrize(
756
- "settings_static_info,class_names",
757
- [
758
- (_settings_static_info_duplicate_parameters, ["P1", "G2", "G1", "root"]),
759
- (
760
- _settings_static_info_different_parameters_with_same_name,
761
- ["P1_1", "G2", "P1", "G1", "root"],
762
- ),
763
- (_settings_static_info_combined_case, ["P1_1", "P2", "G2", "P1", "G1", "root"]),
764
- ],
765
- )
766
- def test_codegen_with_settings_static_info_edge_cases(
767
- monkeypatch, settings_static_info, class_names
768
- ):
769
-
770
- codegen_outdir = Path(tempfile.mkdtemp())
771
- monkeypatch.setattr(pyfluent, "CODEGEN_OUTDIR", codegen_outdir)
772
- version = "251"
773
- static_infos = {}
774
- static_infos[StaticInfoType.SETTINGS] = settings_static_info
775
- allapigen.generate(version, static_infos)
776
- with open(codegen_outdir / "solver" / f"settings_{version}.py", "r") as f:
777
- module_def = ast.parse(f.read())
778
- class_names_from_file = [
779
- x.name for x in module_def.body if isinstance(x, ast.ClassDef)
780
- ]
781
- # The order of classes is important.
782
- assert class_names_from_file == class_names
783
- shutil.rmtree(str(codegen_outdir))