mrhan1993 / Fooocus-API

FastAPI powered API for Fooocus
GNU General Public License v3.0
583 stars 154 forks source link

job-history query returns all jobs regardless of page or page_size parameter #354

Open lux4rd0 opened 5 months ago

lux4rd0 commented 5 months ago

Hello! Loving this API!! I'm building a quick application to support some of my workflows, and I started running into issues when trying to manage the job history endpoint. No matter what I send to it - it returns all jobs. So that:

http://ai01.tylephony.com:8888/v1/generation/job-history?page=1&page_size=2

Still returns:

{
  "queue": [],
  "history": [
    {
      "job_id": "14fd735a-2bd2-47e3-9601-ae74b7458bca",
      "is_finished": true
    },
    {
      "job_id": "70dd1a4f-33a9-45f6-adb2-a15b7f28673d",
      "is_finished": true
    },
    {
      "job_id": "9a3209ca-f818-41ac-af5f-ee734b47e286",
      "is_finished": true
    },
    {
      "job_id": "5e817ed0-896b-4514-89dc-ec78ef852cbb",
      "is_finished": true
    },
    {
      "job_id": "81e5bfff-a4e9-4d37-8694-b72105be142a",
      "is_finished": true
    },
    {
      "job_id": "7ee5010f-5aee-494a-a994-f3f5c43e42f8",
      "is_finished": true
    },
    {
      "job_id": "fd150e73-e580-43ab-9997-c3f63507b437",
      "is_finished": true
    }
  ]
}

I was hoping that by sending different pages and page sizes, I could paginate dynamically, but it looks like I'll need to handle the full list myself. Do you know if this is a bug?

Running the latest release, v0.4.0.6, on Windows.

mrhan1993 commented 5 months ago

paginate dynamically is supported only if it is started with the --presistent parameter.

lux4rd0 commented 4 months ago

Thanks! Will try it out!

lux4rd0 commented 4 months ago

Using "--persistent" as a flag removes all history from being displayed:

{
  "queue": [
    {
      "job_id": "4b1b9e6f-2fb9-40c8-8036-a38bfa5517d1",
      "is_finished": false
    },
    {
      "job_id": "4406adf6-ca38-40c4-b992-edf496c51dae",
      "is_finished": false
    },
    {
      "job_id": "0c58643d-3429-4cf9-8c51-74935b8c36c4",
      "is_finished": false
    },
    {
      "job_id": "c2d2c673-3dd5-42bb-abab-439bab40c4ef",
      "is_finished": false
    }
  ],
  "history": []
}

There should be jobs listed in this history JSON array.

mrhan1993 commented 4 months ago

Recommend new project FooocusAPI to you

BaiMoHan commented 3 months ago

Using "--persistent" as a flag removes all history from being displayed:

{
  "queue": [
    {
      "job_id": "4b1b9e6f-2fb9-40c8-8036-a38bfa5517d1",
      "is_finished": false
    },
    {
      "job_id": "4406adf6-ca38-40c4-b992-edf496c51dae",
      "is_finished": false
    },
    {
      "job_id": "0c58643d-3429-4cf9-8c51-74935b8c36c4",
      "is_finished": false
    },
    {
      "job_id": "c2d2c673-3dd5-42bb-abab-439bab40c4ef",
      "is_finished": false
    }
  ],
  "history": []
}

There should be jobs listed in this history JSON array.

remove all? I cannot understand it. I started the server with the "--persistent" but no records in database.db

mrhan1993 commented 3 months ago

@BaiMoHan @lux4rd0 When '-- persistent' is not used, the history is just a list in memory that disappears after the program is closed. In fact, the current version does not have the logic to delete records from the database.

BaiMoHan commented 3 months ago

@BaiMoHan @lux4rd0 When '-- persistent' is not used, the history is just a list in memory that disappears after the program is closed. In fact, the current version does not have the logic to delete records from the database.

Yes, I have reviewed some code, but not all of it. I found some bugs when saving records to the database. I am trying to fix it. Maybe will open one issue/pr later.