diff --git a/bv_use_cases/simplest/__init__.py b/bv_use_cases/simplest/__init__.py index 4f57670..a113236 100644 --- a/bv_use_cases/simplest/__init__.py +++ b/bv_use_cases/simplest/__init__.py @@ -1,4 +1,6 @@ import os +import time + from soma.controller import path, directory, List, field from capsul.api import Process @@ -7,10 +9,10 @@ class ListDirectory(Process): Return a list containing the names of the files in the directory. ''' path : directory(doc='directory to list') - result : field(List[path()], doc='the output', output=True) + result : field(type_=List[path()], doc='the output', output=True) def execute(self, context): - self.result = os.listdir(self.path) + self.result = list_directory(self.path) def list_directory( @@ -19,4 +21,5 @@ def list_directory( ''' Return a list containing the names of the files in the directory. ''' + time.sleep(3) return os.listdir(path) diff --git a/bv_use_cases/simplest/__main__.py b/bv_use_cases/simplest/__main__.py index 641ec31..7b3d479 100644 --- a/bv_use_cases/simplest/__main__.py +++ b/bv_use_cases/simplest/__main__.py @@ -22,14 +22,11 @@ # to separate this two steps; for instance if one only wants to see the engine # configuration. Therefore, a "with" statement must be used to define portion # of code requiring a valid connection to the CapsulEngine. -with capsul.engine() as capsul_engine: - # Here we are connected to the Capsul engine and can send command to it - execution_id = capsul_engine.start(executable) - capsul_engine.wait(execution_id) - final_status = capsul_engine.status(execution_id) - pprint(final_status) - capsul_engine.raise_for_status(final_status) +capsul_engine = capsul.engine() +with capsul_engine.connect(): + capsul_engine.run(executable) + print(executable.result) # Here the connection to the CapsulEngine is closed. The execution_id may not be # valid for another connection to the same engine. This is engine implementation # dependent. \ No newline at end of file