Changeset 1930 for pyutilib.workflow

08/03/10 11:39:29 (6 years ago)

Adding other examples for how to initialize ports.

Adding, which will be used to initialize the values of lstlisting bounds.

7 added
2 edited


  • pyutilib.workflow/trunk/doc/workflow/workflow-doc.tex

    r1929 r1930  
    194 \subsection{Initializing Tasks with Command-Line Options} 
    196 TODO: describe how to define tasks that recognize command-line options 
    198 \subsection{Defining Task Resources} 
     194\subsection{Initializing Port Values} 
     196Task ports are initialized through the execution of a workflow, and through the  
     197explicit specification of port values.  The simplest way to specify port values is to  
     198define them directly.  For example, consider the following variation of the 
     199example in Section~\ref{sec:simple}: 
     203The workflow is constructed as before, but the values of ports \code{x} and \code{y} are  
     204defined explicitly, and the execution of the workflow does not specify these values. 
     206\pwsp also supports the initialization of port values with command-line options. 
     207The goal of this capability is to facilitate the use of PyUtilib in 
     208command-line applications, by allowing command-line options to be used 
     209to directly initialize a workflow. 
     210The following example is a simple extension of the example in Section~\ref{sec:simple}. 
     214Some additional logic is added to the \code{TaskAA} class to specify the 
     215command-line options that are recognized by the \code{parser} object. 
     216Note that this parser mimics the standard \code{options.OptionParser} 
     217facility.  The main difference is that this class can be configured to 
     218not enforce strict parse semantics.  That is, it allows for parsing 
     219of 'invalid' options, which are ignored.  Unfortunately, this leads 
     220to ambiguities that require that all option with values use the 
     221\code{--option=value} syntax. 
     223In this example, the \code{set\_options} method is used to initialize a 
     224workflow with a list of option strings.  This syntax mimics the format of 
     225data provided by \code{sys.argv}.  Again, the execution of the workflow 
     226does not specify these values. 
     228Note that port values specified in these ways are viewed as default values 
     229for the port.  When a port value is computed from input connections, 
     230then the port value will be overriden if the input connections provide 
     231a non-trivial value.  For example, if the port action is \code{store}, 
     232then the value will be overriden if the input connection has a value 
     233other than \code{None}.  Similarly, if the port action is \code{append} 
     234or \code{map}, then the value will be overriden if one or more of the 
     235input connections are not None.   
     237Additionally, port values are redefined by the workflow keyword options. 
     238For example, in the following script we initialize input ports for \code{TaskAA}, which 
     239are then redefined when the workflow is executed: 
     243The output of this script is  
     247which reflects the fact that the value of \code{y} was redefined by the workflow 
     248keyword option. 
     251\section{Defining Task Resources} 
    200253TODO: describe how to constrain the execution of tasks with resources 
Note: See TracChangeset for help on using the changeset viewer.