scif icon indicating copy to clipboard operation
scif copied to clipboard

Exit Code from scif run

Open dmachi opened this issue 1 year ago • 12 comments

When launching an app with run, a zero exit code is always returned. As far as I can tell, the code will only return the app's exit code if _exec is called with interactive=True and exit=True. The run() command has interactive explicitly set to False on https://github.com/vsoch/scif/blob/master/scif/main/commands.py#L166. Is there anyway to force that exit code to return properly?

dmachi avatar Jan 23 '24 22:01 dmachi

If you want to open a PR to expose that variable, that would be welcome. The expected use case is that if you are wanting interactive, you'd be using exec.

vsoch avatar Jan 23 '24 22:01 vsoch

Thank you for the prompt reply. Is there some reason why one would NOT want run() to return the exit code of the thing it is running? I'm curious because apptainer does return that exit code from the app run. It makes it difficult to include this in other scripts without an exit code. I am happy to create patch and PR for this, but am wondering if you would accept it if run just always exited with whatever exit code the command exited with?

dmachi avatar Jan 23 '24 22:01 dmachi

Honestly this project is so old I don't remember the details. I agree with you it makes sense to return it, and I'm happy to accept a PR.

vsoch avatar Jan 23 '24 22:01 vsoch

LOL. We were wondering if it was still alive :). We'll get a patch created if we don't find a lazier alternative solution.

dmachi avatar Jan 23 '24 22:01 dmachi

I maintain hundreds of projects, so I will work on them on an as-needs basis. I'm glad you are using SCIF!

vsoch avatar Jan 23 '24 22:01 vsoch

I've created PR #68 to address this.

dmachi avatar Jan 24 '24 14:01 dmachi

Closed with #68

vsoch avatar Jan 24 '24 19:01 vsoch

@dmachi we broke upstream tests, so I had to revert and we will need to address this in another way.

vsoch avatar Jan 25 '24 13:01 vsoch

@vsoch Can you be more specific on what upstream tests are failing so I can figure out how to fix this. Am I able to see those tests and results? I thought my changes should only really add that exit code after the output of the job (which it was already doing).

dmachi avatar Jan 25 '24 13:01 dmachi

See #70

vsoch avatar Jan 25 '24 13:01 vsoch

@dmachi perhaps we can try https://stackoverflow.com/questions/70692908/how-to-get-the-exit-code-for-os-popencommand ?

vsoch avatar Jan 25 '24 14:01 vsoch

and ping @dtrudg - let's make sure we add a test this time to not break things.

vsoch avatar Jan 25 '24 14:01 vsoch