bmrlab / gendam

A privacy-first generative DAM
4 stars 2 forks source link

优化 library 切换,退出旧 library -> 加载新 library -> 重启 tasks #51

Closed web3nomad closed 1 week ago

web3nomad commented 3 weeks ago

有个可以优化的是:任务重试支持从第一个没成功的任务开始,也就是两种 mode,一种是 startover 另一种是 continue

zhuojg commented 2 weeks ago

逻辑已经实现了,有几个编码的小问题:

web3nomad commented 2 weeks ago

逻辑已经实现了,有几个编码的小问题:

  • 现在把逻辑实现在了ctx上,方便在应用启动 load_library 之后发起一个异步的 task 进行触发
  • 在 switch_current_library 的时候就不太这么触发,会阻塞用户操作(虽然也很快),因此切换 library 的触发逻辑写在前端了

确实,放在前端是更好的。 switch library 和启动 app 以后都靠前端来触发。

zhuojg commented 2 weeks ago

先把 ctx 上的 switch_current_library 做了一下拆分,分为了 quit_current_library 和 load_library

应用启动和切换 library 的时候,都在前端先 quit 再 load

这样的话,就可以把后端 load_library 等逻辑都去掉了,这个明天我改一下看看

web3nomad commented 2 weeks ago

@zhuojg 前端我改掉了 https://github.com/bmrlab/tauri-dam-test-playground/commit/dc0fc3d7775fe85840528496c9cc9e92cbe7e19f 现在是切换的时候先前端 quit, 然后页面刷新后再 set 新的 library

这样的话,就可以把后端 load_library 等逻辑都去掉了,这个明天我改一下看看

然后 👆 这里说的是后端改一下 👇 这部分对吧

https://github.com/bmrlab/tauri-dam-test-playground/blob/dc0fc3d7775fe85840528496c9cc9e92cbe7e19f/apps/api-server/src/routes/libraries/mod.rs#L81

这个我还没改,你来改改?

zhuojg commented 2 weeks ago

我在 7091483bc40fe1241191234b964f3cbc888e2261 整体改动了一下:

web3nomad commented 1 week ago

我周末这里调整了一下,先是 ctx 上分成了 load_library 和 unload_library 两个方法,也对应 2 个接口:

load_library 的顺序是

  1. init library (push db, start qdrant server)
  2. update library in ctx and in store
  3. check qdrant
  4. init task pool
  5. init download hub
  6. init ai handler
  7. trigger unfinished tasks

unload_library 的顺序是

  1. cancel tasks
  2. unload qdrant
  3. shutdown ai handler
  4. remove library from ctx and from store

然后

https://github.com/bmrlab/gendam/commit/2880a03578d8b1562958f6f908966e36dd57cf72 ... https://github.com/bmrlab/gendam/commit/a3b5b62e73cccb81a9deb04721d378e2b44a2e2c

先 close 了