|
1 | 1 | #!/usr/bin/env python3 |
2 | | -"""Submit workflow to geozarr pipeline via RabbitMQ.""" |
3 | | - |
4 | 2 | import json |
5 | 3 | import os |
6 | | -import sys |
7 | 4 |
|
8 | 5 | import pika |
9 | 6 |
|
10 | | - |
11 | | -def submit_workflow(payload: dict) -> bool: |
12 | | - """Submit workflow via RabbitMQ.""" |
13 | | - try: |
14 | | - username = os.getenv("RABBITMQ_USER", "user") |
15 | | - password = os.getenv("RABBITMQ_PASSWORD") |
16 | | - |
17 | | - if not password: |
18 | | - print("❌ RABBITMQ_PASSWORD not set") |
19 | | - print( |
20 | | - " Get: kubectl get secret rabbitmq-password -n core -o jsonpath='{.data.rabbitmq-password}' | base64 -d" |
21 | | - ) |
22 | | - return False |
23 | | - |
24 | | - credentials = pika.PlainCredentials(username, password) |
25 | | - connection = pika.BlockingConnection( |
26 | | - pika.ConnectionParameters("localhost", 5672, credentials=credentials) |
27 | | - ) |
28 | | - channel = connection.channel() |
29 | | - |
30 | | - exchange_name = "geozarr-staging" |
31 | | - routing_key = "eopf.items.test" |
32 | | - |
33 | | - channel.exchange_declare(exchange=exchange_name, exchange_type="topic", durable=True) |
34 | | - channel.basic_publish( |
35 | | - exchange=exchange_name, |
36 | | - routing_key=routing_key, |
37 | | - body=json.dumps(payload), |
38 | | - properties=pika.BasicProperties(delivery_mode=2, content_type="application/json"), |
39 | | - ) |
40 | | - |
41 | | - print(f"✅ Published: {payload['source_url'][:80]}...") |
42 | | - connection.close() |
43 | | - return True |
44 | | - |
45 | | - except Exception as e: |
46 | | - print(f"❌ Failed: {e}") |
47 | | - import traceback |
48 | | - |
49 | | - traceback.print_exc() |
50 | | - return False |
51 | | - |
52 | | - |
53 | | -if __name__ == "__main__": |
54 | | - # ✅ Use STAC item URL (pipeline extracts zarr URL from assets) |
55 | | - # ❌ NOT direct zarr URL |
56 | | - item_id = "S2A_MSIL2A_20251022T094121_N0511_R036_T34TDT_20251022T114817" |
57 | | - payload = { |
58 | | - "source_url": f"https://stac.core.eopf.eodc.eu/collections/sentinel-2-l2a/items/{item_id}", |
59 | | - "item_id": item_id, |
60 | | - "collection": "sentinel-2-l2a-dp-test", |
61 | | - } |
62 | | - |
63 | | - print("🚀 Submitting workflow via RabbitMQ") |
64 | | - print(f" Collection: {payload['collection']}") |
65 | | - print(f" Source: {payload['source_url']}") |
66 | | - print() |
67 | | - print("Prerequisites:") |
68 | | - print(" kubectl port-forward -n devseed-staging svc/rabbitmq 5672:5672 &") |
69 | | - print( |
70 | | - " export RABBITMQ_PASSWORD=$(kubectl get secret rabbitmq-password -n core -o jsonpath='{.data.rabbitmq-password}' | base64 -d)" |
71 | | - ) |
72 | | - print() |
73 | | - |
74 | | - if submit_workflow(payload): |
75 | | - print("✅ Monitor: kubectl get wf -n devseed-staging --watch") |
76 | | - sys.exit(0) |
77 | | - else: |
78 | | - sys.exit(1) |
| 7 | +# Test item that was failing (same as before) |
| 8 | +payload = { |
| 9 | + "source_url": "https://stac.core.eopf.eodc.eu/collections/sentinel-2-l2a/items/S2A_MSIL2A_20251023T105131_N0511_R051_T31UET_20251023T122522", |
| 10 | + "item_id": "S2A_MSIL2A_20251023T105131_N0511_R051_T31UET_20251023T122522", |
| 11 | + "collection": "sentinel-2-l2a-dp-test", |
| 12 | +} |
| 13 | + |
| 14 | +credentials = pika.PlainCredentials("user", os.getenv("RABBITMQ_PASSWORD")) |
| 15 | +connection = pika.BlockingConnection(pika.ConnectionParameters("localhost", 5672, "/", credentials)) |
| 16 | +channel = connection.channel() |
| 17 | + |
| 18 | +message = json.dumps(payload) |
| 19 | +channel.basic_publish( |
| 20 | + exchange="geozarr-events", |
| 21 | + routing_key="geozarr.convert", |
| 22 | + body=message, |
| 23 | + properties=pika.BasicProperties(content_type="application/json"), |
| 24 | +) |
| 25 | + |
| 26 | +print(f"✅ Published workflow for item: {payload['item_id']}") |
| 27 | +connection.close() |
0 commit comments