Skip to content

Commit bebb667

Browse files
committed
Raise exception if referenced hd5 file not found
1 parent 8c92d79 commit bebb667

2 files changed

Lines changed: 19 additions & 28 deletions

File tree

src/dlstbx/services/s3echo_collector.py

Lines changed: 16 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -72,14 +72,10 @@ def on_start(self, rw, header, message):
7272
response_info = update_dcid_info_file(
7373
minio_client, bucket_name, dcid, 0, rpid, self.log
7474
)
75-
try:
76-
image_files = iris.get_image_files(images, self.log)
77-
s3echo_upload_files.update(
78-
{name: (dcid, pth) for name, pth in image_files.items()}
79-
)
80-
except Exception as err:
81-
self.log.exception("Error uploading image files to S3 Echo")
82-
raise err
75+
image_files = iris.get_image_files(images, self.log)
76+
s3echo_upload_files.update(
77+
{name: (dcid, pth) for name, pth in image_files.items()}
78+
)
8379
if not response_info:
8480
self.log.debug("Sending message to upload endpoint")
8581
rw.send_to(
@@ -93,23 +89,19 @@ def on_start(self, rw, header, message):
9389
response_info = update_dcid_info_file(
9490
minio_client, bucket_name, dcid, 0, rpid, self.log
9591
)
96-
try:
97-
image_files = iris.get_related_images_files_from_h5(
98-
image_master_file, self.log
99-
)
100-
s3echo_upload_files.update(
101-
{name: (dcid, pth) for name, pth in image_files.items()}
92+
image_files = iris.get_related_images_files_from_h5(
93+
image_master_file, self.log
94+
)
95+
s3echo_upload_files.update(
96+
{name: (dcid, pth) for name, pth in image_files.items()}
97+
)
98+
if not response_info:
99+
self.log.debug("Sending message to upload endpoint")
100+
rw.send_to(
101+
"upload",
102+
{"s3echo_upload": {dcid: image_files}},
103+
transaction=txn,
102104
)
103-
if not response_info:
104-
self.log.debug("Sending message to upload endpoint")
105-
rw.send_to(
106-
"upload",
107-
{"s3echo_upload": {dcid: image_files}},
108-
transaction=txn,
109-
)
110-
except Exception as err:
111-
self.log.exception("Error uploading image files to S3 Echo")
112-
raise err
113105
rw.environment.update({"s3echo_upload": s3echo_upload_files})
114106
self.log.debug("Sending message to watch endpoint")
115107
rw.send_to("watch", message, transaction=txn)

src/dlstbx/util/iris.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -119,10 +119,9 @@ def get_image_files(images, logger):
119119

120120
def get_related_images_files_from_h5(h5_file, logger):
121121
file_list = {}
122-
try:
123-
related = set(find_all_references(h5_file))
124-
except (ValueError, KeyError):
125-
logger.error(f"Could not find files related to {h5_file}", exc_info=True)
122+
related = set(find_all_references(h5_file))
123+
if not related:
124+
raise ValueError(f"No related image files found for {h5_file}")
126125
image_pattern = str(h5_file).split("master")[0] + "*"
127126
related.union(glob.glob(image_pattern))
128127
for filepath in sorted(related):

0 commit comments

Comments
 (0)