def test_notify(self):
        self.flag = False

        def observer():
            self.flag = not self.flag

        workflow = Workflow()
        workflow.attach(observer)
        workflow.notify()
        assert self.flag is True
Exemple #2
0
    def __init__(self, workflow: Workflow):
        super(WorkflowEditor, self).__init__()
        self.setOrientation(Qt.Vertical)

        self.processeditor = WorkflowProcessEditor()
        self.workflowview = LinearWorkflowView(WorkflowModel(workflow))

        self.addWidget(self.processeditor)
        self.addWidget(WorkflowWidget(self.workflowview))

        self.workflowview.sigShowParameter.connect(lambda parameter: self.setParameters(parameter))

        workflow.attach(self.sigWorkflowChanged.emit)
    def __init__(self,
                 workflow: Workflow,
                 operation_filter: Callable[[OperationPlugin], bool] = None,
                 kwargs_callable: Callable[[], dict] = None,
                 execute_iterative: bool = False,
                 **kwargs):
        """
        A Workflow editor that shows each operation in insertion order. This is useful in simplistic workflows, typically
        when data passes from through a linear sequence. This order may not represent execution order when
        a workflow is programmatically composed, or when graph-based editing is supported in the future.

        Parameters
        ----------
        workflow : Workflow
            A workflow instance; may be initially empty.
        operation_filter: Callable[[OperationPlugin], bool]
            A callable that can be used to filter which operations to show in the "Add Operation" menu
        kwargs_callable: Callable[[], dict]
            A callable that gets called when auto-run is triggered. This callable is expected to generate a dict of
            kwargs that will be passed into the workflow as inputs.
        execute_iterative: bool
            Determines if the attached workflow will be executed with `.execute` or `.execute_all`. When `.execute_all`
            is used, all input args get zipped, and the workflow is executed over each arg tuple.

        """
        super(WorkflowEditor, self).__init__()
        self.workflow = workflow
        self.kwargs = kwargs
        self.kwargs_callable = kwargs_callable
        self.execute_iterative = execute_iterative
        self.setOrientation(Qt.Vertical)

        self.operationeditor = WorkflowOperationEditor()
        self.workflowview = LinearWorkflowView(WorkflowModel(workflow))

        self.addWidget(self.operationeditor)
        workflow_widget = WorkflowWidget(self.workflowview,
                                         operation_filter=operation_filter)
        self.addWidget(workflow_widget)
        workflow_widget.sigRunWorkflow.connect(self.sigRunWorkflow.emit)
        workflow_widget.sigRunWorkflow.connect(self.run_workflow)
        # Should this work internally? How would the start operations get their inputs?
        # Would the ExamplePlugin need to explicitly set the parameter value (even for hidden image)?
        # It would be nice to just have this work easily... (to ExamplePlugin's perspective)
        # workflow_widget.sigRunWorkflow.connect(self.run_workflow)
        # TODO make work for autorun...
        # OR is this the outside class's respsonsibility (see SAXSGUIPlugin.maskeditor)

        self.workflowview.sigShowParameter.connect(self.setParameters)

        workflow.attach(self.sigWorkflowChanged.emit)
    def __init__(self, workflow: Workflow):
        super(WorkflowEditor, self).__init__()
        self.workflow = workflow
        self.setOrientation(Qt.Vertical)

        self.operationeditor = WorkflowOperationEditor()
        self.workflowview = LinearWorkflowView(WorkflowModel(workflow))

        self.addWidget(self.operationeditor)
        self.addWidget(WorkflowWidget(self.workflowview))

        self.workflowview.sigShowParameter.connect(self.setParameters)

        workflow.attach(self.sigWorkflowChanged.emit)
    def __init__(self, workflow: Workflow, **kwargs):
        super(WorkflowEditor, self).__init__()
        self.workflow = workflow
        self.kwargs = kwargs
        self.setOrientation(Qt.Vertical)

        self.operationeditor = WorkflowOperationEditor()
        self.workflowview = LinearWorkflowView(WorkflowModel(workflow))

        self.addWidget(self.operationeditor)
        workflow_widget = WorkflowWidget(self.workflowview)
        self.addWidget(workflow_widget)
        workflow_widget.sigRunWorkflow.connect(self.sigRunWorkflow.emit)
        # Should this work internally? How would the start operations get their inputs?
        # Would the ExamplePlugin need to explicitly set the parameter value (even for hidden image)?
        # It would be nice to just have this work easily... (to ExamplePlugin's perspective)
        # workflow_widget.sigRunWorkflow.connect(self.run_workflow)
        # TODO make work for autorun...
        # OR is this the outside class's respsonsibility (see SAXSGUIPlugin.maskeditor)

        self.workflowview.sigShowParameter.connect(self.setParameters)

        workflow.attach(self.sigWorkflowChanged.emit)