|
11 | 11 | from capsul.api import Pipeline, PipelineNode
|
12 | 12 | from capsul.pipeline import pipeline_workflow
|
13 | 13 | from capsul.study_config.study_config import StudyConfig
|
| 14 | +from soma_workflow.configuration import \ |
| 15 | + change_soma_workflow_directory, restore_soma_workflow_directory |
14 | 16 | import tempfile
|
15 | 17 | import shutil
|
| 18 | +import socket |
16 | 19 |
|
17 | 20 |
|
18 | 21 | class DummyProcess(Process):
|
@@ -154,12 +157,22 @@ def pipeline_definition(self):
|
154 | 157 |
|
155 | 158 | class TestPipelineWorkflow(unittest.TestCase):
|
156 | 159 |
|
| 160 | + _swf_dir = None |
| 161 | + |
157 | 162 | def setUp(self):
|
| 163 | + # use a custom temporary soma-workflow dir to avoid concurrent |
| 164 | + # access problems |
| 165 | + if TestPipelineWorkflow._swf_dir is None: |
| 166 | + TestPipelineWorkflow._swf_dir = tempfile.mkdtemp() |
| 167 | + change_soma_workflow_directory(TestPipelineWorkflow._swf_dir, |
| 168 | + socket.gethostname()) |
| 169 | + |
| 170 | + self.tmpdir = tempfile.mkdtemp() |
| 171 | + |
158 | 172 | study_config = StudyConfig() #modules=StudyConfig.default_modules \
|
159 |
| - #+ ['FomConfig']) |
| 173 | + #+ ['FomConfig']) |
160 | 174 | self.pipeline = DummyPipeline()
|
161 | 175 | self.pipeline.set_study_config(study_config)
|
162 |
| - self.tmpdir = tempfile.mkdtemp() |
163 | 176 | self.pipeline.input = osp.join(self.tmpdir, 'file_in.nii')
|
164 | 177 | self.pipeline.output1 = osp.join(self.tmpdir, 'file_out1.nii')
|
165 | 178 | self.pipeline.output2 = osp.join(self.tmpdir, 'file_out2.nii')
|
@@ -189,11 +202,21 @@ def setUp(self):
|
189 | 202 | def tearDown(self):
|
190 | 203 | for exec_id in self.exec_ids:
|
191 | 204 | self.study_config.engine.dispose(exec_id)
|
| 205 | + del self.study_config |
192 | 206 | try:
|
193 | 207 | shutil.rmtree(self.tmpdir)
|
194 | 208 | except Exception:
|
195 | 209 | pass
|
196 | 210 |
|
| 211 | + def tearDownClass(): |
| 212 | + if TestPipelineWorkflow._swf_dir is not None: |
| 213 | + restore_soma_workflow_directory() |
| 214 | + try: |
| 215 | + shutil.rmtree(TestPipelineWorkflow._swf_dir) |
| 216 | + TestPipelineWorkflow._swf_dir = None |
| 217 | + except Exception: |
| 218 | + pass |
| 219 | + |
197 | 220 | def test_requirements(self):
|
198 | 221 | engine = self.study_config.engine
|
199 | 222 | with engine.settings as session:
|
|
0 commit comments