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

refactor _populate_first_tasks_python_name_command_id_map #3432

Open
seanpearsonuk opened this issue Oct 28, 2024 · 2 comments
Open

refactor _populate_first_tasks_python_name_command_id_map #3432

seanpearsonuk opened this issue Oct 28, 2024 · 2 comments

Comments

@seanpearsonuk
Copy link
Collaborator

seanpearsonuk commented Oct 28, 2024

    ## 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
@seanpearsonuk seanpearsonuk changed the title rwefactor _populate_first_tasks_python_name_command_id_map refactor _populate_first_tasks_python_name_command_id_map Oct 28, 2024
@mkundu1
Copy link
Contributor

mkundu1 commented Oct 28, 2024

These classes should also distinguish between getters and setters. The internal state should be updated by setters.

@seanpearsonuk
Copy link
Collaborator Author

@mkundu1 Thanks. N.b. I was also updating the description in the meantime.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants