Viewing Workflow Status and Accessing Results of Pipedream Workflow via HTTP Response in Python

This topic was automatically generated from Slack. You can find the original thread here.

Hi I’m creating several pipedream workflows using Python which are triggered via an HTTP response to the webhook. The HTTP responses will be sent from an external server. How would I view the “status/log” of the ongoing workflow (i.e. its status during the steps) externally, and also how would I be able to query+access the result of a workflow body?

Hi Peter, I’m going to see how our Q&A bot answers this question and will correct / supplement as necessary

Hi I’m creating several pipedream workflows using Python which are triggered via an HTTP response to the webhook. The HTTP responses will be sent from an external server. How would I view the “status/log” of the ongoing workflow (i.e. its status during the steps) externally, and also how would I be able to query+access the result of a workflow body?

To view the status or log of an ongoing workflow externally, you can customize the HTTP response using the “Return HTTP Response” action from the HTTP / Webhook app. This allows you to set a custom status code, response headers, and response body. You can find more information on how to use this action here: https://pipedream.com/apps/http/actions/return-http-response To access the result of a workflow body, you can use the data returned from the steps in your workflow. For example, if you have a Python code step that returns data, you can use that data in the “Return HTTP Response” action to include it in the response body. Keep in mind that you’ll need to handle the logic of querying and accessing the results within your workflow steps, as Pipedream doesn’t provide a built-in way to query the results externally.

You can’t access the status of running executions until the execution is done. Then you can access all of the logs / exports from the event inspector. Can you explain how the event inspector and the event history UI works?

The Event Inspector allows you to view the execution history of your workflows. Each time a workflow is triggered, a new execution is created, and you can view the logs and step exports for each execution in the Event Inspector. To access the Event Inspector, navigate to your workflow in the Pipedream UI and click on the “Inspector” tab. The Event History is a centralized view of all workflow events and their stack traces, which can be found in the dashboard under the “Event History” section. In the Event History, you can filter events by workflow, execution status, and time range. This includes events in progress, giving you real-time visibility into the health of your workflows. Please note that Event Histories are currently in beta and are only available to Paid workspaces with a limited number of events. For more information on the Event Inspector, visit: Limits For more information on the Event History, visit: Event History

Let me know if that helps

Thanks! That does help a lot. Just another question: if a task is expected to take 2 mins and its still not finished for 5, I would like to log it as an “error” on my DB. Would I have to send in an HTTP request using the Pipedream REST API, and if I don’t receive a response then I log it as an error? Or would I have to wait as I cannot access the status of running operations?

I’d recommend setting a 5 min timeout in your workflow’s settings, which will raise an error if the workflow exceeds 5 min for any execution. Then you can run a workflow on any errors in your account, or specific workflows, and save the error to your DB.

Can you tell me how to set a 5 min timeout on workflow executions and how to run a custom error workflow?

To set a 5-minute timeout on your workflow executions, follow these steps: 1. Visit your workflow in the Pipedream UI. 2. Click on the “…” menu at the top-right corner and select “Settings”. 3. In the Settings, you can set the “Max Execution Time” to 5 minutes (300000 ms). For handling errors, you can create a custom error workflow. When an error occurs in your main workflow, it will trigger the custom error workflow. Here’s how to set it up: 1. Create a new workflow that will act as your custom error workflow. 2. Set the trigger for this workflow to “Pipedream Platform - Workflow Error”. 3. In the custom error workflow, add the necessary steps to handle the error, such as logging the error to your database or sending notifications. Now, when an error occurs in any of your workflows, the custom error workflow will be triggered, allowing you to handle the error as needed. For more information on error handling, visit: Handling errors

There’s no Workflow error source. I think I have to subscribe to the $errors stream to run a custom error workflow right?

Yes, you’re correct. To run a custom error workflow, you need to subscribe to the $errors stream. Here’s a step-by-step guide on how to set up a custom error workflow: 1. Create a new workflow that will act as your custom error workflow. 2. Set the trigger for this workflow to “Pipedream Platform - Workflow Error”. 3. In the custom error workflow, add the necessary steps to handle the error, such as logging the error to your database or sending notifications. To subscribe to the $errors stream, you can use the Pipedream API to create a subscription. Replace the emitter_id with the ID of the workflow you want to handle errors for, and the listener_id with the ID of the custom error workflow you created: ```
bash curl ‘https://api.pipedream.com/v1/subscriptions?emitter_id=p_workflow1&listener_id=p_workflow2&event_name=$errors’ \ -X POST \ -H “Authorization: Bearer <api_key>” \ -H “Content-Type: application/json”

I’ll try it out. Thanks for the help! Love the platform btw :slightly_smiling_face:

Pi is hallucinating #2 in that list of instructions, but the rest of those answers are accurate. Take a look at the docs on how to run custom code on errors at https://pipedream.com/docs/workflows/errors/

Thanks! Let us know if you have more questions