cytoflowgui.workflow.workflow

The main model for the GUI.

At its core, the model is a list of WorkflowItem instances. A WorkflowItem wraps an operation, its completion status, the result of applying it to the previous WorkflowItem’s result, and IView’s on that result. The Workflow also maintains a “current” or selected WorkflowItem.

The left panel of the GUI is a View on this object (viewing the list of WorkflowItem instances), and the right panel of the GUI is a View of the selected WorkflowItem’s current view.

So far, so simple. However, in a single-threaded GUI application, the UI freezes when something processor-intensive is happening. Adding another thread doesn’t help matters because of the CPython global interpreter lock; while Python is otherwise computing, the GUI doesn’t update. To solve this, the Workflow maintains a copy of itself in a separate process. The LocalWorkflow is the one that is viewed by the GUI; the RemoteWorkflow is the one that actually loads the data and does the processing. Thus the GUI remains responsive. Changed attributes in either Workflow are noticed by a set of Traits handlers, which send those changes to the other process.

This process is also where the plotting happens. For an explanation of how the plots are ferried back to the GUI, see the module docstring for cytoflowgui.matplotlib_backend_local and cytoflowgui.matplotlib_backend_remote

class cytoflowgui.workflow.workflow.Msg[source]

Bases: object

Messages passed between the local and remote workflows

NEW_WORKFLOW = 'NEW_WORKFLOW'
ADD_ITEMS = 'ADD_ITEMS'
REMOVE_ITEMS = 'REMOVE_ITEMS'
SELECT = 'SELECT'
UPDATE_OP = 'UPDATE_OP'
UPDATE_VIEW = 'UPDATE_VIEW'
CHANGE_CURRENT_VIEW = 'CHANGE_CURRENT_VIEW'
CHANGE_CURRENT_PLOT = 'CHANGE_CURRENT_PLOT'
UPDATE_WI = 'UPDATE_WI'
ESTIMATE = 'ESTIMATE'
APPLY_CALLED = 'APPLY_CALLED'
PLOT_CALLED = 'PLOT_CALLED'
EVAL = 'EVAL'
EXEC = 'EXEC'
RUN_ALL = 'RUN_ALL'
SHUTDOWN = 'SHUTDOWN'
class cytoflowgui.workflow.workflow.UniquePriorityQueue(maxsize=0)[source]

Bases: queue.PriorityQueue

A PriorityQueue that only allows one copy of each item. http://stackoverflow.com/questions/5997189/how-can-i-make-a-unique-value-priority-queue-in-python

cytoflowgui.workflow.workflow.filter_unpicklable(obj)[source]

Recursively filter unpicklable items from lists and dictionaries

class cytoflowgui.workflow.workflow.LocalWorkflow(remote_workflow_connection, **kwargs)[source]

Bases: traits.has_traits.HasStrictTraits

The workflow that is maintained in the “local” process – ie, the same one that showing a GUI.

workflow

The list of WorkflowItems

selected

The currently-selected WorkflowItem

modified

Has this workflow been modified since it was loaded?

message_q

The queue.Queue of messages to send to the remote process

recv_thread

The threading.Thread that receives messages from the remote process

send_thread

The threading.Thread that sends messages to the remote process

recv_main(child_conn)[source]

The method that runs in recv_thread to receive messages from the remote process.

send_main(child_conn)[source]

The method that runs in send_thread to send messages from message_q to the remote process

run_all()[source]

Send the RUN_ALL message to the remote process

remote_eval(expr)[source]

Evaluate an expression in the remote process and return the result

remote_exec(expr)[source]

Execute an expression in the remote process and wait until it completes

wi_sync(wi, variable, value, timeout=30)[source]

Set WorkflowItem.status on the remote workflow, then wait for it to propogate here.

wi_waitfor(wi, variable, value, timeout=30)[source]

Waits a configurable amount of time for wi’s status to change to status

shutdown_remote_process(remote_process)[source]

Shut down the remote process

class cytoflowgui.workflow.workflow.RemoteWorkflow[source]

Bases: traits.has_traits.HasStrictTraits

The workflow that is maintained in the “remote” process – ie, the one that actually does the processing.

workflow

The list of WorkflowItem’s

selected

The currently-selected WorkflowItem

last_view_plotted

The last IWorkflowView that was plotted

send_thread

The threading.Thread that sends messages to the local process

recv_thread

The threading.Thread that receives messages from the local process

message_q

The queue.Queue of messages to send to the local process

matplotlib_events

threading.Event to synchronize matplotlib plotting across process boundaries

plot_lock

threading.Lock to synchronize matplotlib plotting across process boundaries

run(parent_workflow_conn, parent_mpl_conn=None)[source]

The method that runs the main loop of the remote process

recv_main(parent_conn)[source]

The method that runs in the recv_thread to receive messages from the local process.

send_main(parent_conn)[source]

The method that runs in send_thread to send messages to the local process.

shutdown()[source]

Shut down the remote process