Changeset 1930 for pyutilib.workflow


Ignore:
Timestamp:
08/03/10 11:39:29 (4 years ago)
Author:
wehart
Message:

Adding other examples for how to initialize ports.

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

Location:
pyutilib.workflow/trunk/doc/workflow
Files:
7 added
2 edited

Legend:

Unmodified
Added
Removed
  • pyutilib.workflow/trunk/doc/workflow/workflow-doc.tex

    r1929 r1930  
    192192 
    193193 
    194 \subsection{Initializing Tasks with Command-Line Options} 
    195  
    196 TODO: describe how to define tasks that recognize command-line options 
    197  
    198 \subsection{Defining Task Resources} 
     194\subsection{Initializing Port Values} 
     195 
     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}: 
     200\begin{quotation} 
     201\lstinputlisting[firstline=16,lastline=21]{examples/example1a.py} 
     202\end{quotation} 
     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. 
     205 
     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}. 
     211\begin{quotation} 
     212\lstinputlisting[firstline=3,lastline=22]{examples/example1b.py} 
     213\end{quotation} 
     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. 
     222 
     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. 
     227 
     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.   
     236 
     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: 
     240\begin{quotation} 
     241\lstinputlisting[firstline=16,lastline=22]{examples/example1c.py} 
     242\end{quotation} 
     243The output of this script is  
     244\begin{quotation} 
     245\lstinputlisting{examples/example1c.txt} 
     246\end{quotation} 
     247which reflects the fact that the value of \code{y} was redefined by the workflow 
     248keyword option. 
     249 
     250 
     251\section{Defining Task Resources} 
    199252 
    200253TODO: describe how to constrain the execution of tasks with resources 
Note: See TracChangeset for help on using the changeset viewer.