populse / capsul

Collaborative Analysis Platform : Simple, Unifying, Lean
Other
7 stars 14 forks source link

capsul.run never reports failures #215

Closed denisri closed 2 years ago

denisri commented 2 years ago

If we try:

$ python3 -m capsul.run rototobaba && echo OK || echo FAILED
Traceback (most recent call last):
  File "/usr/lib/python3.10/runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/lib/python3.10/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "/casa/host/src/capsul/capsul/run.py", line 29, in <module>
    with open(execution_file) as f:
FileNotFoundError: [Errno 2] No such file or directory: 'rototobaba'
OK

Thus execution (obviously) does not succeed, but the return code of the command is still 0, so we don't catch execution failures. Is it because of the fork() in capsul.run ?

denisri commented 2 years ago

Yes, it is because of the fork(): detaching the process from its parent probably also forbids the parent to get a correct termination code from its child. If we remove the fork() we get the correct status.

sapetnioc commented 2 years ago

The fork is here only to really detach the process and allow to use Popen.wait on client side. Otherwise there are warning messages in the tests. But this is a draft local implementation that uses a single subprocess to execute a process. My idea was to replace it by a Soma workflow with each nodes calling python -m capsul.run. But I did not worked a lot on it.

sapetnioc commented 2 years ago

capsul.run had been rewritten.