6
6
from ipsframework import ipsutil
7
7
8
8
9
- def catch_and_go (func_to_decorate ):
10
- def new_func (* original_args , ** original_kwargs ):
11
- # Do whatever else you want here
12
- obj = original_args [0 ]
13
- try :
14
- func_to_decorate (* original_args , ** original_kwargs )
15
- except Exception as e :
16
- obj .services .exception ("Exception in call to %s:%s" % (obj .__class__ .__name__ , func_to_decorate .__name__ ))
17
- print (e )
18
- return new_func
19
-
20
-
21
9
class runspaceInitComponent (Component ):
22
10
"""
23
11
Framework component to manage runspace initialization, container file
@@ -34,33 +22,16 @@ def __init__(self, services, config):
34
22
self .simRootDir = services .get_config_param ('SIM_ROOT' )
35
23
self .cwd = self .config ['OS_CWD' ]
36
24
37
- @catch_and_go
38
25
def init (self , timestamp = 0.0 , ** keywords ):
39
26
"""
40
27
Creates base directory, copies IPS and FacetsComposer input files.
41
28
"""
42
29
43
- services = self .services
44
-
45
- try :
46
- os .chdir (self .cwd )
47
- except OSError :
48
- self .services .debug ('Working directory %s does not exist - this is impossibile' ,
49
- self .cwd )
50
- raise
51
-
52
30
if not self .simRootDir .startswith ("/" ):
53
31
self .simRootDir = os .path .join (self .cwd , self .simRootDir )
54
32
55
- # try making the simulation root directory
56
- try :
57
- os .makedirs (self .simRootDir , exist_ok = True )
58
- except OSError as oserr :
59
- self .services .exception ('Error creating directory %s : %s' ,
60
- self .simRootDir , oserr .strerror )
61
-
62
- config_files = services .fwk .config_file_list
63
- platform_file = services .fwk .platform_file_name
33
+ config_files = self .services .fwk .config_file_list
34
+ platform_file = self .services .fwk .platform_file_name
64
35
65
36
# Determine where the file is...if there's not an absolute path specified,
66
37
# assume that it was in the directory that the IPS was launched from.
@@ -79,29 +50,19 @@ def init(self, timestamp=0.0, **keywords):
79
50
ipsutil .copyFiles (conf_file_loc , config_files , self .simRootDir )
80
51
ipsutil .copyFiles (plat_file_loc , platform_file , self .simRootDir )
81
52
82
- @catch_and_go
83
53
def step (self , timestamp = 0.0 , ** keywords ):
84
54
"""
85
55
Copies individual subcomponent input files into working subdirectories.
86
56
"""
87
57
88
- services = self .services
89
-
90
- # sim_comps = services.fwk.config_manager.get_component_map()
91
- sim_comps = services .fwk .config_manager .get_all_simulation_components_map ()
92
- registry = services .fwk .comp_registry
58
+ sim_comps = self .services .fwk .config_manager .get_all_simulation_components_map ()
59
+ sim_roots = self .services .fwk .config_manager .get_all_simulation_sim_root ()
60
+ registry = self .services .fwk .comp_registry
93
61
94
62
simulation_setup = os .path .join (self .simRootDir , 'simulation_setup' )
95
63
96
- # make the simulation_setup directory for scripts
97
- try :
98
- os .makedirs (simulation_setup , exist_ok = True )
99
- except OSError as oserr :
100
- self .services .exception ('Error creating directory %s : %s' ,
101
- simulation_setup , oserr .strerror )
102
-
103
64
# for each simulation component
104
- for comp_list in sim_comps .values ():
65
+ for name , comp_list in sim_comps .items ():
105
66
# for each component_id in the list of components
106
67
for comp_id in comp_list :
107
68
# build the work directory name
@@ -111,7 +72,7 @@ def step(self, timestamp=0.0, **keywords):
111
72
str (comp_id .get_seq_num ())])
112
73
113
74
# compose the workdir name
114
- workdir = os .path .join (self . simRootDir , 'work' , full_comp_id )
75
+ workdir = os .path .join (sim_roots [ name ] , 'work' , full_comp_id )
115
76
116
77
# make the working directory
117
78
try :
@@ -130,21 +91,6 @@ def step(self, timestamp=0.0, **keywords):
130
91
print ('Error copying input files for initialization' )
131
92
raise
132
93
133
- # This is a bit tricky because we want to look either in the same
134
- # place as the input files or the data_tree root
135
- if 'DATA_FILES' in comp_conf :
136
- filesCopied = False
137
- if 'DATA_TREE_ROOT' in comp_conf :
138
- dtrdir = os .path .abspath (comp_conf ['DATA_TREE_ROOT' ])
139
- if os .path .exists (os .path .join (dtrdir , comp_conf ['DATA_FILES' ][0 ])):
140
- ipsutil .copyFiles (dtrdir , os .path .basename (comp_conf ['DATA_FILES' ]),
141
- workdir )
142
- filesCopied = True
143
- if not filesCopied :
144
- ipsutil .copyFiles (os .path .abspath (comp_conf ['INPUT_DIR' ]),
145
- os .path .basename (comp_conf ['DATA_FILES' ]),
146
- workdir )
147
-
148
94
# copy the component's script to the simulation_setup directory
149
95
if comp_conf ['SCRIPT' ]:
150
96
if os .path .isabs (comp_conf ['SCRIPT' ]):
@@ -155,14 +101,3 @@ def step(self, timestamp=0.0, **keywords):
155
101
ipsutil .copyFiles (comp_conf ['BIN_DIR' ],
156
102
[os .path .basename (comp_conf ['SCRIPT' ])],
157
103
simulation_setup )
158
-
159
- # get the working directory from the runspaceInitComponent
160
- workdir = services .get_working_dir ()
161
-
162
- # create the working directory for this component
163
- try :
164
- os .makedirs (workdir , exist_ok = True )
165
- except OSError as oserr :
166
- self .services .exception ('Error creating directory %s : %s' ,
167
- workdir , oserr .strerror )
168
- raise
0 commit comments