ansys-fluent-core 0.34.1__py3-none-any.whl → 0.35.dev0__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 (81) hide show
  1. ansys/fluent/core/__init__.py +48 -84
  2. ansys/fluent/core/codegen/allapigen.py +2 -2
  3. ansys/fluent/core/codegen/builtin_settingsgen.py +50 -28
  4. ansys/fluent/core/codegen/datamodelgen.py +3 -1
  5. ansys/fluent/core/codegen/print_fluent_version.py +2 -2
  6. ansys/fluent/core/codegen/settingsgen.py +1 -1
  7. ansys/fluent/core/codegen/tuigen.py +4 -4
  8. ansys/fluent/core/data_model_cache.py +2 -2
  9. ansys/fluent/core/docker/docker_compose.py +8 -9
  10. ansys/fluent/core/docker/utils.py +1 -1
  11. ansys/fluent/core/examples/downloads.py +8 -11
  12. ansys/fluent/core/fluent_connection.py +23 -15
  13. ansys/fluent/core/generated/api_tree/api_objects.json +1 -1
  14. ansys/fluent/core/generated/datamodel_231/flicing.py +55 -55
  15. ansys/fluent/core/generated/datamodel_231/meshing.py +209 -209
  16. ansys/fluent/core/generated/datamodel_232/flicing.py +45 -45
  17. ansys/fluent/core/generated/datamodel_232/meshing.py +205 -205
  18. ansys/fluent/core/generated/datamodel_241/flicing.py +30 -30
  19. ansys/fluent/core/generated/datamodel_241/meshing.py +298 -298
  20. ansys/fluent/core/generated/datamodel_242/flicing.py +35 -35
  21. ansys/fluent/core/generated/datamodel_242/meshing.py +321 -321
  22. ansys/fluent/core/generated/datamodel_242/part_management.py +3 -3
  23. ansys/fluent/core/generated/datamodel_251/flicing.py +40 -40
  24. ansys/fluent/core/generated/datamodel_251/meshing.py +315 -315
  25. ansys/fluent/core/generated/datamodel_251/part_management.py +6 -6
  26. ansys/fluent/core/generated/datamodel_252/flicing.py +45 -45
  27. ansys/fluent/core/generated/datamodel_252/meshing.py +398 -398
  28. ansys/fluent/core/generated/datamodel_261/flicing.py +50 -50
  29. ansys/fluent/core/generated/datamodel_261/meshing.py +406 -406
  30. ansys/fluent/core/generated/datamodel_261/meshing_utilities.py +616 -296
  31. ansys/fluent/core/generated/datamodel_261/part_management.py +10 -10
  32. ansys/fluent/core/generated/fluent_version_252.py +1 -1
  33. ansys/fluent/core/generated/fluent_version_261.py +3 -3
  34. ansys/fluent/core/generated/meshing/tui_261.py +1178 -1133
  35. ansys/fluent/core/generated/solver/settings_261.py +2378 -3023
  36. ansys/fluent/core/generated/solver/settings_261.pyi +1537 -1456
  37. ansys/fluent/core/generated/solver/settings_builtin.py +515 -27
  38. ansys/fluent/core/generated/solver/settings_builtin.pyi +2 -18
  39. ansys/fluent/core/generated/solver/tui_261.py +2606 -3483
  40. ansys/fluent/core/launcher/container_launcher.py +19 -4
  41. ansys/fluent/core/launcher/fluent_container.py +48 -39
  42. ansys/fluent/core/launcher/launch_options.py +5 -4
  43. ansys/fluent/core/launcher/launcher.py +16 -3
  44. ansys/fluent/core/launcher/launcher_utils.py +63 -15
  45. ansys/fluent/core/launcher/pim_launcher.py +17 -3
  46. ansys/fluent/core/launcher/process_launch_string.py +3 -2
  47. ansys/fluent/core/launcher/server_info.py +7 -3
  48. ansys/fluent/core/launcher/slurm_launcher.py +4 -2
  49. ansys/fluent/core/launcher/standalone_launcher.py +6 -3
  50. ansys/fluent/core/launcher/watchdog.py +3 -3
  51. ansys/fluent/core/launcher/watchdog_exec +1 -1
  52. ansys/fluent/core/logger.py +3 -1
  53. ansys/fluent/core/module_config.py +358 -0
  54. ansys/fluent/core/pyfluent_warnings.py +2 -2
  55. ansys/fluent/core/report.py +0 -2
  56. ansys/fluent/core/search.py +31 -18
  57. ansys/fluent/core/services/api_upgrade.py +3 -2
  58. ansys/fluent/core/services/datamodel_se.py +4 -2
  59. ansys/fluent/core/services/health_check.py +3 -1
  60. ansys/fluent/core/services/interceptors.py +8 -6
  61. ansys/fluent/core/session.py +31 -3
  62. ansys/fluent/core/session_pure_meshing.py +1 -1
  63. ansys/fluent/core/session_shared.py +4 -4
  64. ansys/fluent/core/session_solver.py +8 -2
  65. ansys/fluent/core/session_utilities.py +7 -0
  66. ansys/fluent/core/solver/flobject.py +6 -4
  67. ansys/fluent/core/solver/settings_builtin_bases.py +3 -3
  68. ansys/fluent/core/solver/settings_builtin_data.py +2 -14
  69. ansys/fluent/core/streaming_services/datamodel_event_streaming.py +3 -2
  70. ansys/fluent/core/streaming_services/datamodel_streaming.py +3 -1
  71. ansys/fluent/core/streaming_services/events_streaming.py +2 -18
  72. ansys/fluent/core/system_coupling.py +3 -1
  73. ansys/fluent/core/utils/__init__.py +0 -7
  74. ansys/fluent/core/utils/data_transfer.py +3 -3
  75. ansys/fluent/core/utils/file_transfer_service.py +24 -15
  76. ansys/fluent/core/utils/fluent_version.py +3 -3
  77. ansys/fluent/core/utils/networking.py +2 -2
  78. {ansys_fluent_core-0.34.1.dist-info → ansys_fluent_core-0.35.dev0.dist-info}/METADATA +1 -1
  79. {ansys_fluent_core-0.34.1.dist-info → ansys_fluent_core-0.35.dev0.dist-info}/RECORD +81 -80
  80. {ansys_fluent_core-0.34.1.dist-info → ansys_fluent_core-0.35.dev0.dist-info}/LICENSE +0 -0
  81. {ansys_fluent_core-0.34.1.dist-info → ansys_fluent_core-0.35.dev0.dist-info}/WHEEL +0 -0
@@ -514,7 +514,9 @@ class DatamodelService(StreamingService):
514
514
  self.event_streaming = None
515
515
  self.subscriptions = SubscriptionList()
516
516
  self.file_transfer_service = file_transfer_service
517
- self.cache = DataModelCache() if pyfluent.DATAMODEL_USE_STATE_CACHE else None
517
+ self.cache = (
518
+ DataModelCache() if pyfluent.config.datamodel_use_state_cache else None
519
+ )
518
520
  self.version = version
519
521
 
520
522
  def get_attribute_value(self, rules: str, path: str, attribute: str) -> ValueT:
@@ -1096,7 +1098,7 @@ class PyStateContainer(PyCallableStateObject):
1096
1098
  Any
1097
1099
  Value of the attribute.
1098
1100
  """
1099
- if pyfluent.DATAMODEL_USE_ATTR_CACHE:
1101
+ if pyfluent.config.datamodel_use_attr_cache:
1100
1102
  return self._get_cached_attr(attrib)
1101
1103
  return self._get_remote_attr(attrib)
1102
1104
 
@@ -80,7 +80,9 @@ class HealthCheckService:
80
80
  """
81
81
  request = HealthCheckModule.HealthCheckRequest()
82
82
  response = self._stub.Check(
83
- request, metadata=self._metadata, timeout=pyfluent.CHECK_HEALTH_TIMEOUT
83
+ request,
84
+ metadata=self._metadata,
85
+ timeout=pyfluent.config.check_health_timeout,
84
86
  )
85
87
  return HealthCheckService.Status(response.status)
86
88
 
@@ -24,7 +24,6 @@
24
24
 
25
25
  import builtins
26
26
  import logging
27
- import os
28
27
  from typing import Any
29
28
 
30
29
  from google.protobuf.json_format import MessageToDict
@@ -34,8 +33,6 @@ import grpc
34
33
  from ansys.fluent.core.services.batch_ops import BatchOps
35
34
 
36
35
  network_logger: logging.Logger = logging.getLogger("pyfluent.networking")
37
- log_bytes_limit: int = int(os.getenv("PYFLUENT_GRPC_LOG_BYTES_LIMIT", 1000))
38
- truncate_len: int = log_bytes_limit // 5
39
36
 
40
37
 
41
38
  def _upper_snake_case_to_camel_case(name: str) -> str:
@@ -43,14 +40,17 @@ def _upper_snake_case_to_camel_case(name: str) -> str:
43
40
 
44
41
 
45
42
  def _truncate_grpc_str(message: Message) -> str:
43
+ from ansys.fluent.core import config
44
+
45
+ truncate_len = config.grpc_log_bytes_limit // 5
46
46
  message_bytes = message.ByteSize()
47
47
  message_str = str(MessageToDict(message))
48
- if not log_bytes_limit or message_bytes < log_bytes_limit:
48
+ if not config.grpc_log_bytes_limit or message_bytes < config.grpc_log_bytes_limit:
49
49
  return message_str
50
50
  else:
51
51
  network_logger.debug(
52
52
  f"GRPC_TRACE: message partially hidden, {message_bytes} bytes > "
53
- f"{log_bytes_limit} bytes limit. To see the full message, set PYFLUENT_GRPC_LOG_BYTES_LIMIT to 0."
53
+ f"{config.grpc_log_bytes_limit} bytes limit. To see the full message, set PYFLUENT_GRPC_LOG_BYTES_LIMIT to 0."
54
54
  )
55
55
  return f"{message_str[:truncate_len]} < ... > {message_str[-truncate_len:]}"
56
56
 
@@ -68,6 +68,8 @@ class TracingInterceptor(grpc.UnaryUnaryClientInterceptor):
68
68
  client_call_details: grpc.ClientCallDetails,
69
69
  request: Any,
70
70
  ) -> Any:
71
+ from ansys.fluent.core import config
72
+
71
73
  network_logger.debug(
72
74
  f"GRPC_TRACE: RPC = {client_call_details.method}, request = {_truncate_grpc_str(request)}"
73
75
  )
@@ -75,7 +77,7 @@ class TracingInterceptor(grpc.UnaryUnaryClientInterceptor):
75
77
  if not response.exception():
76
78
  # call _truncate_grpc_str early to get the size warning even when hiding secrets
77
79
  response_str = _truncate_grpc_str(response.result())
78
- if os.getenv("PYFLUENT_HIDE_LOG_SECRETS") != "1":
80
+ if not config.hide_log_secrets:
79
81
  network_logger.debug(f"GRPC_TRACE: response = {response_str}")
80
82
  return response
81
83
 
@@ -33,7 +33,6 @@ from deprecated.sphinx import deprecated
33
33
 
34
34
  from ansys.fluent.core.fluent_connection import FluentConnection
35
35
  from ansys.fluent.core.journaling import Journal
36
- from ansys.fluent.core.launcher.launcher_utils import is_compose
37
36
  from ansys.fluent.core.pyfluent_warnings import (
38
37
  PyFluentDeprecationWarning,
39
38
  PyFluentUserWarning,
@@ -151,6 +150,7 @@ class BaseSession:
151
150
  file_transfer_service,
152
151
  event_type,
153
152
  get_zones_info,
153
+ launcher_args,
154
154
  )
155
155
  self.register_finalizer_callback = fluent_connection.register_finalizer_cb
156
156
 
@@ -161,10 +161,14 @@ class BaseSession:
161
161
  file_transfer_service: Any | None = None,
162
162
  event_type=None,
163
163
  get_zones_info: weakref.WeakMethod[Callable[[], list[ZoneInfo]]] | None = None,
164
+ launcher_args: Dict[str, Any] | None = None,
164
165
  ):
165
166
  """Build a BaseSession object from fluent_connection object."""
166
167
  self._fluent_connection = fluent_connection
168
+ # Stores the backup of the fluent connection for later reference.
169
+ self._fluent_connection_backup = self._fluent_connection
167
170
  self._file_transfer_service = file_transfer_service
171
+ self._launcher_args = launcher_args
168
172
  self._error_state = fluent_connection._error_state
169
173
  self.scheme = scheme_eval
170
174
  self.rp_vars = RPVars(self.scheme.string_eval)
@@ -354,8 +358,32 @@ class BaseSession:
354
358
  return FluentVersion(self.scheme.version)
355
359
 
356
360
  def _exit_compose_service(self):
357
- if self._fluent_connection._container and is_compose():
358
- self._fluent_connection._container.stop()
361
+ args = self._launcher_args or {}
362
+ compose_config = args.get("compose_config", None)
363
+
364
+ container = self._fluent_connection._container
365
+ if compose_config and compose_config.is_compose:
366
+ container.stop()
367
+
368
+ def wait_process_finished(self, wait: float | int | bool = 60):
369
+ """Returns ``True`` if local Fluent processes have finished, ``False`` if they
370
+ are still running when wait limit (default 60 seconds) is reached. Immediately
371
+ cancels and returns ``None`` if ``wait`` is set to ``False``.
372
+
373
+ Parameters
374
+ ----------
375
+ wait : float, int or bool, optional
376
+ How long to wait for processes to finish before returning, by default 60 seconds.
377
+ Can also be set to ``True``, which will result in waiting indefinitely.
378
+
379
+ Raises
380
+ ------
381
+ UnsupportedRemoteFluentInstance
382
+ If current Fluent instance is running remotely.
383
+ WaitTypeError
384
+ If ``wait`` is specified improperly.
385
+ """
386
+ return self._fluent_connection_backup.wait_process_finished()
359
387
 
360
388
  def exit(self, **kwargs) -> None:
361
389
  """Exit session."""
@@ -120,7 +120,7 @@ class PureMeshing(BaseSession):
120
120
  self.datamodel_streams[rules] = stream
121
121
  stream.start(
122
122
  rules=rules,
123
- no_commands_diff_state=pyfluent.DATAMODEL_USE_NOCOMMANDS_DIFF_STATE,
123
+ no_commands_diff_state=pyfluent.config.datamodel_use_nocommands_diff_state,
124
124
  )
125
125
  self._fluent_connection.register_finalizer_cb(stream.stop)
126
126
 
@@ -47,11 +47,11 @@ tui_logger = logging.getLogger("pyfluent.tui")
47
47
 
48
48
  def _make_tui_module(session, module_name):
49
49
  try:
50
- from ansys.fluent.core import CODEGEN_OUTDIR
50
+ from ansys.fluent.core import config
51
51
 
52
52
  tui_module = pyfluent.utils.load_module(
53
53
  f"{module_name}_tui_{session._version}",
54
- CODEGEN_OUTDIR / module_name / f"tui_{session._version}.py",
54
+ config.codegen_outdir / module_name / f"tui_{session._version}.py",
55
55
  )
56
56
  warning_for_fluent_dev_version(session._version)
57
57
  return tui_module.main_menu(
@@ -64,13 +64,13 @@ def _make_tui_module(session, module_name):
64
64
 
65
65
  def _make_datamodel_module(session, module_name):
66
66
  try:
67
- from ansys.fluent.core import CODEGEN_OUTDIR
67
+ from ansys.fluent.core import config
68
68
  from ansys.fluent.core.codegen.datamodelgen import datamodel_file_name_map
69
69
 
70
70
  file_name = datamodel_file_name_map[module_name]
71
71
  module = pyfluent.utils.load_module(
72
72
  f"{module_name}_{session._version}",
73
- CODEGEN_OUTDIR / f"datamodel_{session._version}" / f"{file_name}.py",
73
+ config.codegen_outdir / f"datamodel_{session._version}" / f"{file_name}.py",
74
74
  )
75
75
  warning_for_fluent_dev_version(session._version)
76
76
  return module.Root(session._se_service, module_name, [])
@@ -119,13 +119,16 @@ class Solver(BaseSession):
119
119
  get_zones_info=weakref.WeakMethod(self._get_zones_info),
120
120
  )
121
121
  self._settings = None
122
- self._build_from_fluent_connection(fluent_connection, scheme_eval)
122
+ self._build_from_fluent_connection(
123
+ fluent_connection, scheme_eval, launcher_args=launcher_args
124
+ )
123
125
 
124
126
  def _build_from_fluent_connection(
125
127
  self,
126
128
  fluent_connection,
127
129
  scheme_eval: SchemeEval,
128
130
  file_transfer_service: Any | None = None,
131
+ launcher_args: Dict[str, Any] | None = None,
129
132
  ):
130
133
  self._tui_service = self._datamodel_service_tui
131
134
  self._se_service = self._datamodel_service_se
@@ -134,6 +137,7 @@ class Solver(BaseSession):
134
137
  self._system_coupling = None
135
138
  self._fluent_version = None
136
139
  self._bg_session_threads = []
140
+ self._launcher_args = launcher_args
137
141
  self._solution_variable_service = service_creator("svar").create(
138
142
  fluent_connection._channel, fluent_connection._metadata
139
143
  )
@@ -267,7 +271,7 @@ class Solver(BaseSession):
267
271
  "solution/run-calculation/calculate",
268
272
  "solution/run-calculation/dual-time-iterate",
269
273
  ]
270
- if pyfluent.SUPPORT_SOLVER_INTERRUPT:
274
+ if pyfluent.config.support_solver_interrupt:
271
275
  if command.path in interruptible_commands:
272
276
  command._root.solution.run_calculation.interrupt()
273
277
 
@@ -296,10 +300,12 @@ class Solver(BaseSession):
296
300
  bg_session._fluent_connection,
297
301
  bg_session._fluent_connection._connection_interface.scheme_eval,
298
302
  event_type=SolverEvent,
303
+ launcher_args=launcher_args,
299
304
  )
300
305
  self._build_from_fluent_connection(
301
306
  bg_session._fluent_connection,
302
307
  bg_session._fluent_connection._connection_interface.scheme_eval,
308
+ launcher_args=launcher_args,
303
309
  )
304
310
  # TODO temporary fix till set_state at settings root is fixed
305
311
  _set_state_safe(self.settings, state)
@@ -264,6 +264,7 @@ class SessionBase:
264
264
  @classmethod
265
265
  def from_pim(
266
266
  cls,
267
+ ui_mode: UIMode | str | None = None,
267
268
  graphics_driver: (
268
269
  FluentWindowsGraphicsDriver | FluentLinuxGraphicsDriver | str | None
269
270
  ) = None,
@@ -274,6 +275,7 @@ class SessionBase:
274
275
  start_timeout: int = 60,
275
276
  additional_arguments: str = "",
276
277
  cleanup_on_exit: bool = True,
278
+ dry_run: bool | None = None,
277
279
  start_transcript: bool = True,
278
280
  gpu: bool | None = None,
279
281
  start_watchdog: bool | None = None,
@@ -284,6 +286,8 @@ class SessionBase:
284
286
 
285
287
  Parameters
286
288
  ----------
289
+ ui_mode : UIMode or str, optional
290
+ Defines the user interface mode for Fluent. Options correspond to values in the ``UIMode`` enum.
287
291
  graphics_driver : FluentWindowsGraphicsDriver or FluentLinuxGraphicsDriver
288
292
  Specifies the graphics driver for Fluent. Options are from the ``FluentWindowsGraphicsDriver`` enum
289
293
  (for Windows) or the ``FluentLinuxGraphicsDriver`` enum (for Linux).
@@ -309,6 +313,9 @@ class SessionBase:
309
313
  cleanup_on_exit : bool
310
314
  Determines whether to shut down the connected Fluent session upon exit or when calling
311
315
  the session's `exit()` method. Defaults to True.
316
+ dry_run : bool, optional
317
+ If True, does not launch Fluent but prints configuration information instead. If dry running a
318
+ PIM start, this method will return a configuration dictionary. Defaults to False.
312
319
  start_transcript : bool
313
320
  Indicates whether to start streaming the Fluent transcript in the client. Defaults to True;
314
321
  streaming can be controlled via `transcript.start()` and `transcript.stop()` methods on the session object.
@@ -1730,6 +1730,8 @@ class BaseCommand(Action):
1730
1730
 
1731
1731
  def _execute_command(self, *args, **kwds):
1732
1732
  """Execute a command with the specified positional and keyword arguments."""
1733
+ from ansys.fluent.core import config
1734
+
1733
1735
  if self.flproxy.is_interactive_mode():
1734
1736
  prompt = self.flproxy.get_command_confirmation_prompt(
1735
1737
  self._parent.path, self.obj_name, **kwds
@@ -1747,7 +1749,7 @@ class BaseCommand(Action):
1747
1749
  with self._while_executing_command():
1748
1750
  ret = self.flproxy.execute_cmd(self._parent.path, self.obj_name, **kwds)
1749
1751
  if (
1750
- os.getenv("PYFLUENT_NO_FIX_PARAMETER_LIST_RETURN") != "1"
1752
+ not config.disable_parameter_list_return_fix
1751
1753
  and FluentVersion(self._version) <= FluentVersion.v252
1752
1754
  and self.path
1753
1755
  in [
@@ -2326,16 +2328,16 @@ def get_root(
2326
2328
  RuntimeError
2327
2329
  If hash values are inconsistent.
2328
2330
  """
2329
- from ansys.fluent.core import CODEGEN_OUTDIR, utils
2331
+ from ansys.fluent.core import config, utils
2330
2332
 
2331
- if os.getenv("PYFLUENT_USE_RUNTIME_PYTHON_CLASSES") == "1":
2333
+ if config.use_runtime_python_classes:
2332
2334
  obj_info = flproxy.get_static_info()
2333
2335
  root_cls, _ = get_cls("", obj_info, version=version)
2334
2336
  else:
2335
2337
  try:
2336
2338
  settings = utils.load_module(
2337
2339
  f"settings_{version}",
2338
- CODEGEN_OUTDIR / "solver" / f"settings_{version}.py",
2340
+ config.codegen_outdir / "solver" / f"settings_{version}.py",
2339
2341
  )
2340
2342
  root_cls = settings.root
2341
2343
  warning_for_fluent_dev_version(version)
@@ -52,9 +52,9 @@ def _get_settings_root(settings_source: SettingsBase | Solver):
52
52
 
53
53
 
54
54
  def _get_settings_obj(settings_root, builtin_settings_obj):
55
- builtin_cls_name = builtin_settings_obj.__class__.__name__
55
+ builtin_cls_db_name = builtin_settings_obj.__class__._db_name
56
56
  obj = settings_root
57
- path = DATA[builtin_cls_name][1]
57
+ path = DATA[builtin_cls_db_name][1]
58
58
  found_path = None
59
59
  if isinstance(path, dict):
60
60
  version = FluentVersion(obj._version)
@@ -63,7 +63,7 @@ def _get_settings_obj(settings_root, builtin_settings_obj):
63
63
  found_path = p
64
64
  break
65
65
  if found_path is None:
66
- raise RuntimeError(f"{builtin_cls_name} is not supported in {version}.")
66
+ raise RuntimeError(f"{builtin_cls_db_name} is not supported in {version}.")
67
67
  elif isinstance(path, str):
68
68
  found_path = path
69
69
  comps = found_path.split(".")
@@ -225,26 +225,14 @@ DATA = {
225
225
  "VelocityInlet": ("NamedObject", "setup.boundary_conditions.velocity_inlet"),
226
226
  "WallBoundaries": ("Singleton", "setup.boundary_conditions.wall"),
227
227
  "WallBoundary": ("NamedObject", "setup.boundary_conditions.wall"),
228
- "NonReflectingBoundaries": (
229
- "Singleton",
230
- {
231
- since(FluentVersion.v241): "setup.boundary_conditions.non_reflecting_bc",
232
- },
233
- ),
234
228
  "NonReflectingBoundary": (
235
- "NamedObject",
236
- {
237
- since(FluentVersion.v241): "setup.boundary_conditions.non_reflecting_bc",
238
- },
239
- ),
240
- "PerforatedWallBoundaries": (
241
229
  "Singleton",
242
230
  {
243
- since(FluentVersion.v241): "setup.boundary_conditions.perforated_wall",
231
+ since(FluentVersion.v241): "setup.boundary_conditions.non_reflecting_bc",
244
232
  },
245
233
  ),
246
234
  "PerforatedWallBoundary": (
247
- "NamedObject",
235
+ "Singleton",
248
236
  {
249
237
  since(FluentVersion.v241): "setup.boundary_conditions.perforated_wall",
250
238
  },
@@ -23,7 +23,6 @@
23
23
  """Provides a module for datamodel event streaming."""
24
24
 
25
25
  import logging
26
- import os
27
26
  import threading
28
27
  from typing import Callable
29
28
 
@@ -62,6 +61,8 @@ class DatamodelEvents(StreamingService):
62
61
 
63
62
  def _process_streaming(self, id, stream_begin_method, started_evt, *args, **kwargs):
64
63
  """Processes datamodel events."""
64
+ from ansys.fluent.core import config
65
+
65
66
  request = DataModelProtoModule.EventRequest(*args, **kwargs)
66
67
  responses = self._streaming_service.begin_streaming(
67
68
  request, started_evt, id=id, stream_begin_method=stream_begin_method
@@ -69,7 +70,7 @@ class DatamodelEvents(StreamingService):
69
70
  while True:
70
71
  try:
71
72
  response: DataModelProtoModule.EventResponse = next(responses)
72
- if os.getenv("PYFLUENT_HIDE_LOG_SECRETS") != "1":
73
+ if not config.hide_log_secrets:
73
74
  network_logger.debug(
74
75
  f"GRPC_TRACE: RPC = /grpcRemoting.DataModel/BeginEventStreaming, response = {MessageToDict(response)}"
75
76
  )
@@ -57,7 +57,9 @@ class DatamodelStream(StreamingService):
57
57
  """Processes datamodel events."""
58
58
  data_model_request = datamodel_se_pb2.DataModelRequest(*args, **kwargs)
59
59
  data_model_request.rules = rules
60
- data_model_request.returnstatechanges = pyfluent.DATAMODEL_RETURN_STATE_CHANGES
60
+ data_model_request.returnstatechanges = (
61
+ pyfluent.config.datamodel_return_state_changes
62
+ )
61
63
  if no_commands_diff_state:
62
64
  data_model_request.diffstate = datamodel_se_pb2.DIFFSTATE_NOCOMMANDS
63
65
  responses = self._streaming_service.begin_streaming(
@@ -281,30 +281,14 @@ class SolutionInitializedEventInfo(
281
281
  class ReportDefinitionUpdatedEventInfo(
282
282
  EventInfoBase, event=SolverEvent.REPORT_DEFINITION_UPDATED
283
283
  ):
284
- """Information about the event triggered when a report definition is updated.
285
-
286
- Attributes
287
- ----------
288
- report_name : str
289
- Report name.
290
- """
291
-
292
- report_name: str = field(metadata=dict(deprecated_name="reportdefinitionname"))
284
+ """Information about the event triggered when a report definition is updated."""
293
285
 
294
286
 
295
287
  @dataclass
296
288
  class ReportPlotSetUpdatedEventInfo(
297
289
  EventInfoBase, event=SolverEvent.REPORT_PLOT_SET_UPDATED
298
290
  ):
299
- """Information about the event triggered when a report plot set is updated.
300
-
301
- Attributes
302
- ----------
303
- plot_set_name : str
304
- Plot set name.
305
- """
306
-
307
- plot_set_name: str = field(metadata=dict(deprecated_name="plotsetname"))
291
+ """Information about the event triggered when a report plot set is updated."""
308
292
 
309
293
 
310
294
  class ResidualPlotUpdatedEventInfo(
@@ -252,7 +252,9 @@ class SystemCoupling:
252
252
  # the local Fluent container working directory will correspond to
253
253
  # pyfluent.EXAMPLES_PATH in the host, so that is where the SCP file
254
254
  # will be written.
255
- examples_path_scp = os.path.join(pyfluent.EXAMPLES_PATH, scp_file_name)
255
+ examples_path_scp = os.path.join(
256
+ pyfluent.config.examples_path, scp_file_name
257
+ )
256
258
  if os.path.exists(examples_path_scp):
257
259
  scp_file_name = examples_path_scp
258
260
 
@@ -42,13 +42,6 @@ def load_module(module_name, file_path):
42
42
  return module
43
43
 
44
44
 
45
- def get_examples_download_dir():
46
- """Return the path to the examples download directory."""
47
- parent_path = Path.home() / "Downloads"
48
- parent_path.mkdir(exist_ok=True)
49
- return parent_path / "ansys_fluent_core_examples"
50
-
51
-
52
45
  def get_user_data_dir():
53
46
  """Return the path to the user data directory."""
54
47
  if sys.platform == "win32":
@@ -114,7 +114,7 @@ def transfer_case(
114
114
  """
115
115
  inside_container = source_instance.connection_properties.inside_container
116
116
  if not workdir:
117
- workdir = Path(pyfluent.EXAMPLES_PATH)
117
+ workdir = Path(pyfluent.config.examples_path)
118
118
  else:
119
119
  workdir = Path(workdir)
120
120
  if inside_container:
@@ -122,9 +122,9 @@ def transfer_case(
122
122
  network_logger.warning(
123
123
  "Fluent is running inside a container, and no 'container_workdir' was specified for "
124
124
  "'transfer_case'. Assuming that the default container mount path "
125
- f"'{pyfluent.CONTAINER_MOUNT_TARGET}' is being used. "
125
+ f"'{pyfluent.config.container_mount_target}' is being used. "
126
126
  )
127
- container_workdir = PurePosixPath(pyfluent.CONTAINER_MOUNT_TARGET)
127
+ container_workdir = PurePosixPath(pyfluent.config.container_mount_target)
128
128
  network_logger.debug(f"container_workdir: {container_workdir}")
129
129
  else:
130
130
  container_workdir = PurePosixPath(container_workdir)
@@ -537,6 +537,9 @@ class PimFileTransferService:
537
537
  )
538
538
  except ModuleNotFoundError:
539
539
  pass
540
+ self.cwd = os.getcwd()
541
+ self.instance_name = self.pim_instance.name.replace("instances/", "")
542
+ self.instance_dir = os.path.join(self.cwd, self.instance_name)
540
543
 
541
544
  def file_exists_on_remote(self, file_name: str) -> bool:
542
545
  """Check if remote file exists.
@@ -604,16 +607,18 @@ class PimFileTransferService:
604
607
  if self.is_configured():
605
608
  for file in files:
606
609
  if os.path.isfile(file):
607
- if not self.file_service.file_exist(os.path.basename(file)):
608
- self.upload_file(
609
- file_name=file, remote_file_name=remote_file_name
610
- )
611
- print(f"\n{os.path.basename(file_name)} uploaded.\n")
610
+ if os.path.exists(self.instance_dir):
611
+ shutil.copy2(file, self.instance_dir)
612
612
  else:
613
- warnings.warn(
614
- f"\n{file} with the same name exists at the remote location.\n",
615
- PyFluentUserWarning,
616
- )
613
+ if not self.file_service.file_exist(os.path.basename(file)):
614
+ self.upload_file(
615
+ file_name=file, remote_file_name=remote_file_name
616
+ )
617
+ else:
618
+ warnings.warn(
619
+ f"\n{file} with the same name exists at the remote location.\n",
620
+ PyFluentUserWarning,
621
+ )
617
622
  elif not self.file_service.file_exist(os.path.basename(file)):
618
623
  raise FileNotFoundError(f"{file} does not exist.")
619
624
 
@@ -642,7 +647,7 @@ class PimFileTransferService:
642
647
  else:
643
648
  raise FileNotFoundError("Remote file does not exist.")
644
649
 
645
- def download(self, file_name: list[str] | str, local_directory: str | None = "."):
650
+ def download(self, file_name: list[str] | str, local_directory: str | None = None):
646
651
  """Download a file from the server.
647
652
 
648
653
  Parameters
@@ -652,6 +657,7 @@ class PimFileTransferService:
652
657
  local_directory : str, optional
653
658
  Local directory. The default is the current working directory.
654
659
  """
660
+ download_directory = local_directory if local_directory else self.cwd
655
661
  files = [file_name] if isinstance(file_name, str) else file_name
656
662
  if self.is_configured():
657
663
  for file in files:
@@ -661,11 +667,14 @@ class PimFileTransferService:
661
667
  PyFluentUserWarning,
662
668
  )
663
669
  else:
664
- self.download_file(
665
- file_name=os.path.basename(file),
666
- local_directory=local_directory,
667
- )
668
- print(f"\n{os.path.basename(file_name)} downloaded.\n")
670
+ download_file_name = os.path.join(self.instance_dir, file)
671
+ if os.path.exists(download_file_name):
672
+ shutil.copy2(download_file_name, download_directory)
673
+ else:
674
+ self.download_file(
675
+ file_name=os.path.basename(file),
676
+ local_directory=download_directory,
677
+ )
669
678
 
670
679
  def __call__(self, pim_instance: Any | None = None):
671
680
  self.pim_instance = pim_instance
@@ -162,7 +162,7 @@ class FluentVersion(Enum):
162
162
  FluentVersion
163
163
  FluentVersion member corresponding to the latest release.
164
164
  """
165
- return cls(pyfluent.FLUENT_RELEASE_VERSION)
165
+ return cls(pyfluent.config.fluent_release_version)
166
166
 
167
167
  @classmethod
168
168
  def current_dev(cls):
@@ -173,7 +173,7 @@ class FluentVersion(Enum):
173
173
  FluentVersion
174
174
  FluentVersion member corresponding to the latest development version.
175
175
  """
176
- return cls(pyfluent.FLUENT_DEV_VERSION)
176
+ return cls(pyfluent.config.fluent_dev_version)
177
177
 
178
178
  @property
179
179
  def awp_var(self):
@@ -188,7 +188,7 @@ class FluentVersion(Enum):
188
188
  @property
189
189
  def docker_image_tag(self):
190
190
  """Get the Fluent version as a Docker image tag."""
191
- return f"v{self.value}"
191
+ return f"v{self.value.rsplit('.', 1)[0]}.latest"
192
192
 
193
193
  def __lt__(self, other):
194
194
  if isinstance(other, FluentVersion):
@@ -79,7 +79,7 @@ def find_remoting_ip() -> str:
79
79
  str
80
80
  remoting ip address
81
81
  """
82
- from ansys.fluent.core import INFER_REMOTING_IP_TIMEOUT_PER_IP
82
+ from ansys.fluent.core import config
83
83
 
84
84
  all_ips = [
85
85
  addrinfo[-1][0]
@@ -108,7 +108,7 @@ def find_remoting_ip() -> str:
108
108
  if (
109
109
  stub.Check(
110
110
  health_pb2.HealthCheckRequest(),
111
- timeout=INFER_REMOTING_IP_TIMEOUT_PER_IP,
111
+ timeout=config.infer_remoting_ip_timeout_per_ip,
112
112
  ).status
113
113
  == health_pb2.HealthCheckResponse.ServingStatus.SERVING
114
114
  ):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: ansys-fluent-core
3
- Version: 0.34.1
3
+ Version: 0.35.dev0
4
4
  Summary: PyFluent provides Pythonic access to Ansys Fluent.
5
5
  Author-email: "ANSYS, Inc." <pyansys.core@ansys.com>
6
6
  Maintainer-email: "ANSYS, Inc." <pyansys.core@ansys.com>