Repository navigation
Conversation
|
Here is the summary of changes. You are about to add 1 region tag.
This comment is generated by snippet-bot.
|
There was a problem hiding this comment.
Code Review
This pull request introduces a new sample script and corresponding tests for cancelling a running Google Cloud Workflows execution. The feedback suggests utilizing the client library's built-in helper methods (execution_path and workflow_path) to construct resource paths instead of manually formatting them with f-strings, which improves robustness and aligns with best practices.
| name = ( | ||
| f"projects/{project_id}/locations/{location_id}/workflows/{workflow_id}" | ||
| f"/executions/{execution_id}" | ||
| ) |
There was a problem hiding this comment.
Use the client's built-in execution_path helper method instead of manually constructing the resource path with f-strings. This is more robust, less prone to formatting errors, and aligns with Google Cloud client library best practices.
name = client.execution_path(project_id, location_id, workflow_id, execution_id)| parent = ( | ||
| f"projects/{conftest.LIVE_PROJECT_ID}/locations/{conftest.LIVE_LOCATION_ID}" | ||
| f"/workflows/{sleep_workflow_id}" | ||
| ) |
There was a problem hiding this comment.
Use the client's built-in workflow_path helper method instead of manually constructing the parent resource path with f-strings. This is more robust and consistent with the rest of the codebase.
| parent = ( | |
| f"projects/{conftest.LIVE_PROJECT_ID}/locations/{conftest.LIVE_LOCATION_ID}" | |
| f"/workflows/{sleep_workflow_id}" | |
| ) | |
| parent = executions_client.workflow_path( | |
| conftest.LIVE_PROJECT_ID, | |
| conftest.LIVE_LOCATION_ID, | |
| sleep_workflow_id, | |
| ) |
Stopping a stuck or superseded workflow run from Python lacked a sample showing `executions_v1` cancellation and state verification. Adding `workflows_cancel_execution` covers `cancel_execution` and `NotFound` handling on active runs.
a431a65 to
122bf44
Compare
Description
Adds
cancel_execution.py(workflows_cancel_execution) usingexecutions_v1.ExecutionsClient.cancel_executionto terminate an in-flight execution, verified by unit tests and a gated live integration test against a sleeping workflow.Checklist
Testing
Compliance & Style
workflows/cloud-client/.Post-Approval Actions