Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: dir() over ArgumentWrapper. #3321

Merged
merged 10 commits into from
Oct 3, 2024
21 changes: 15 additions & 6 deletions src/ansys/fluent/core/workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -902,10 +902,16 @@ def __setattr__(self, attr, value):
self.set_state({attr: value})

def __dir__(self):
arg_list = []
for arg in self():
arg_list.append(camel_to_snake_case(arg))
return sorted(set(list(self.__dict__.keys()) + dir(type(self)) + arg_list))
arg_state = self.get_state()
arg_list = (
[arg for arg in arg_state if isinstance(arg_state, dict)]
if self() is not None
prmukherj marked this conversation as resolved.
Show resolved Hide resolved
prmukherj marked this conversation as resolved.
Show resolved Hide resolved
else []
)
dir_arg = [item for item in dir(self._arg) if item.islower()]
return sorted(
set(list(self.__dict__.keys()) + dir(type(self)) + arg_list + dir_arg)
)


class CommandTask(BaseTask):
Expand Down Expand Up @@ -1253,8 +1259,11 @@ def _makeTask(command_source, name: str) -> BaseTask:
"Conditional": ConditionalTask,
}
task_type = task.TaskType()
if task_type is None and command_source._compound_child:
kind = CompoundChild
if task_type is None:
if command_source._compound_child:
kind = CompoundChild
else:
kind = SimpleTask
prmukherj marked this conversation as resolved.
Show resolved Hide resolved
else:
kind = kinds[task_type]
if not kind:
Expand Down
3 changes: 2 additions & 1 deletion tests/test_new_meshing_workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -1612,14 +1612,15 @@ def test_mark_as_updated(new_meshing_session):
)


@pytest.mark.fluent_version(">=23.2")
@pytest.mark.fluent_version(">=24.1")
@pytest.mark.codegen_required
def test_accessors_for_argument_sub_items(new_meshing_session):
meshing = new_meshing_session
watertight = meshing.watertight()

import_geom = watertight.import_geometry
assert import_geom.length_unit.default_value() == "mm"
assert "allowed_values" in dir(import_geom.length_unit)
assert import_geom.arguments.length_unit.allowed_values() == [
"m",
"cm",
Expand Down