Repository navigation
feat(images): regenerate SDK with Python image workflows - #18
Conversation
Vitus Larrieu (vitus-dedalus)
left a comment
There was a problem hiding this comment.
Live sync and async imports reached ready. Both status-request timeout failures still reproduce on this head without the accepted image ID. Requesting changes. Apply the three suggestions together.
| import httpx | ||
| from typing_extensions import TypedDict | ||
|
|
||
| from . import AsyncDedalus, Dedalus |
There was a problem hiding this comment.
issue (reliability, blocking): import the transport timeout type for both polling fixes.
The SDK raises APITimeoutError for an HTTPX request timeout. The two polling suggestions below need this import. Apply all three suggestions together.
| from . import AsyncDedalus, Dedalus | |
| from . import APITimeoutError, AsyncDedalus, Dedalus |
| response = client.get( | ||
| f"/v1/images/{quote(image_id, safe='')}", | ||
| cast_to=httpx.Response, | ||
| options={"timeout": remaining, "max_retries": 0}, | ||
| ) |
There was a problem hiding this comment.
issue (reliability, blocking): preserve the image ID when the status request times out.
A reproduced HTTPX ReadTimeout escapes as APITimeoutError, without .image. The registration may already be preparing, so callers need its ID to resume polling. Wrap the transport timeout as ImagePreparationError and retain its cause. This requires the import suggestion above.
| response = client.get( | |
| f"/v1/images/{quote(image_id, safe='')}", | |
| cast_to=httpx.Response, | |
| options={"timeout": remaining, "max_retries": 0}, | |
| ) | |
| try: | |
| response = client.get( | |
| f"/v1/images/{quote(image_id, safe='')}", | |
| cast_to=httpx.Response, | |
| options={"timeout": remaining, "max_retries": 0}, | |
| ) | |
| except APITimeoutError as error: | |
| raise ImagePreparationError( | |
| Image(image_id=image_id, state="unknown"), | |
| "Status request timed out. Preparation continues. Use this image ID to resume polling.", | |
| ) from error |
| except TimeoutError: | ||
| raise ImagePreparationError( | ||
| Image(image_id=image_id, state="unknown"), | ||
| "Timed out waiting. Preparation continues; use this image ID to resume polling.", | ||
| ) from None |
There was a problem hiding this comment.
issue (reliability, blocking): handle SDK request timeouts in async polling too.
This handler catches the overall deadline but misses APITimeoutError from an individual status request. That reproduced failure also loses .image. Preserve the image ID and original cause for either timeout. This requires the import suggestion above.
| except TimeoutError: | |
| raise ImagePreparationError( | |
| Image(image_id=image_id, state="unknown"), | |
| "Timed out waiting. Preparation continues; use this image ID to resume polling.", | |
| ) from None | |
| except (TimeoutError, APITimeoutError) as error: | |
| raise ImagePreparationError( | |
| Image(image_id=image_id, state="unknown"), | |
| "Timed out waiting. Preparation continues. Use this image ID to resume polling.", | |
| ) from error |
Vitus Larrieu (vitus-dedalus)
left a comment
There was a problem hiding this comment.
Approved. Verified the timeout fix preserves the image ID and original error in both sync and async polling. All 27 tests pass.
Refresh the generated API surface to cover all 31 public operations, including the six image operations, manual Machine resize, Machine-create image_id, PATCH autoresizing updates, lifecycle refusal fields, and flat image errors. Remove the obsolete log-reauthorization operation. The pinned contract check fails CI for missing, obsolete, duplicate operations or changed request fields; mutation tests verify the guard.
Preserve sync/async import and polling helpers, default waiting and
wait=False, separate storage credentials, sync remaining-budget timeouts, and async cancellation. Keep package metadata consistent with runtime version 0.6.0. Unsupported platforms fail before uploading; the current helper supports linux/amd64.Validation: 25 source tests and 25 installed-wheel tests passed; wheel and source distribution built. Formatting, contract guard tests, and actionlint passed. Both sync and async tests pass ready image IDs into generated Machine creation.
Tests cover mocked upload and registration, readiness, no-wait, terminal failures, timeouts/cancellation, credential separation, ready image IDs passed to Machine creation, PATCH/resize methods, and public error/refusal fields. Live archive preparation and Machine execution remain required before release; mocks do not establish live readiness. No package was published and no live resources were created.