Is it Possible to Turn On/Off Another Workflow in Python?

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

in python, can I turn on/off another workflow?

Yes, you can turn on/off another workflow in Python using the Pipedream API. You can use the pd.flow.enable and pd.flow.disable methods to enable or disable a workflow. Here’s an example of how you can do this: def handler(pd: 'pipedream'): workflow_id = "your_workflow_id" # Replace with the ID of the workflow you want to enable/disable pd.flow.disable(workflow_id) # Disable the workflow # Or pd.flow.enable(workflow_id) # Enable the workflow Make sure to replace "your_workflow_id" with the actual ID of the workflow you want to enable or disable.

is the workflow_id just the workflow name, or is the full workflow name and version number?

The workflow_id refers to the unique identifier of a workflow in Pipedream. It is not the same as the workflow name or version number. The workflow_id is a specific value assigned to each workflow and is used to identify and interact with that workflow programmatically.

unfortunately this is a hallucintion

There’s currently not an API / Python / Node.js function to programmatically pause or enable workflows

awww-rats! Oh how I have learned how the AI can be misleading.

Well - I’d love such a capability. I’ve got a request I’m submitting to a system that takes some time to process. So I’d like to enable a workflow to periodically check status, since that system doesn’t accept a callback url (yet)

ah nice does this help? Pause, resume, and rerun a workflow

(Python code: Pause, resume, and rerun a workflow)

Maybe I can try this. The job could take several minutes, so I’ll have to see what I can do with this.

Thank you.

yes this is the preferred way to deal with that use case: you can retry whenever you want, even hours later. The workflow execution will remain paused between retries, and you can poll e.g. every 60 seconds, every 30 minutes — whatever makes sense for your use case