cytoflowgui.workflow_controller

Controllers for LocalWorkflow and the WorkflowItems it contains – these dynamically create the traitsui.view.View instances for the workflow’s operations and views.

Perhaps the most confusing thing in the entire codebase is the way that these views are created. The difficulty is that a view for a WorkflowItem is polymorphic depending on the IWorkflowOperation that it wraps and the IWorkflowView that is currently active.

Here’s how this works. The “Workflow” pane contains a view of the LocalWorkflow (the model), created by WorkflowController.workflow_traits_view. The editor is a VerticalNotebookEditor, configured to use WorkflowController.handler_factory to create a new WorkflowItemHandler for each WorkflowItem in the LocalWorkflow.

Here’s our opportunity for polymorphism! Because each WorkflowItem has its own WorkflowItemHandler instance, the WorkflowItemHandler.operation_traits_view method can return a traitsui.view.View specifically for that `WorkflowItem`’s operation. The traitsui.view.View it returns contains an InstanceHandlerEditor, which uses WorkflowItemHandler._get_operation_handler to get a handler specifically for the IWorkflowOperation that this WorkflowItem wraps. And this handler, in turn, creates the view specifically for the IWorkflowOperation (and contains the logic for connecting it to the IWorkflowOperation that is its model.)

The logic for the view traits and view parameters panes is similar. Each pane contains a view of LocalWorkflow.selected, the currently-selected WorkflowItem. In turn that WorkflowItem’s handler creates a view for the currently-displayed IWorkflowView (which is in WorkflowItem.current_view). This handler, in turn, creates a view for the IWorkflowView’s traits or plot parameters.

One last non-obvious thing. Many of the operations and views require choosing a value from the Experiment. For example, if an IWorkflowView is plotting a histogram, one of its traits is the channel whose histogram is being plotted. These values – channels, conditions, statistics and numeric statistics, for both the current WorkflowItem.result and the previous WorkflowItem.result – are presented as properties of the WorkflowItemHandler. In turn, the WorkflowItemHandler appears in the view’s context dictionary as context. So, if a view wants to get the previous WorkflowItem’s channels, it can refer to them as context.channels. (Examples of this pattern are scattered throughout the submodules of view_plugins.

class cytoflowgui.workflow_controller.WorkflowItemHandler(*args: Any, **kwargs: Any)[source]

Bases: traitsui.api.Controller

A controller for a WorkflowItem. It dynamically creates views for the IWorkflowOperation and IWorkflowViews that are contained, as well as exposing channels, conditions, statistics and numeric statistics as properties (so they can be accessed by the views.

deletable = <traits.traits.ForwardProperty object>

For the vertical notebook view, is this page deletable?

icon = <traits.traits.ForwardProperty object>

The icon for the vertical notebook view

name = <traits.trait_types.DelegatesTo object>
friendly_id = <traits.trait_types.DelegatesTo object>
op_plugins

alias of traits.trait_types.List

view_plugins

alias of traits.trait_types.List

conditions = <traits.traits.ForwardProperty object>

The conditions in this WorkflowItem.result

conditions_names = <traits.traits.ForwardProperty object>

The names of the conditions in this WorkflowItem.result

previous_conditions = <traits.traits.ForwardProperty object>

The conditions in the previous WorkflowItem.result

previous_conditions_names = <traits.traits.ForwardProperty object>

The names of the conditions in the previous WorkflowItem.result

statistics_names = <traits.traits.ForwardProperty object>

The names of the statistics in this WorkflowItem.result

numeric_statistics_names = <traits.traits.ForwardProperty object>

The names of the numeric statistics in this WorkflowItem.result

previous_statistics_names = <traits.traits.ForwardProperty object>

The names of the statistics in the previous WorkflowItem.result

channels = <traits.traits.ForwardProperty object>

The channels in this WorkflowItem.result

previous_channels = <traits.traits.ForwardProperty object>

The channels in the previous WorkflowItem.result

tree_node = <traits.traits.ForwardProperty object>
operation_traits_view()[source]

Returns the traitsui.view.View of the IWorkflowOperation that this WorkflowItem wraps. The view is actually defined by the operation’s handler’s operation_traits_view attribute.

view_traits_view()[source]

Returns the traitsui.view.View showing the traits of the current IWorkflowView. The view is actually defined by the view’s handler’s view_traits_view attribute.

view_params_view()[source]

Returns the traitsui.view.View showing the plot parameters of the current IWorkflowView. The view is actually defined by the view’s handler’s view_params_view attribute.

view_plot_name_view()[source]

Returns the traitsui.view.View showing the plot names of the current IWorkflowView. The view is actually defined by the view’s handler’s view_plot_name_view attribute.

experiment_view()[source]

Returns a traitsui.view.View of LocalWorkflow.selected, showing some things about the experiment – channels, conditions, statistics, etc.

class cytoflowgui.workflow_controller.WorkflowController(*args: Any, **kwargs: Any)[source]

Bases: traitsui.api.Controller

A controller for a LocalWorkflow. It dynamically creates views for the major panes in the UI: the workflow, the selected view traits, and the selected view parameters. It also contains the logic for adding operations and activating views. Both of which are triggered by the button bars on the sides of their respective panes.

workflow_handlers = <traits.trait_types.Dict object>
op_plugins

alias of traits.trait_types.List

view_plugins

alias of traits.trait_types.List

workflow_traits_view()[source]

Returns a traitsui.view.View of the LocalWorkflow for the Workflow pane. Its editor is a VerticalNotebookEditor. Each item’s instance view is created by WorkflowItemHandler.operation_traits_view.

selected_view_traits_view()[source]

Returns a traitsui.view.View of LocalWorkflow.selected for the View traits pane. The actual view is created by WorkflowItemHandler.view_traits_view.

selected_view_params_view()[source]

Returns a traitsui.view.View of LocalWorkflow.selected for the View parameters pane. The actual view is created by WorkflowItemHandler.view_params_view.

selected_view_plot_name_view()[source]

Returns a traitsui.view.View of LocalWorkflow.selected for the plot names toolbar. The actual view is created by WorkflowItemHandler.view_plot_name_view.

experiment_view()[source]

Returns a traitsui.view.View of LocalWorkflow.selected for the experiment viewer.

handler_factory(wi)[source]

Return an instance of WorkflowItemHandler for a WorkflowItem in LocalWorkflow

add_operation(operation_id)[source]

The logic to add an IWorkflowOperation to LocalWorkflow. Creates a new WorkflowItem, figures out where to add it, inserts it into the model and activates the default view (if present.)

activate_view(view_id)[source]

The logic to activate a view on the selected WorkflowItem. Creates a new instance of the view if necessary and makes it the current view; event handlers on WorkflowItem.current_view take care of everything else.