refactor _populate_first_tasks_python_name_command_id_map
Opened this issue · 2 comments
seanpearsonuk commented
## 1. The function name is difficult to interpret.
def _populate_first_tasks_python_name_command_id_map(self):
if not self._initial_task_python_names_map:
## 2. Iterating over dir instead of the relevant list of names.
## dir() is for users.
for command in dir(self._command_source):
## 3. Require more systematic way to filter out unwanted names
## than mentioning SwitchToSolution explicitly.
if command in ["SwitchToSolution", "set_state"]:
continue
command_obj = getattr(self._command_source, command)
if isinstance(command_obj, PyCommand):
command_obj_instance = command_obj.create_instance()
if not command_obj_instance.get_attr("requiredInputs"):
## 4. Going forward, this call is happening too late. The static info
## shall already indicate the API names, and if this code picks up the names
## differently then we will have already failed by this point.
help_str = command_obj_instance.get_attr(
"APIName"
) or command_obj_instance.get_attr("helpString")
if help_str:
self._initial_task_python_names_map[help_str] = command
del command_obj_instance
mkundu1 commented
These classes should also distinguish between getters and setters. The internal state should be updated by setters.
seanpearsonuk commented
@mkundu1 Thanks. N.b. I was also updating the description in the meantime.