1
- #!/usr/bin/env python
2
1
# -*- coding: utf-8 -*-
3
2
# emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: nil -*-
4
3
# 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."""
9
5
from copy import deepcopy
10
6
import re
11
7
import numpy as np
16
12
17
13
18
14
class 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
+ """
20
20
21
21
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.
23
24
24
25
Parameters
25
26
----------
@@ -31,15 +32,19 @@ def __init__(self, name=None, base_dir=None):
31
32
default=None, which results in the use of mkdtemp
32
33
33
34
"""
35
+ self ._name = None
34
36
self ._hierarchy = None
35
37
self .name = name
36
38
self ._id = self .name # for compatibility with node expansion using iterables
37
39
38
40
self .base_dir = base_dir
41
+ """Define the work directory for this instance of workflow element."""
42
+
39
43
self .config = deepcopy (config ._sections )
40
44
41
45
@property
42
46
def name (self ):
47
+ """Set the unique name of this workflow element."""
43
48
return self ._name
44
49
45
50
@name .setter
@@ -50,6 +55,7 @@ def name(self, name):
50
55
51
56
@property
52
57
def fullname (self ):
58
+ """Build the full name down the hierarchy."""
53
59
if self ._hierarchy :
54
60
return "%s.%s" % (self ._hierarchy , self .name )
55
61
return self .name
@@ -64,20 +70,22 @@ def outputs(self):
64
70
65
71
@property
66
72
def itername (self ):
67
- """Name for expanded iterable"""
73
+ """Get the name of the expanded iterable. """
68
74
itername = self ._id
69
75
if self ._hierarchy :
70
76
itername = "%s.%s" % (self ._hierarchy , self ._id )
71
77
return itername
72
78
73
79
def clone (self , name ):
74
- """Clone an EngineBase object
80
+ """
81
+ Clone an EngineBase object.
75
82
76
83
Parameters
77
84
----------
78
85
79
86
name : string (mandatory)
80
87
A clone of node or workflow must have a new name
88
+
81
89
"""
82
90
if name == self .name :
83
91
raise ValueError ('Cloning requires a new name, "%s" is ' "in use." % name )
@@ -96,15 +104,20 @@ def _check_inputs(self, parameter):
96
104
return hasattr (self .inputs , parameter )
97
105
98
106
def __str__ (self ):
107
+ """Convert to string."""
99
108
return self .fullname
100
109
101
110
def __repr__ (self ):
111
+ """Get Python representation."""
102
112
return self .itername
103
113
104
114
def save (self , filename = None ):
115
+ """Store this workflow element to a file."""
105
116
if filename is None :
106
117
filename = "temp.pklz"
107
118
savepkl (filename , self )
108
119
109
- def load (self , filename ):
120
+ @staticmethod
121
+ def load (filename ):
122
+ """Load this workflow element from a file."""
110
123
return loadpkl (filename )
0 commit comments