1- #!/usr/bin/env python
21# -*- coding: utf-8 -*-
32# emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: nil -*-
43# vi: set ft=python sts=4 ts=4 sw=4 et:
5- """Defines functionality for pipelined execution of interfaces
6-
7- The `EngineBase` class implements the more general view of a task.
8- """
4+ """Defines functionality for pipelined execution of interfaces."""
95from copy import deepcopy
106import re
117import numpy as np
1612
1713
1814class EngineBase (object ):
19- """Defines common attributes and functions for workflows and nodes."""
15+ """
16+ Defines common attributes and functions for workflows and nodes.
17+
18+ Implements the more general view of a task.
19+ """
2020
2121 def __init__ (self , name = None , base_dir = None ):
22- """ Initialize base parameters of a workflow or node
22+ """
23+ Initialize base parameters of a workflow or node.
2324
2425 Parameters
2526 ----------
@@ -31,15 +32,19 @@ def __init__(self, name=None, base_dir=None):
3132 default=None, which results in the use of mkdtemp
3233
3334 """
35+ self ._name = None
3436 self ._hierarchy = None
3537 self .name = name
3638 self ._id = self .name # for compatibility with node expansion using iterables
3739
3840 self .base_dir = base_dir
41+ """Define the work directory for this instance of workflow element."""
42+
3943 self .config = deepcopy (config ._sections )
4044
4145 @property
4246 def name (self ):
47+ """Set the unique name of this workflow element."""
4348 return self ._name
4449
4550 @name .setter
@@ -50,6 +55,7 @@ def name(self, name):
5055
5156 @property
5257 def fullname (self ):
58+ """Build the full name down the hierarchy."""
5359 if self ._hierarchy :
5460 return "%s.%s" % (self ._hierarchy , self .name )
5561 return self .name
@@ -64,20 +70,22 @@ def outputs(self):
6470
6571 @property
6672 def itername (self ):
67- """Name for expanded iterable"""
73+ """Get the name of the expanded iterable. """
6874 itername = self ._id
6975 if self ._hierarchy :
7076 itername = "%s.%s" % (self ._hierarchy , self ._id )
7177 return itername
7278
7379 def clone (self , name ):
74- """Clone an EngineBase object
80+ """
81+ Clone an EngineBase object.
7582
7683 Parameters
7784 ----------
7885
7986 name : string (mandatory)
8087 A clone of node or workflow must have a new name
88+
8189 """
8290 if name == self .name :
8391 raise ValueError ('Cloning requires a new name, "%s" is ' "in use." % name )
@@ -96,15 +104,20 @@ def _check_inputs(self, parameter):
96104 return hasattr (self .inputs , parameter )
97105
98106 def __str__ (self ):
107+ """Convert to string."""
99108 return self .fullname
100109
101110 def __repr__ (self ):
111+ """Get Python representation."""
102112 return self .itername
103113
104114 def save (self , filename = None ):
115+ """Store this workflow element to a file."""
105116 if filename is None :
106117 filename = "temp.pklz"
107118 savepkl (filename , self )
108119
109- def load (self , filename ):
120+ @staticmethod
121+ def load (filename ):
122+ """Load this workflow element from a file."""
110123 return loadpkl (filename )
0 commit comments