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

Reinstantiating workflows for every change #34

Open
Tara-Lakshmipathy opened this issue Dec 16, 2024 · 1 comment
Open

Reinstantiating workflows for every change #34

Tara-Lakshmipathy opened this issue Dec 16, 2024 · 1 comment

Comments

@Tara-Lakshmipathy
Copy link
Contributor

In the current implementation, the workflow is reinstantiated every time there is a change in the GUI. The associated code snippet can be found in reactflow.py:

def get_workflow(self):
        workflow_label = self.wf.label

        wf = Workflow(workflow_label)
        dict_nodes = json.loads(self.gui.nodes)
        for dict_node in dict_nodes:
            node = dict_to_node(dict_node)
            wf.add_child(node)
            # wf.add_child(node(label=node.label))

        nodes = wf._children
        dict_edges = json.loads(self.gui.edges)
        for dict_edge in dict_edges:
            dict_to_edge(dict_edge, nodes)

        return wf

Besides caching becoming non-functional, wf.save also does not work. This is probably due to the reinstantiation trying to add children with the same label to an already saved workflow. The GUI itself simply becomes unresponsive at this point.

While the reinstantiation is a clean way of capturing changes from the GUI side of things, I think it is leading to too many loses in functionality. It would perhaps be better to break down the get_workflow function so that changes are handled without reinstantiating the workflow.

Thoughts @pyiron/gui? (just testing out the teams functionality here, please ignore if you don't want to contribute to the issue)

@Tara-Lakshmipathy
Copy link
Contributor Author

Tara-Lakshmipathy commented Dec 17, 2024

For now, I found a workaround for saving and loading by adding a suffix to the workflow label:

if ... :
     ......
     ......

elif global_command == 'load':
     if self.accordion_widget is not None:
          self.accordion_widget.selected_index = 1
     temp_label = self.wf.label
     self.wf.label = temp_label + "-save"
     try:
          self.wf.load()
          self.wf.label = temp_label
          self.update()
          print("Successfully loaded from " + temp_label + "-save")
     except:
          self.wf.label = temp_label
          self.update()
          print("Save file " + temp_label + "-save" + " not found!")

elif global_command == 'save':
     if self.accordion_widget is not None:
          self.accordion_widget.selected_index = 1
     temp_label = self.wf.label
     self.wf.label = temp_label + "-save"
     self.wf.save()
     self.wf.label = temp_label
     print("Successfully saved in " + temp_label + "-save")

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

1 participant