-
Notifications
You must be signed in to change notification settings - Fork 27.3k
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
feature/add-model-to-log-file #14663
feature/add-model-to-log-file #14663
Conversation
- write these in the CSV log file - ensure old log files are updated w.r.t delimiter count
no objection to what the PR is trying to achieve |
I just went through the diff. You're right in that it's going to merge conflict, luckily it seems fairly straightforward to resolve. |
This comment was marked as resolved.
This comment was marked as resolved.
How so? I added code to ensure CSV files are always synced. In fact, it should work whenever any number of fields are added. I tested this. See: stable-diffusion-webui/modules/ui_common.py Lines 103 to 108 in 315e40a
which calls stable-diffusion-webui/modules/ui_common.py Lines 39 to 59 in 315e40a
|
ahh my bad, misread the code |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a couple nit picks on my part. By no means do you have to make these changes; these are mostly personal preference if anything.
One other thing I noticed is that we're importing import csv
in multiple functions after this change. It may be better if we move that import to the top of the file instead of having it inside the functions.
@@ -36,6 +36,29 @@ def plaintext_to_html(text, classname=None): | |||
return f"<p class='{classname}'>{content}</p>" if classname else f"<p>{content}</p>" | |||
|
|||
|
|||
def update_logfile(logfile_path, fields): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd recommend using typehints whenever adding new functions. The repo doesn't have them now but it would definitely be nice if new functions were implemented with them for functions/classes.
Also a simple docstring just to satisfy linters wouldn't hurt. This is just an example description of the function so if you can think of a better one then feel free to modify it.
-def update_logfile(logfile_path, fields):
+def update_logfile(logfile_path: str, fields: list[str]) -> None:
+ """Updates existing log file rows to match current log file column count."""
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
agreed, I mostly wanted to retain the style of the surrounding, but if @AUTOMATIC1111 is in agreement, I'd be happy to add the typehints
for row in rows[1:]: | ||
while len(row) < len(fields): | ||
row.append("") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a bit nit picky on my part but this approach could be a bit more pythonic.
- for row in rows[1:]:
- while len(row) < len(fields):
- row.append("")
+ rows = [row + ([""] * (len(fields) - len(row))) for row in rows[1:]]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm I'll have to push back on this, while list comprehensions are usually my preference, this becomes nigh unreadable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm I'll have to push back on this, while list comprehensions are usually my preference, this becomes nigh unreadable.
Yeah fair enough. I got a bit carried away code golfing it seems. :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Haha it happens, I appreciate your input though 👍
I debated this point a bit, I noticed csv was imported in the method where it was used so I tried to stay with the style, but I do agree a top-level import would be preferred. I defer to @AUTOMATIC1111's judgement. |
Top level import is fine. I personally would rather not have If you think it's needed, then at least it should not write to disk when there are no changes in header (which is almost always). |
Cool, I've done the following:
|
cc @AUTOMATIC1111 should be ready for review/merge now! |
Does this solve the issue of inserting the last used checkpoint instead of the original/first one? 🤔 |
Description
When trying to reproduce an image, the information stored in "log.csv" is very useful. Unfortunately it's missing one key bit of information: what model you used.
This PR adds support for storing model information (name and hash) in the "log.csv" file.
It also takes care of the scenario where there's a preexisting "log.csv" file that needs to be migrated.
Here's an issue that brings this up: #5021
Screenshots/videos:
Here's the file read as a spreadsheet (I've omitted the prompt column).
Checklist: