Skip to content

Commit

Permalink
Merge pull request #70 from ghrcdaac/mlh0079-allow-any-dmrpp
Browse files Browse the repository at this point in the history
 - This will allow input to not fail if at least 1 input granule prod…
  • Loading branch information
sflynn-itsc authored Aug 7, 2024
2 parents be92fe4 + 750ef59 commit 1978353
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions dmrpp_generator/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,8 @@ def process(self):
collection_files = collection.get('files', [])
buckets = self.config.get('buckets')
granules = self.input['granules']

output_generated = False
for granule in granules:
dmrpp_files = []
for file_ in granule['files']:
Expand All @@ -119,6 +121,9 @@ def process(self):
input_file_path = file_.get('filename', f's3://{file_["bucket"]}/{file_["key"]}')
output_file_paths = self.dmrpp_generate(input_file=input_file_path, dmrpp_meta=self.dmrpp_meta)

if not output_generated and len(output_file_paths) > 0:
output_generated = True

for output_file_path in output_file_paths:
if output_file_path:
output_file_basename = os.path.basename(output_file_path)
Expand All @@ -131,17 +136,16 @@ def process(self):
}
dmrpp_files.append(dmrpp_file)
self.upload_file_to_s3(output_file_path, f's3://{dmrpp_file["bucket"]}/{dmrpp_file["key"]}')

if len(dmrpp_files) == 0:
self.logger_to_cw.warning(f'No dmrpp files were produced for {granule}')

if len(dmrpp_files) == 0:
message = f'No dmrpp files were produced for {granule}'
if self.verify_output:
raise Exception(message)
else:
self.logger_to_cw.warning(message)

self.strip_old_dmrpp_files(granule)
granule['files'] += dmrpp_files

if self.verify_output and not output_generated:
raise Exception('No dmrpp files were produced and verify_output was enabled.')

return self.input

@staticmethod
Expand Down

0 comments on commit 1978353

Please sign in to comment.