Skip to content

Commit

Permalink
Merge pull request #2391 from desihub/zproc_workflow
Browse files Browse the repository at this point in the history
enable zproc.main to be called from other scripts
  • Loading branch information
akremin authored Oct 11, 2024
2 parents bd7fd13 + d1a727c commit fa2a2d8
Showing 1 changed file with 19 additions and 6 deletions.
25 changes: 19 additions & 6 deletions py/desispec/scripts/zproc.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,22 @@ def parse(options=None):


def main(args=None, comm=None):
"""
Run spectral grouping, coaddition, redshifts, and afterburners
Options:
args (argparse.Namespace or list of str): options to use instead of sys.argv
comm: mpi4py communicator to use for parallelism
Returns: integer error code (0=good)
"""
#- save original command line before parsing it
#- in case we need it for creating a batch script
if args is None or isinstance(args, argparse.Namespace):
cmdline = sys.argv.copy()
else:
cmdline = ['desi_zproc',] + list(args)

if not isinstance(args, argparse.Namespace):
args = parse(options=args)

Expand Down Expand Up @@ -299,7 +315,6 @@ def main(args=None, comm=None):
## Create and submit a batch job if requested
if rank == 0:
## create the batch script
cmdline = list(sys.argv).copy()
scriptfile = create_desi_zproc_batch_script(group=groupname,
subgroup=subgroup,
tileid=tileid,
Expand Down Expand Up @@ -327,7 +342,8 @@ def main(args=None, comm=None):
## All ranks need to exit if submitted batch
if comm is not None:
err = comm.bcast(err, root=0)
sys.exit(err)

return int(err)

exposure_table = None
hpixexp = None
Expand Down Expand Up @@ -869,10 +885,7 @@ def main(args=None, comm=None):
else:
log.info(goodbye)

if error_count > 0:
sys.exit(int(error_count))
else:
return 0
return int(error_count)


def distribute_ranks_to_blocks(nblocks, rank=None, size=None, comm=None,
Expand Down

0 comments on commit fa2a2d8

Please sign in to comment.