Skip to content
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

Fix unknown scheduler error handling in calculate_sigmas function #6280

Merged
merged 1 commit into from
Dec 31, 2024

Conversation

blepping
Copy link
Contributor

@blepping blepping commented Dec 30, 2024

calculate_sigmas currently doesn't handle unknown scheduler names correctly. The variable sigmas never gets bound in the error case, so it will fail with a rather unintuitive NameError: name 'sigmas' is not defined.

This pull modernizes calculate_sigmas and scheduler lookup to use a dictionary for the scheduler list and adds type annotations. Of course it also fixes the original issue by raising ValueError after the log message. Changes tested to be compatible with Python 3.8.

Taking this approach also has the advantage of not having to repeat/keep the list of scheduler names in sync (since it can just be generated from the list keys) and reduces duplicated code. Also, custom nodes can easily add themselves to the scheduler list without having to do stuff like monkeypatch calculate_sigmas.

It could be changed to just use a simple tuple if desired, but NamedTuple is a lot more readable.

I've been using this myself for a while without any issues but more testing would definitely be good. (I don't see an obvious way it would cause a problem though.)

@blepping blepping changed the title Fix unknown sampler error handling in calculate_sigmas function Fix unknown scheduler error handling in calculate_sigmas function Dec 30, 2024
@comfyanonymous comfyanonymous added the Run-CI-Test This is an administrative label to tell the CI to run full automatic testing on this PR now. label Dec 31, 2024
Copy link

(Automated Bot Message) CI Tests are running, you can view the results at https://ci.comfy.org/?branch=6280%2Fmerge

@comfyanonymous comfyanonymous merged commit c0338a4 into comfyanonymous:master Dec 31, 2024
14 of 18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Run-CI-Test This is an administrative label to tell the CI to run full automatic testing on this PR now.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants