Commit e1a37d2
authored
Replace assert with raise ImportError for optuna/ray dependency checks (#46263)
The assert statements in default_hp_space_optuna() and
default_hp_space_ray() are silently stripped when Python runs with
the -O (optimize) flag. This allows the functions to proceed
without the required library installed, leading to confusing
NameErrors downstream instead of a clear ImportError.
The wandb equivalent (default_hp_space_wandb) already uses the
correct if/raise ImportError pattern. This change makes the
optuna and ray functions consistent.1 parent e977b06 commit e1a37d2
1 file changed
Lines changed: 4 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
452 | 452 | | |
453 | 453 | | |
454 | 454 | | |
455 | | - | |
| 455 | + | |
| 456 | + | |
456 | 457 | | |
457 | 458 | | |
458 | 459 | | |
| |||
464 | 465 | | |
465 | 466 | | |
466 | 467 | | |
467 | | - | |
| 468 | + | |
| 469 | + | |
468 | 470 | | |
469 | 471 | | |
470 | 472 | | |
| |||
0 commit comments