Skip to content

Commit

Permalink
feat: Send mapped option as grpc metadata (#3582)
Browse files Browse the repository at this point in the history
* feat: Send mapped option as grpc metadata

* test: enable test_on_command_executed_lifetime
  • Loading branch information
mkundu1 authored Jan 9, 2025
1 parent dfc482c commit 9d0248d
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 18 deletions.
10 changes: 2 additions & 8 deletions src/ansys/fluent/core/launcher/fluent_container.py
Original file line number Diff line number Diff line change
Expand Up @@ -319,16 +319,10 @@ def configure_container_dict(
container_dict["environment"] = {}
container_dict["environment"]["FLUENT_NO_AUTOMATIC_TRANSCRIPT"] = "1"

if (
os.getenv("REMOTING_NEW_DM_API") == "1"
or os.getenv("REMOTING_MAPPED_NEW_DM_API") == "1"
):
if os.getenv("REMOTING_NEW_DM_API") == "1":
if "environment" not in container_dict:
container_dict["environment"] = {}
if os.getenv("REMOTING_NEW_DM_API") == "1":
container_dict["environment"]["REMOTING_NEW_DM_API"] = "1"
if os.getenv("REMOTING_MAPPED_NEW_DM_API") == "1":
container_dict["environment"]["REMOTING_MAPPED_NEW_DM_API"] = "1"
container_dict["environment"]["REMOTING_NEW_DM_API"] = "1"

if pyfluent.LAUNCH_FLUENT_IP or os.getenv("REMOTING_SERVER_ADDRESS"):
if "environment" not in container_dict:
Expand Down
2 changes: 2 additions & 0 deletions src/ansys/fluent/core/services/datamodel_se.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,8 @@ def __init__(
self._stub = DataModelGrpcModule.DataModelStub(intercept_channel)
self._metadata = metadata
self.file_transfer_service = file_transfer_service
if os.getenv("REMOTING_MAPPED_NEW_DM_API") == "1":
self._metadata.append(("mapped", "1"))

# TODO: Remove it from the proto interface
def initialize_datamodel(
Expand Down
13 changes: 6 additions & 7 deletions tests/test_datamodel_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,12 @@
def test_env_var_setting(datamodel_api_version_all, request, new_solver_session):
solver = new_solver_session
test_name = request.node.name
for var in ["REMOTING_NEW_DM_API", "REMOTING_MAPPED_NEW_DM_API"]:
# TODO: It might be possible to check the param value in the fixture
# instead of checking the test name here.
if test_name.endswith("[old]"):
assert solver.scheme_eval.scheme_eval(f'(getenv "{var}")') is None
elif test_name.endswith("[new]"):
assert solver.scheme_eval.scheme_eval(f'(getenv "{var}")') == "1"
# TODO: It might be possible to check the param value in the fixture
# instead of checking the test name here.
if test_name.endswith("[old]"):
assert solver.scheme_eval.scheme_eval('(getenv "REMOTING_NEW_DM_API")') is None
elif test_name.endswith("[new]"):
assert solver.scheme_eval.scheme_eval('(getenv "REMOTING_NEW_DM_API")') == "1"


@pytest.mark.fluent_version(">=25.2")
Expand Down
4 changes: 1 addition & 3 deletions tests/test_datamodel_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -655,7 +655,6 @@ def test_on_affected_at_type_path_lifetime(new_solver_session):
assert "/test/affected/A:A1/B-1" not in solver._se_service.subscriptions


@pytest.mark.skip(reason="https://github.com/ansys/pyfluent/issues/3625")
@pytest.mark.fluent_version(">=24.2")
def test_on_command_executed_lifetime(new_solver_session):
solver = new_solver_session
Expand All @@ -672,8 +671,7 @@ def test_on_command_executed_lifetime(new_solver_session):
else:
_ = root.A["A1"].add_on_command_executed(lambda *args: data.append(1))
root.A["A1"].add_on_command_executed(lambda *args: data.append(2))
# TODO: path should be appended to the tag
tags = ["/test/command_executed", "/test/command_executed-1"]
tags = ["/test/command_executed/A:A1", "/test/command_executed/A:A1-1"]
gc.collect()
for tag in tags:
assert tag in solver._se_service.subscriptions
Expand Down

0 comments on commit 9d0248d

Please sign in to comment.