Ananya Mishra
05/10/2023, 8:03 PMprefect block delete...
. However, when trying to delete these blocks, we keep getting 409 Conflict error codes on those blocks.
Strange, because the same blocks can be deleted just fine through the UI. Any ideas on how we could resolve this? Feeling like some kind of issue with how the API is handling block deletion...Nate
05/10/2023, 8:09 PMprefect version
if possibleAnanya Mishra
05/10/2023, 8:15 PM{'kubernetes-job/deployment-infra-16899', 's3/deployment-storage-16451', 'kubernetes-job/deployment-infra-16541', ...}
and then run subprocess.run(f"prefect block delete {slug}", shell=True)
in python for each blockroot@421ed1fe04e5:~/.prefect# prefect version
Version: 2.7.12
API version: 0.8.4
Python version: 3.11.1
Git commit: 524c25cd
Built: Mon, Feb 6, 2023 4:31 PM
OS/Arch: linux/aarch64
Profile: default
Server type: cloud
Nate
05/10/2023, 8:17 PMAnanya Mishra
05/10/2023, 8:18 PMNate
05/10/2023, 8:18 PMAnanya Mishra
05/10/2023, 8:19 PMNate
05/10/2023, 8:22 PMslug
(as you have above), grab the ID (a UUID) off each one with block_document.id
and then pass that value into delete_block_document
from prefect import get_client
from uuid import UUID
slugs = ["block-type/block-doc-slug", ...]
async with get_client() as client:
for slug in slugs:
type_slug, name_slug = slug.split('/')
block_document = await client.read_block_document_by_slug(name_slug, type_slug)
await client.delete_block_document(UUID(block_document.id))
should be something like thisAnanya Mishra
05/10/2023, 8:37 PMhttpx.HTTPStatusError: Client error '409 Conflict' for url '<https://api.prefect.cloud/api/accounts/b8194971-9f89-43fe-a099-69552528a88a/workspaces/e0b524be-50ed-4eca-b77b-d2a1b2ade39f/block_documents/5fd2e02b-160e-4cf4-a990-5754e5e6230a>'
Nate
05/10/2023, 8:40 PMAnanya Mishra
05/10/2023, 8:41 PMNate
05/10/2023, 8:41 PMAnanya Mishra
05/10/2023, 8:43 PMNate
05/10/2023, 8:46 PM