Skip to content

feat(workflows): Add client library sample to delete a workflow - #14802

Open
iennae wants to merge 1 commit into
refactor/workflows-cloud-client-packagefrom
feat/workflows-delete-workflow
Open

iennae wants to merge 1 commit into
refactor/workflows-cloud-client-packagefrom
feat/workflows-delete-workflow

Conversation

@iennae

@iennae iennae commented Nov 14, 2026

Copy link
Copy Markdown
Contributor

Description

Deleting a workflow returns a long-running operation that must complete before dependent resources or tests treat the workflow as removed.

Adds delete_workflow.py (workflows_delete_workflow) using workflows_v1.WorkflowsClient.delete_workflow with LRO .result() synchronization, unit tests, and a gated live integration test.

Note: Stacked on #14797 (refactor/workflows-cloud-client-package) so this PR shows only this sample's diff.

Checklist

Testing

  • I have tested this change on a live environment and verified it works as intended. Unit and live integration tests pass on Python 3.13.

Compliance & Style


Post-Approval Actions

  • Please merge this PR for me once it is approved

@iennae
iennae requested review from a team as code owners November 14, 2026 00:21
@product-auto-label product-auto-label Bot added the api: workflows Issues related to the Workflows API. label Nov 14, 2026
@snippet-bot

snippet-bot Bot commented Nov 14, 2026 •

Copy link
Copy Markdown

Here is the summary of changes.

You are about to add 1 region tag.

This comment is generated by snippet-bot.
If you find problems with this result, please file an issue at:
https://github.com/googleapis/repo-automation-bots/issues.
To update this comment, add snippet-bot:force-run label or use the checkbox below:

  • Refresh this comment

@product-auto-label product-auto-label Bot added the samples Issues that are directly related to samples. label Nov 14, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a new sample script delete_workflow.py to delete Google Cloud Workflows, along with corresponding unit and live tests in delete_workflow_test.py. The review feedback highlights a missing import of workflows_v1 in the test file that will cause a NameError during execution, and suggests removing a redundant pass statement in one of the test cases.

Comment on lines +17 to +19
from google.api_core import exceptions
import pytest
from workflows_samples import delete_workflow

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The test file uses workflows_v1.WorkflowsClient in test_delete_workflow_live (line 84), but workflows_v1 is not imported in this file. This will cause a NameError when the test module is loaded. Please import workflows_v1 from google.cloud.

Suggested change
from google.api_core import exceptions
import pytest
from workflows_samples import delete_workflow
from google.api_core import exceptions
from google.cloud import workflows_v1
import pytest
from workflows_samples import delete_workflow

Comment on lines +38 to +40
client = mock_client_class.return_value
pass

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The pass statement is redundant and can be safely removed.

Suggested change
client = mock_client_class.return_value
pass
client = mock_client_class.return_value

Cleaning up workflows programmatically from Python requires awaiting the long-running delete operation rather than treating the initial RPC return as completion. Adding `workflows_delete_workflow` demonstrates synchronous LRO completion and `NotFound` error handling.
@iennae
iennae force-pushed the feat/workflows-delete-workflow branch from d45f91b to 0a9c62a Compare November 14, 2026 00:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api: workflows Issues related to the Workflows API. samples Issues that are directly related to samples.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant