Skip to content

Commit

Permalink
Merge pull request #15 from brainvisa/simplest
Browse files Browse the repository at this point in the history
Simplified API
  • Loading branch information
sapetnioc authored Jan 28, 2022
2 parents 18009f2 + 9db0140 commit 594fb1a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
7 changes: 5 additions & 2 deletions bv_use_cases/simplest/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import os
import time

from soma.controller import path, directory, List, field
from capsul.api import Process

Expand All @@ -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(
Expand All @@ -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)
11 changes: 4 additions & 7 deletions bv_use_cases/simplest/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.

0 comments on commit 594fb1a

Please sign in to comment.