Scenario
A Python application needs to process new customer registration CSVs as they arrive. The process is:- A new CSV file of raw customer data is uploaded to a specific S3 location.
- The application triggers a Lume pipeline, pointing to the S3 object’s path.
- The application does not block or wait. It relies on Lume to call it back when the job is done.
- When Lume sends a webhook notification, the application fetches the run status and, on success, adds the event to a downstream processing queue.
The Application Code
This example uses the Flask web framework (pip install Flask
).
How to Run This Example
-
Install Dependencies:
-
Set Environment Variables:
-
Expose Your Local Server: Lume’s cloud platform needs to be able to reach your local machine. Use a tool like
ngrok
to create a secure public URL for your local server.This will give you a public URL likehttps://<unique_id>.ngrok.io
. -
Configure Webhook in Lume: In the Lume UI for your
customer_cleaner
Flow, add a new Webhook Notification pointing to your ngrok URL (e.g.,https://<unique_id>.ngrok.io/lume-webhook
). -
Run the Application:
The script will first trigger the run and then start the web server. When Lume finishes the run, you will see the webhook request printed in your terminal, followed by the simulated worker processing.
Sample Data
Sample Input
(Contents ofnew_customers.csv
uploaded to S3)
id | name | |
---|---|---|
1 | John Doe | john.doe@example.com |
2 | JANE SMITH | JANE.SMITH@EXAMPLE.COM |
Sample Output
(Contents of the mapped CSV file in the target S3 location, available to the background worker)customer_id | full_name | email_address | is_premium |
---|---|---|---|
CUST-1 | John Doe | john.doe@example.com | false |
CUST-2 | Jane Smith | jane.smith@example.com | false |
is_premium
flag.