From 2f8209954b52b88e7aeb2709b136907df56b89de Mon Sep 17 00:00:00 2001 From: Mainak Kundu Date: Wed, 5 Apr 2023 14:33:06 -0400 Subject: [PATCH] Datamodel attr caching --- src/ansys/fluent/core/__init__.py | 6 ++++++ src/ansys/fluent/core/services/datamodel_se.py | 4 +++- src/ansys/fluent/core/session_pure_meshing.py | 5 ++--- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/ansys/fluent/core/__init__.py b/src/ansys/fluent/core/__init__.py index ea09479245bd..4e83df705815 100644 --- a/src/ansys/fluent/core/__init__.py +++ b/src/ansys/fluent/core/__init__.py @@ -78,5 +78,11 @@ def version_info() -> str: pydoc.text.docother = fldoc.docother.__get__(pydoc.text, pydoc.TextDoc) +# Whether to use datamodel state caching DATAMODEL_USE_STATE_CACHE = True + +# Whether to use datamodel attribute caching DATAMODEL_USE_ATTR_CACHE = True + +# Whether stream and cache commands state +DATAMODEL_USE_NOCOMMANDS_DIFF_STATE = True diff --git a/src/ansys/fluent/core/services/datamodel_se.py b/src/ansys/fluent/core/services/datamodel_se.py index 43e9a3798089..1c8c362c17e1 100644 --- a/src/ansys/fluent/core/services/datamodel_se.py +++ b/src/ansys/fluent/core/services/datamodel_se.py @@ -411,7 +411,9 @@ def get_attr(self, attrib: str) -> Any: Any Value of the attribute. """ - if pyfluent.DATAMODEL_USE_ATTR_CACHE: + if pyfluent.DATAMODEL_USE_ATTR_CACHE and hasattr( + DataModelProtoModule, "SubscribeEventsRequest" + ): return self._get_cached_attr(attrib) return self._get_remote_attr(attrib) diff --git a/src/ansys/fluent/core/session_pure_meshing.py b/src/ansys/fluent/core/session_pure_meshing.py index 3daab8634575..21c0baf5865e 100644 --- a/src/ansys/fluent/core/session_pure_meshing.py +++ b/src/ansys/fluent/core/session_pure_meshing.py @@ -40,9 +40,8 @@ def __init__(self, fluent_connection: FluentConnection): for rules in self.__class__.rules: request = datamodel_se_pb2.DataModelRequest() request.rules = rules - request.diffstate = ( - datamodel_se_pb2.DIFFSTATE_NOCOMMANDS - ) # DIFFSTATE_FULL? + if pyfluent.DATAMODEL_USE_NOCOMMANDS_DIFF_STATE: + request.diffstate = datamodel_se_pb2.DIFFSTATE_NOCOMMANDS streaming = StreamingService( stub=datamodel_service_se._stub, request=request,