enable zproc.main to be called from other scripts #2391
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR provides two changes to
desispec.scripts.zproc.main
to enable it to be called from other scripts:sys.exit
directly. Previously even upon success, it would callsys.exit(0)
instead of returning to the calling function. The command line scriptbin/desi_zproc
already includessys.exit(zproc.main())
so that did not need to be changed.args
orsys.argv
. This is needed for the--batch
option, which previously assumed the command line was coming only fromsys.argv
which isn't the case if a wrapper script is callingzproc.main
with a list of strings.zproc.main
with anargs.Namespace
object, this will still incorrectly generate the command line fromsys.argv
. That's the same as what the current code does, i.e. this PR doesn't solve all cases, but it at least provides a workaround via supporting passing a list of strings to main.This was motivated by Loa testing wanting to batch submit an individual tile/nights without having to call the command line script and re-import packages etc every time (slow). An alternative would have been to use
desi_tile_redshifts
anddesi_healpix_redshifts
instead, but I was mostly done with this update before realizing that from talking with @akremin, and I think these are useful functionality updates anyway.