Skip to content

Conversation

@mglubber
Copy link
Contributor

@mglubber mglubber commented Apr 4, 2022

First of all, thanks for putting together a great tool. I'm using on about 4 different projects now.

When I was tracking down some errors I was having with a run, I found that there are 8 different versions of runSubprocess, which made it a bit difficult to determine what was going on. I've combined them into a single function (and context manager). I ran funannotate test on the modified version and everything passed successfully.

The original functions can be replicated as follows:

runSubprocess(cmd, '.', lib.log) -> runSubprocess(cmd, '.', lib.log)
runSubprocess2(cmd, '.', lib.log, output_file) -> runSubprocess(cmd, '.', lib.log, capture_output=output_file)
runSubprocess3(cmd, '.', lib.log) -> runSubprocess(cmd, '.', lib.log, capture_output=False)
runSubprocess4(cmd, '.', lib.log) -> runSubprocess(cmd, '.', lib.log, only_failed=True)
runSubprocess5(cmd, '.', lib.log, input_file, output_file) -> runSubprocess(cmd, '.', lib.log, input=input_file, capture_output=output_file)
runSubprocess6(cmd, '.', lib.log, logfile2) -> runSubprocess(cmd, '.', lib.log, capture_output=logfile2, capture_error="STDOUT")
runSubprocess7 - didn't replicate, found no uses
runSubprocess8(cmd, '.', lib.log, output_file) -> runSubprocess(cmd, '.', lib.log, capture_output=output_file, only_failed=True)

The functions can be replicated as follows:
runSubprocess(cmd, '.', lib.log) -> runSubprocess(cmd, '.', lib.log)
runSubprocess2(cmd, '.', lib.log, output_file) -> runSubprocess(cmd, '.', lib.log, capture_output=output_file)
runSubprocess3(cmd, '.', lib.log) -> runSubprocess(cmd, '.', lib.log, capture_output=False)
runSubprocess4(cmd, '.', lib.log) -> runSubprocess(cmd, '.', lib.log, only_failed=True)
runSubprocess5(cmd, '.', lib.log, input_file, output_file) -> runSubprocess(cmd, '.', lib.log, input=input_file, capture_output=output_file)
runSubprocess6(cmd, '.', lib.log, logfile2) -> runSubprocess(cmd, '.', lib.log, capture_output=logfile2, capture_error="STDOUT")
runSubprocess7 - didn't replicate, found no uses
runSubprocess8(cmd, '.', lib.log, output_file) -> runSubprocess(cmd, '.', lib.log, capture_output=output_file, only_failed=True)

A context manager for the subprocess in/out/error was created to allow
proper closing if input/output files are used
@nextgenusfs
Copy link
Owner

Wow lots of work here -- yes this is something that was sloppy in the code. Let me pull this branch and run some more tests, but code looks good.

@nextgenusfs
Copy link
Owner

fantastic all my local tests passed, thanks @mglubber

@nextgenusfs nextgenusfs merged commit 32d85a7 into nextgenusfs:master Apr 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants