Skip to content

Commit 3017a1b

Browse files
committed
Avoid sending VI messages to tiler queue
1 parent bd76812 commit 3017a1b

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

src/hls_lpdaac/forward/index.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,11 @@ def _handler(event: "S3Event", *, lpdaac_queue_url: str, tiler_queue_url: str) -
3232
json_contents = s3.Object(bucket, json_key).get()["Body"].read().decode("utf-8")
3333
_send_message(lpdaac_queue_url, key=json_key, message=json_contents)
3434

35-
stac_json_key = json_key.replace(".json", "_stac.json")
36-
stac_url = f"s3://{bucket}/{stac_json_key}"
37-
_send_message(tiler_queue_url, key=stac_json_key, message=stac_url)
35+
# Send message to tiler queue ONLY for non-VI files
36+
if "_VI/" not in json_key:
37+
stac_json_key = json_key.replace(".json", "_stac.json")
38+
stac_url = f"s3://{bucket}/{stac_json_key}"
39+
_send_message(tiler_queue_url, key=stac_json_key, message=stac_url)
3840

3941

4042
def _send_message(queue_url: str, *, key: str, message: str) -> None:

tests/integration/test_forward_lambda.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,17 +35,15 @@ def test_notification(
3535
obj.wait_until_not_exists()
3636

3737
# We expect 4 messages, 2 for regular and 2 for VI
38-
assert len(forward_messages) == 4
39-
assert forward_messages[0].body == body
38+
assert forward_messages == [body] * 4
4039

4140
# We expect only 2 messages for the 2 non-VI objects written
4241
assert len(tiler_messages) == 2
43-
expected_bodies = [
42+
assert tiler_messages == [
4443
f"s3://{bucket_name}/{obj.key.replace('.json', '_stac.json')}"
4544
for obj in objects
46-
if "_VI" in obj.key
45+
if "_VI/" not in obj.key
4746
]
48-
assert all(message.body in expected_bodies for message in tiler_messages)
4947

5048

5149
def ssm_param_value(ssm: SSMClient, name: str) -> str:
@@ -72,7 +70,7 @@ def write_objects(bucket: Bucket, body: str) -> Sequence[Object]:
7270
return objects
7371

7472

75-
def fetch_messages(queue: Queue) -> Iterator[Message]:
73+
def fetch_messages(queue: Queue) -> Iterator[str]:
7674
while messages := queue.receive_messages(
7775
MaxNumberOfMessages=10, WaitTimeSeconds=20
7876
):
@@ -83,4 +81,4 @@ def fetch_messages(queue: Queue) -> Iterator[Message]:
8381
]
8482
)
8583

86-
yield from messages
84+
yield from (message.body for message in messages)

0 commit comments

Comments
 (0)