Skip to content

Commit

Permalink
Datamodel attr caching
Browse files Browse the repository at this point in the history
  • Loading branch information
mkundu1 committed Apr 5, 2023
1 parent 0645893 commit 2f82099
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
6 changes: 6 additions & 0 deletions src/ansys/fluent/core/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 3 additions & 1 deletion src/ansys/fluent/core/services/datamodel_se.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
5 changes: 2 additions & 3 deletions src/ansys/fluent/core/session_pure_meshing.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 2f82099

Please sign in to comment.