Skip to content

Commit a862beb

Browse files
committed
lambdalabs: add region-aware instance filtering in Kconfig
When using manual region selection for Lambda Labs, the instance type menu would show all instances regardless of whether they were available in the selected region. This led to a poor user experience where users could select incompatible region/instance combinations that would fail during provisioning. This change adds intelligent Kconfig dependencies to filter instance types based on the selected region: 1. Available instance types now include a 'depends on' clause that makes them visible only when: - Using automatic region selection modes (smart cheapest or smart infer), OR - Using manual region selection AND the instance is available in the selected region 2. Unavailable instance types (those with no capacity) are now completely hidden when using manual region selection, preventing accidental selection of instances that will always fail For example, gpu_1x_a10 which is only available in us-east-1 and us-west-1 now has: depends on !TERRAFORM_LAMBDALABS_REGION_MANUAL || \ (TERRAFORM_LAMBDALABS_REGION_US_EAST_1 || \ TERRAFORM_LAMBDALABS_REGION_US_WEST_1) This ensures users see only valid options for their selected region, significantly improving the configuration experience and preventing provisioning failures due to region/instance mismatches. The dependencies are dynamically generated based on real-time Lambda Labs API data, ensuring the constraints stay current with actual availability. Generated-by: Claude AI Signed-off-by: Luis Chamberlain <[email protected]>
1 parent 768dad8 commit a862beb

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

scripts/lambdalabs_api.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,22 @@ def generate_instance_types_kconfig(api_key: str) -> str:
279279

280280
kconfig += f"config TERRAFORM_LAMBDALABS_INSTANCE_TYPE_{kconfig_name}\n"
281281
kconfig += f'\tbool "{name} ({price_str}) - {description} [AVAILABLE]"\n'
282+
283+
# Add region dependencies when manual region selection is used
284+
if regions:
285+
# Convert region names to Kconfig symbols
286+
region_configs = []
287+
for region in regions:
288+
region_kconfig = region.upper().replace("-", "_")
289+
region_configs.append(
290+
f"TERRAFORM_LAMBDALABS_REGION_{region_kconfig}"
291+
)
292+
293+
# Add depends on clause for manual region selection
294+
kconfig += "\tdepends on !TERRAFORM_LAMBDALABS_REGION_MANUAL || ("
295+
kconfig += " || ".join(region_configs)
296+
kconfig += ")\n"
297+
282298
kconfig += "\thelp\n"
283299
kconfig += f"\t {description}\n"
284300
kconfig += f"\t AVAILABLE in: {regions_str}\n"
@@ -301,6 +317,8 @@ def generate_instance_types_kconfig(api_key: str) -> str:
301317

302318
kconfig += f"config TERRAFORM_LAMBDALABS_INSTANCE_TYPE_{kconfig_name}\n"
303319
kconfig += f'\tbool "{name} ({price_str}) - [NO CAPACITY]"\n'
320+
# Make unavailable types never show when manual region selection is used
321+
kconfig += "\tdepends on !TERRAFORM_LAMBDALABS_REGION_MANUAL\n"
304322
kconfig += "\thelp\n"
305323
kconfig += f"\t {description}\n"
306324
kconfig += f"\t WARNING: Currently NO CAPACITY in any region!\n"

0 commit comments

Comments
 (0)