Skip to content
This repository was archived by the owner on Sep 25, 2023. It is now read-only.

Commit 3d571b7

Browse files
authored
fix: TDE-392 stop processing when an image transform fails (#1013)
* fix: stop processing if image transform fails and log error * fix: metadata filtering logging * fix: stop processing if image transform fails and log error * fix: metadata filtering logging * fix: remove testing variable * fix: fix exception and logging messages
1 parent 52934d7 commit 3d571b7

File tree

5 files changed

+12
-8
lines changed

5 files changed

+12
-8
lines changed

topo_processor/cog/execution.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ def run(cmd: "Command") -> Tuple[int, str, str]:
1818

1919
proc = subprocess.run(cmd.to_full_command(), stdout=subprocess.PIPE, stderr=subprocess.PIPE)
2020
if proc.returncode != 0:
21-
get_log().trace("Ran command failed", command=cmd.redacted_command(), duration=time_in_ms() - start_time)
21+
get_log().error("Run command failed", command=cmd.redacted_command(), duration=time_in_ms() - start_time)
2222
raise Exception(proc.stderr.decode())
23-
get_log().trace("Ran command succeeded", command=cmd.redacted_command(), duration=time_in_ms() - start_time)
23+
get_log().trace("Run command succeeded", command=cmd.redacted_command(), duration=time_in_ms() - start_time)
2424
return proc.returncode, proc.stdout.decode(), proc.stderr.decode()
2525

2626

topo_processor/data/data_transformers/data_transformer_imagery_historic.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,12 @@ def transform_data(self, item: Item) -> None:
3838
return
3939
output_path = os.path.join(item.collection.get_temp_dir(), f"{ulid.ULID()}.tiff")
4040

41-
create_cog(asset.source_path, output_path).run()
41+
try:
42+
create_cog(asset.source_path, output_path).run()
43+
except Exception as e:
44+
raise Exception(
45+
f"COG creation failed for item {item.id} with source path {asset.source_path} and output path {output_path}."
46+
) from e
4247

4348
get_log().debug("Created COG", output_path=output_path, duration=time_in_ms() - start_time)
4449

topo_processor/data/data_transformers/data_transformer_repo.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ def transform_data(self, item: Item) -> None:
2626
transformer.transform_data(item)
2727
except Exception as e:
2828
item.add_error(str(e), transformer.name, e)
29-
get_log().warning(f"Data Transform Failed: {e}", transformers=transformer.name)
30-
return
29+
get_log().error("Data Transform Failed. Process is stopped.", transformers=transformer.name, error=e)
30+
raise Exception(e)
3131
get_log().debug(
3232
"Data Transformed",
3333
duration=time_in_ms() - start_time,

topo_processor/metadata/lds_cache/lds_cache.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ def get_metadata(
7272

7373

7474
def filter_metadata(metadata_to_filter: Dict[str, Any], criteria: Dict[str, Any]) -> Dict[str, Any]:
75-
get_log().debug("filter_metadata_start", criteria=criteria)
75+
get_log().debug("filter_metadata", criteria=criteria)
7676
filtered_dict: Dict[str, Any] = {}
7777
is_found = False
7878

@@ -86,5 +86,4 @@ def filter_metadata(metadata_to_filter: Dict[str, Any], criteria: Dict[str, Any]
8686
break
8787
if is_found:
8888
filtered_dict[metadata_key] = metadata_value
89-
get_log().debug("filter_metadata_end", metadata=filtered_dict)
9089
return filtered_dict

topo_processor/stac/item_factory.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def _create_assets(source: str, data_type: str, metadata_path: str) -> None:
3434
for asset in assets:
3535
metadata_loader_rep.load_metadata(asset)
3636
if not asset.item:
37-
raise Exception(f"No item set for asset. Process is stopped.")
37+
raise Exception(f"No item set for asset {asset.source_path}. Process is stopped.")
3838

3939

4040
def _create_items(force: bool = False) -> None:

0 commit comments

Comments
 (0)