Configure ruff and black for linting#52
Open
akx wants to merge 6 commits into
Open
Conversation
Merged
Merged
dcbb3e1 to
235d2a1
Compare
Contributor
Author
|
@benjaminaubin rebased |
4dc10d5 to
e943461
Compare
Contributor
Author
|
@benjaminaubin Rebased again 😁 I also enabled import sorting via Ruff (ref. #59). |
6bd67ab to
445ae99
Compare
Contributor
Author
f85b1e8 to
46f6ec0
Compare
Contributor
Author
|
Rebased once again. |
Contributor
Author
|
Rebased 🍂 |
a0ff858 to
638bb54
Compare
Contributor
Author
|
Rebased on 059d8e9. |
akx
commented
Nov 22, 2023
| # batch_idx > 5 and | ||
| self.max_images > 0 | ||
| ): | ||
| logger = type(pl_module.logger) |
akx
commented
Nov 22, 2023
| ckpt_resume_path = opt.resume_from_checkpoint | ||
|
|
||
| if not "devices" in trainer_config and trainer_config["accelerator"] != "gpu": | ||
| if "devices" not in trainer_config and trainer_config["accelerator"] != "gpu": |
Contributor
Author
There was a problem hiding this comment.
x not in y is idiomatic.
akx
commented
Nov 22, 2023
| try: | ||
| group_name = nowname.split(now)[-1].split("-")[1] | ||
| except: | ||
| except Exception: |
Contributor
Author
There was a problem hiding this comment.
except: is dangerous as it catches SystemExits and KeyboardInterrupts.
akx
commented
Nov 22, 2023
Comment on lines
-21
to
+26
| print(f"sigmas after discretization, before pruning img2img: ", sigmas) | ||
| print("sigmas after discretization, before pruning img2img: ", sigmas) | ||
| sigmas = torch.flip(sigmas, (0,)) | ||
| sigmas = sigmas[: max(int(self.strength * len(sigmas)), 1)] | ||
| print("prune index:", max(int(self.strength * len(sigmas)), 1)) | ||
| sigmas = torch.flip(sigmas, (0,)) | ||
| print(f"sigmas after pruning: ", sigmas) | ||
| print("sigmas after pruning: ", sigmas) |
akx
commented
Nov 22, 2023
Comment on lines
-476
to
-443
| def get_interactive_image() -> Image.Image: | ||
| image = st.file_uploader("Input", type=["jpg", "JPEG", "png"]) | ||
| if image is not None: | ||
| image = Image.open(image) | ||
| if not image.mode == "RGB": | ||
| image = image.convert("RGB") | ||
| return image | ||
|
|
||
|
|
akx
commented
Nov 22, 2023
| with record_function("Default detailed stats"): | ||
| for _ in range(25): | ||
| o = F.scaled_dot_product_attention(query, key, value) | ||
| _o = F.scaled_dot_product_attention(query, key, value) |
Contributor
Author
There was a problem hiding this comment.
Unused local, mark it as such.
akx
commented
Nov 22, 2023
|
|
||
| with torch.no_grad(): | ||
| with autocast(device) as precision_scope: | ||
| with autocast(device): |
akx
commented
Nov 22, 2023
| print(key, batch[key].shape) | ||
| elif isinstance(batch[key], list): | ||
| print(key, [len(l) for l in batch[key]]) | ||
| print(key, [len(lst) for lst in batch[key]]) |
Contributor
Author
There was a problem hiding this comment.
l is easily confusable for I and 1.
akx
commented
Nov 22, 2023
Comment on lines
-248
to
+254
| denoiser = lambda input, sigma, c: self.denoiser( | ||
| self.model, input, sigma, c, **kwargs | ||
| ) | ||
| def denoiser(input, sigma, c): | ||
| return self.denoiser(self.model, input, sigma, c, **kwargs) |
Contributor
Author
There was a problem hiding this comment.
Don't use a lambda where a def will do. (That said, this is really just partial()...)
akx
commented
Nov 22, 2023
Comment on lines
-58
to
-59
| # from .diffusionmodules.util import mixed_checkpoint as checkpoint | ||
|
|
akx
commented
Nov 22, 2023
|
|
||
| # compute in_ch_mult, block_in and curr_res at lowest res | ||
| in_ch_mult = (1,) + tuple(ch_mult) | ||
| # compute block_in and curr_res at lowest res |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR configures linting with the Ruff linter (and the Black formatter that's already in use in the repository) to be easily runnable with pre-commit. It also adds a GitHub Actions workflow to run those checks for every pushed commit.
It then fixes the issues that the default set of configuration for Ruff (with small changes, see pyproject.toml) notes.
This PR includes #146 and #147 because they would otherwise cause lint errors.