unleash-client-python icon indicating copy to clipboard operation
unleash-client-python copied to clipboard

Incorrect warning message

Open sanchaz opened this issue 3 years ago • 0 comments

Describe the bug "scheduler_executor should only be used with a custom scheduler."

To Reproduce Init with no scheduler and no scheduler_executor

Sample code is welcome!

Expected behavior Expected no warning message if both are not provided. Expected warning message if scheduler_executor is provided, but no scheduler.

Logs N/A

Additional context Current code

        # Scheduler bootstrapping
        # - Figure out the Unleash executor name.
        if scheduler and scheduler_executor:
            self.unleash_executor_name = scheduler_executor
        elif scheduler and not scheduler_executor:
            raise ValueError("If using a custom scheduler, you must specify a executor.")
        else:
            if not scheduler:
                LOGGER.warning("scheduler_executor should only be used with a custom scheduler.")

            self.unleash_executor_name = f"unleash_executor_{''.join(random.choices(string.ascii_uppercase + string.digits, k=6))}"

Suggested

        # Scheduler bootstrapping
        # - Figure out the Unleash executor name.
        if scheduler and scheduler_executor:
            self.unleash_executor_name = scheduler_executor
        elif scheduler and not scheduler_executor:
            raise ValueError("If using a custom scheduler, you must specify a executor.")
        else:
            if not scheduler and scheduler_executor:
                LOGGER.warning("scheduler_executor should only be used with a custom scheduler.")

            self.unleash_executor_name = f"unleash_executor_{''.join(random.choices(string.ascii_uppercase + string.digits, k=6))}"

sanchaz avatar Oct 26 '22 05:10 sanchaz