Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 13 additions & 9 deletions src/ansys/fluent/core/meshing/workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,11 @@ def __init__(self, task_name):

class MeshingWorkflow:
class Task(PyCallableStateObject):
class Args(PyCallableStateObject):
def __init__(self, task):
self._task = task
self._args = task.Arguments

def __getattr__(self, attr):
return getattr(self._args, attr)

def __init__(self, meshing, name):
self._workflow = meshing._workflow
self._meshing = meshing._meshing
self._task = self._workflow.TaskObject[name]
self._cmd = None
self.Arguments = MeshingWorkflow.Task.Args(self)

@property
def CommandArguments(self):
Expand All @@ -50,6 +41,11 @@ def _command(self):
def __getattr__(self, attr):
return getattr(self._task, attr)

def __dir__(self):
return sorted(
set(list(self.__dict__.keys()) + dir(type(self)) + dir(self._task))
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add this object's attributes, the class attributes (which brings in methods), and attributes inherited from the task

)

def __init__(self, workflow, meshing):
self._workflow = workflow
self._meshing = meshing
Expand All @@ -59,3 +55,11 @@ def task(self, name):

def __getattr__(self, attr):
return getattr(self._workflow, attr)

def __dir__(self):
return sorted(
set(list(self.__dict__.keys()) + dir(type(self)) + dir(self._workflow))
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

similar logic to the above

)

def __call__(self):
return self._workflow()
2 changes: 1 addition & 1 deletion src/ansys/fluent/core/services/datamodel_se.py
Original file line number Diff line number Diff line change
Expand Up @@ -583,8 +583,8 @@ def help(self) -> None:
print(help_string)

def _create_command_arguments(self):
# pending the proto changes
pass
# pending the proto changes
"""
request = DataModelProtoModule.CreateCommandArgumentsRequest()
request.rules = self.rules
Expand Down
18 changes: 18 additions & 0 deletions src/ansys/fluent/core/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,15 @@ def __exit__(self, exc_type: Any, exc_val: Any, exc_tb: Any):
def __getattr__(self, attr):
return getattr(self.fluent_connection, attr)

def __dir__(self):
return sorted(
set(
list(self.__dict__.keys())
+ dir(type(self))
+ dir(self.fluent_connection)
)
)


class Session:
"""Instantiates a Fluent connection. This is a deprecated class. This has
Expand Down Expand Up @@ -275,6 +284,15 @@ def __exit__(self, exc_type: Any, exc_val: Any, exc_tb: Any):
def __getattr__(self, attr):
return getattr(self.fluent_connection, attr)

def __dir__(self):
return sorted(
set(
list(self.__dict__.keys())
+ dir(type(self))
+ dir(self.fluent_connection)
)
)

class Solver:
def __init__(
self, tui_service: DatamodelService_TUI, settings_service: SettingsService
Expand Down
22 changes: 21 additions & 1 deletion tests/test_pure_mesh_vs_mesh_workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,21 @@
@pytest.mark.setup
def test_pure_meshing_mode(load_mixing_elbow_pure_meshing):
pure_meshing_session = load_mixing_elbow_pure_meshing
assert pure_meshing_session.workflow.TaskObject["Import Geometry"].Execute()
# check a few dir elements
# n.b. 'field_data', 'field_info' need to
# be eliminated from meshing sessions
session_dir = dir(pure_meshing_session)
for attr in ("field_data", "field_info", "meshing", "workflow"):
assert attr in session_dir
workflow = pure_meshing_session.workflow
workflow_dir = dir(workflow)
for attr in ("TaskObject", "InsertNewTask", "Workflow", "setState"):
assert attr in workflow_dir
import_geometry = workflow.TaskObject["Import Geometry"]
import_geometry_dir = dir(import_geometry)
for attr in ("AddChildToTask", "Arguments", "Execute", "setState"):
assert attr in import_geometry_dir
assert import_geometry.Execute()
with pytest.raises(AttributeError):
pure_meshing_session.switch_to_solver()

Expand All @@ -16,6 +30,12 @@ def test_pure_meshing_mode(load_mixing_elbow_pure_meshing):
@pytest.mark.setup
def test_meshing_mode(load_mixing_elbow_meshing):
meshing_session = load_mixing_elbow_meshing
# check a few dir elements
# n.b. 'field_data', 'field_info' need to
# be eliminated from meshing sessions
session_dir = dir(meshing_session)
for attr in ("field_data", "field_info", "meshing", "workflow"):
assert attr in session_dir
assert meshing_session.workflow.TaskObject["Import Geometry"].Execute()
assert meshing_session.switch_to_solver()

Expand Down
8 changes: 8 additions & 0 deletions tests/test_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,10 @@ def test_create_session_from_launch_fluent_by_passing_ip_and_port(
session = launch_fluent(
start_instance=False, ip=ip, port=port, cleanup_on_exit=False, mode="solver"
)
# check a few dir elements
session_dir = dir(session)
for attr in ("field_data", "field_info", "setup", "solution"):
assert attr in session_dir
assert session.check_health() == HealthCheckService.Status.SERVING.name
server.stop(None)
session.exit()
Expand All @@ -149,6 +153,10 @@ def test_create_session_from_launch_fluent_by_setting_ip_and_port_env_var(
monkeypatch.setenv("PYFLUENT_FLUENT_IP", ip)
monkeypatch.setenv("PYFLUENT_FLUENT_PORT", str(port))
session = launch_fluent(start_instance=False, cleanup_on_exit=False, mode="solver")
# check a few dir elements
session_dir = dir(session)
for attr in ("field_data", "field_info"):
assert attr in session_dir
assert session.check_health() == HealthCheckService.Status.SERVING.name
server.stop(None)
session.exit()
Expand Down