Skip to content

Commit

Permalink
Merge pull request #125 from zerolab/chore/consistent-optimizer-spelling
Browse files Browse the repository at this point in the history
Be consistent with the optimizer spelling
  • Loading branch information
Stormheg authored Jul 13, 2023
2 parents 1258f99 + 7d7a237 commit a03c333
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions willow/registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,29 +94,29 @@ def register_optimizer(self, optimizer_class: "OptimizerBase"):
# try to check Django settings, if used in that context
from django.conf import settings

enabled_optimisers = getattr(settings, "WILLOW_OPTIMIZERS", False)
enabled_optimizers = getattr(settings, "WILLOW_OPTIMIZERS", False)
except ImportError:
# fall back to env vars.
import os

enabled_optimisers = os.environ.get("WILLOW_OPTIMIZERS", False)
enabled_optimizers = os.environ.get("WILLOW_OPTIMIZERS", False)

if not enabled_optimisers:
if not enabled_optimizers:
# WILLOW_OPTIMIZERS is either not set, or is set to a false-y value, so skip registration
return

if isinstance(enabled_optimisers, str):
if enabled_optimisers.lower() == "false":
if isinstance(enabled_optimizers, str):
if enabled_optimizers.lower() == "false":
return
elif enabled_optimisers.lower() == "true":
enabled_optimisers = True
elif enabled_optimizers.lower() == "true":
enabled_optimizers = True
else:
enabled_optimisers = enabled_optimisers.split(",")
enabled_optimizers = enabled_optimizers.split(",")

if enabled_optimisers is True:
if enabled_optimizers is True:
add_optimizer = True
else:
add_optimizer = optimizer_class.library_name in enabled_optimisers
add_optimizer = optimizer_class.library_name in enabled_optimizers

if (
add_optimizer
Expand Down

0 comments on commit a03c333

Please sign in to comment.