Closed ldavis9000aws closed 4 months ago
I was trying to use the "--persistent" switch and encountered several issues related to missing columns in the generate_record
table. These issues were primarily caused by mismatches between the ORM model definitions and the actual database schema. Below is a summary of the problems faced and the steps taken to resolve them. I'm not a developer, bu
Invalid Keyword Argument: save_meta
When using the --persistent
switch, the following error occurred:
ERROR [Fooocus] Worker error: 'save_meta' is an invalid keyword argument for GenerateRecord
Cause: The GenerateRecord
class in sql_client.py
lacked a definition for the save_meta
attribute, resulting in a mismatch when saving records.
Invalid Keyword Argument: meta_scheme
A subsequent error appeared for another missing attribute:
ERROR [Fooocus] Worker error: 'meta_scheme' is an invalid keyword argument for GenerateRecord
Cause: Similar to the previous issue, the meta_scheme
attribute was missing in the GenerateRecord
class.
Invalid Keyword Argument: save_name
Another missing attribute error:
ERROR [Fooocus] Worker error: 'save_name' is an invalid keyword argument for GenerateRecord
Cause: The save_name
attribute was also not defined in the GenerateRecord
class.
SQLite Operational Error: Missing Columns After adding the attributes to the ORM model, an error related to the actual database schema was encountered:
[2024-07-02 19:16:06] ERROR [Fooocus] Worker error: (sqlite3.OperationalError) table generate_record has no column named save_meta
Add Missing Attributes to GenerateRecord
Class
The following attributes were added to the GenerateRecord
class in sql_client.py
:
class GenerateRecord(Base):
# Existing definitions...
save_meta: Mapped[Optional[bool]] = mapped_column(Boolean, nullable=True)
meta_scheme: Mapped[Optional[str]] = mapped_column(Text, nullable=True)
save_name: Mapped[Optional[str]] = mapped_column(Text, nullable=True)
# Full class definition omitted for brevity...
Update Database Schema The database schema was updated to include the new columns by running the following SQL commands:
ALTER TABLE generate_record ADD COLUMN save_meta BOOLEAN;
ALTER TABLE generate_record ADD COLUMN meta_scheme TEXT;
ALTER TABLE generate_record ADD COLUMN save_name TEXT;
In my case, I just manually added them using DB Browser for SQLLite.
The Fooocus API can now successfully save history to the database when using the --persistent
switch.
Example:
Interested in trying a rewrite of FooocusAPI
Changing the database structure is still complicated for users, so my choice is to drop these new fields。thx for your work on this issue
Changing the database structure is still complicated for users, so my choice is to drop these new fields。thx for your work on this issue
Doesn't this mean custom names for saving images and metadata for previously generated images won't be stored in the history database? This is important for my specific needs. I was expecting to be able to query this data through the job history endpoint. It seems like the original goal of storing job history was to provide this kind of information.
I understand that your solution would address the issue by dropping the new fields, but an alternative might be to use a script that checks if the database schema is up to date and updates it if necessary during the API startup. This way, we wouldn't need any user interaction.
Currently, the persistent switch hasn't been working, causing all job history to be lost whenever the API is shut down. Going this route would make sure detailed job history is preserved.
No, it doesn't lose any useful information. You can get the final file name from result_url, while save_meta is just true or false, and meta_scheme is just fooocus or a111
Interested in trying a rewrite of FooocusAPI
Ha! I wish I would've seen that repo earlier, lol. I'll try it out in the next day or so.
I think is a better version
@mrhan1993 So I tried out the newer version and there are a few things I noticed:
It seems like the new API is returning the image directly in the response body rather than just a URL or metadata about the image. This seems to be causing the character limit of the OpenAI Assistants API I'm using.
Can the response be modified to work like the original rather than sending back the entire image? I would open an issue on the new repo, but doesn't look like there's an option to do so.
Okay, I understand your point. It was indeed my oversight. I will make the necessary adjustments to this section.
@ldavis9000aws I modified the return logic, now if you use the default parameters, will return a json, but the data format will be somewhat different, you may need to pay attention to
Hello,
I get the following error whenever I generate an image via the Fooocus-API and use the "--persistent" switch:
[2024-07-02 18:10:49] ERROR [Fooocus] Worker error: 'save_meta' is an invalid keyword argument for GenerateRecord
The image generates, but there is no job history when you query historical job data. I updated to the latest version, but the issue is still there.