-
Notifications
You must be signed in to change notification settings - Fork 11
Allow creating instances without waiting #80
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,5 +1,6 @@ | ||||||||||||||||||||||||||||
| import itertools | ||||||||||||||||||||||||||||
| import time | ||||||||||||||||||||||||||||
| from collections.abc import Callable | ||||||||||||||||||||||||||||
| from dataclasses import dataclass | ||||||||||||||||||||||||||||
| from typing import Literal | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
|
|
@@ -150,6 +151,7 @@ def create( | |||||||||||||||||||||||||||
| pricing: Pricing | None = None, | ||||||||||||||||||||||||||||
| coupon: str | None = None, | ||||||||||||||||||||||||||||
| *, | ||||||||||||||||||||||||||||
| wait_for_status: str | Callable[[str], bool] | None = lambda s: s != InstanceStatus.ORDERED, | ||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||
| max_wait_time: float = 180, | ||||||||||||||||||||||||||||
| initial_interval: float = 0.5, | ||||||||||||||||||||||||||||
| max_interval: float = 5, | ||||||||||||||||||||||||||||
|
|
@@ -172,6 +174,7 @@ def create( | |||||||||||||||||||||||||||
| contract: Optional contract type for the instance. | ||||||||||||||||||||||||||||
| pricing: Optional pricing model for the instance. | ||||||||||||||||||||||||||||
| coupon: Optional coupon code for discounts. | ||||||||||||||||||||||||||||
| wait_for_status: Status to wait for the instance to reach, or callable that returns True when the desired status is reached. Default to any status other than ORDERED. If None, no wait is performed. | ||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||
| wait_for_status: Status to wait for the instance to reach, or callable that returns True when the desired status is reached. Default to any status other than ORDERED. If None, no wait is performed. | |
| wait_for_status: Status to wait for the instance to reach, or callable that returns True when the desired status is reached. Defaults to any status other than ORDERED. If None, no wait is performed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The current docstring is based on and consistent with ClustersService.create
Copilot
AI
Feb 11, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wait_for_status is typed as str | Callable[[str], bool], but the code/tests appear to use InstanceStatus values (and instance.status is compared to InstanceStatus). This should be typed consistently (e.g., InstanceStatus | Callable[[InstanceStatus], bool] | None) to avoid misleading API contracts and type-checking issues.
| if callable(wait_for_status): | |
| if wait_for_status(instance.status): | |
| return instance | |
| elif instance.status == wait_for_status: | |
| return instance | |
| status_value = getattr(instance.status, 'value', instance.status) | |
| if callable(wait_for_status): | |
| if wait_for_status(status_value): | |
| return instance | |
| else: | |
| target_status = getattr(wait_for_status, 'value', wait_for_status) | |
| if status_value == target_status: | |
| return instance |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
InstanceStatus is a namespace for str constants. The actual type passed to wait_for_status is str and not InstanceStatus
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The PR title/description says it adds
InstancesService.create_nowait, but the diff only changescreate()by introducingwait_for_status. Either add the describedcreate_nowaitmethod (e.g., a small wrapper callingcreate(..., wait_for_status=None)), or update the PR metadata to reflect the actual API change.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated the description