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 debug loglevel #2139

Merged
merged 1 commit into from
Sep 22, 2023
Merged

Fix debug loglevel #2139

merged 1 commit into from
Sep 22, 2023

Conversation

huchenlei
Copy link
Collaborator

@huchenlei huchenlei commented Sep 22, 2023

process_has_sdxl_refiner is a static method on Script. Calling it with self. prefix will cause issue when the method is decorated by

def timer_decorator(func):
    """Time the decorated function and output the result to debug logger."""
    if logger.level != logging.DEBUG:
        return func

    @functools.wraps(func)
    def wrapper(*args, **kwargs):
        start_time = time.time()
        result = func(*args, **kwargs)
        end_time = time.time()
        duration = end_time - start_time
        # Only report function that are significant enough.
        if duration > 1e-3:
            logger.debug(f"{func.__name__} ran in: {duration} sec")
        return result

    return wrapper

in debug loglevel, as self.process_has_sdxl_refiner(p) will be interpreted as process_has_sdxl_refiner(self, p), but the function only accepts single param.

This PR fixes the issue by replacing self. with Script. in all callsites.

@huchenlei
Copy link
Collaborator Author

Sample stack trace:

*** Error running before_process_batch: D:\stable-diffusion-webui\extensions\sd-webui-controlnet\scripts\controlnet.py
    Traceback (most recent call last):
      File "D:\stable-diffusion-webui\modules\scripts.py", line 631, in before_process_batch
        script.before_process_batch(p, *script_args, **kwargs)
      File "D:\stable-diffusion-webui\extensions\sd-webui-controlnet\scripts\utils.py", line 90, in wrapper
        result = func(*args, **kwargs)
      File "D:\stable-diffusion-webui\extensions\sd-webui-controlnet\scripts\controlnet.py", line 986, in before_process_batch
        if self.process_has_sdxl_refiner(p):
      File "D:\stable-diffusion-webui\extensions\sd-webui-controlnet\scripts\utils.py", line 90, in wrapper
        result = func(*args, **kwargs)
    TypeError: Script.process_has_sdxl_refiner() takes 1 positional argument but 2 were given

@huchenlei huchenlei merged commit 7a4805c into Mikubill:main Sep 22, 2023
1 check passed
linjiX pushed a commit to diffus-me/sd-webui-controlnet that referenced this pull request Oct 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant