Skip to content

Commit

Permalink
Raise an exception instead of exiting with signal 1 when the number o…
Browse files Browse the repository at this point in the history
…f ADIRC NonDA cycles is insufficient
  • Loading branch information
shinbunya committed Jul 12, 2024
1 parent 55ec72f commit ab789b5
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions adda/adda.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def main(args):
urls=glob.glob(tdir, recursive = True)
if not urls:
utilities.log.info(f'Initial url list is empty in {tdir}. Exiting ADDA. Surface will be all zeros.')
sys.exit(1)
raise Exception('Insufficient number of cycles')
if args.current_time is not None:
urls2=[]
for u in urls:
Expand All @@ -107,7 +107,7 @@ def main(args):
urls=glob.glob(tdir, recursive = True)
if not urls:
utilities.log.info(f'Initial url list is empty in {tdir}. Exiting ADDA. Surface will be all zeros.')
sys.exit(1)
raise Exception('Insufficient number of cycles')
if args.current_time is not None:
urls2=[]
for u in urls:
Expand All @@ -120,21 +120,21 @@ def main(args):

if not urls:
utilities.log.info('Url list is empty before popping first item. Exiting ADDA. Surface will be all zeros.')
sys.exit(1)
raise Exception('Insufficient number of cycles')

if not args.dont_delete_first_nowcast:
urls.pop(0)
if not urls:
utilities.log.info('Url list is empty after popping first item. Exiting ADDA. Surface will be all zeros.')
sys.exit(1)
raise Exception('Insufficient number of cycles')

#remove leading urls if needed
if len(urls) > maxCycles:
urls=urls[-maxCycles:]

if len(urls) < minCycles:
utilities.log.info(f'Not enough cycles for analysis {len(urls),minCycles}. Exiting ADDA. Surface will be all zeros.')
sys.exit(1)
raise Exception('Insufficient number of cycles')

utilities.log.info(f'URL list length = {len(urls)}')
utilities.log.info('URL list after filtering is:\n{}'.format('\n'.join(urls)))
Expand All @@ -145,7 +145,7 @@ def main(args):
# assume "input_url" is a file of urls.
if not os.path.exists(args.input_url):
utilities.log.error(f'Input_url file {args.input_url} not found.')
sys.exit(1)
raise Exception('Input_url file not found')
with open(args.input_url) as f:
urls = f.read().splitlines()
utilities.log.info('URL list is:\n{}'.format('\n'.join(urls)))
Expand Down

0 comments on commit ab789b5

Please sign in to comment.