in xlml/utils/gpu.py [0:0]
def wait_for_resource_creation(operation_name: airflow.XComArg):
# Retrives the delete opeartion to check the status.
client = compute_v1.ZoneOperationsClient()
request = compute_v1.GetZoneOperationRequest(
operation=operation_name,
project=project_id,
zone=zone,
)
operation = client.get(request=request)
status = operation.status.name
if status in ("RUNNING", "PENDING"):
logging.info(
f"Resource create status: {status}, {operation.status_message}"
)
return False
else:
if operation.error:
logging.error(
(
"Error during resource creation: [Code:"
f" {operation.http_error_status_code}]:"
f" {operation.http_error_message}"
f" {operation.error}"
),
)
raise operation.exception() or RuntimeError(
operation.http_error_message
)
elif operation.warnings:
logging.warning("Warnings during resource creation:\n")
for warning in operation.warnings:
logging.warning(f" - {warning.code}: {warning.message}")
return True