-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Support legacy dream.py
API
#866
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
Comments
As mentioned in discord - I do think it's worth establishing expectations that new features may not receive support in the old api unless we have an "Old API maintainer". And, if we do have that (perhaps CapableWeb?), we should formalize it as REST API support. |
Could also have a separate repo[1] in this org for "Legacy API" or maybe even "Simplified API" or some such. [1] Which would provide an opportunity to delete all of the bits which aren't directly related to the HTTP API, making it easier to maintain |
Yeah, that makes sense I think. Having I'd be fine with maintaining this legacy interface, as I'm depending on it myself.
We could, but then I might just fork the repository into my own org and maintain it that way. It's simpler for maintenance to keep it in the same repository, won't add burden to anyone else if I'm the one maintaining it and as mentioned above, changes related to anything else but the API interface would benefit the legacy interface without further changes too, which is beneficial for the "legacy API" users. |
I think there are a number of projects which depend on HTTP API, so it'd be great for all if you were willing to keep it maintained and if we keep it in this repo or at least this org. As time goes on and we refine the backend with which the API interfaces, it will hopefully become easier and easier to maintain as well. |
My point about creating a new repo under this org really works best if what's being taken from here and put in the new repo is significantly decoupled from this repo. If the dependencies are pretty tight, then yeah, you're just buying trouble. |
@CapableWeb Are you volunteering to be the “legacy maintainer?” I’m happy to have to take that on. |
Yes, I'm volunteering for this, granted the file can be kept in this repository in order to make incompatibilities easier to spot and lessen the complexity compared to having the "legacy API" being in a separate repository.
Yeah, agreed. Maybe in the future it won't, but for now the only realistic option would be to keep it in this repository. So if everyone is fine with it, I'll base my work from |
That’s wonderful. Would you be willing to be added to the team as a developer or triager? The latter can assign bug reports and the like but doesn’t have commit privileges. Whatever you’re comfortable with. |
Just following up. Do you want to be added to the invoke-ai organization? |
@lstein sorry, sure thing! Being added as a |
i would like to push back on this being a "legacy" feature, as i have been in multiple situations now where i've got the WebUI running on a remote service (runpod.io) and want to be able to script a batch of tests with different parameters without logging in the runpod.io box, manually killing the web ui, and starting dream.py by hand. i have commented on this elsewhere, and i'm willing to be the maintainer of such an API - but only a minimal version, eg while |
@damian0815 the name |
ahha gotcha |
For whoever is interested, opened up a PR to recover the old dream.py HTTP API (which basically accepted simple HTTP POST requests): #1070 @damian0815 you might be interested to check that out, give it a try and see if it works for your purposes too. It works for me, but very possible I've missed something you're relying on. |
I've spent several weeks now working on a new API/workflow that should eventually be feature-compatible with the old API (though not functionally identical, especially regarding streamed responses): #1047. It does support RESTful usage though, produces an OpenAPI spec, etc. |
@Kyle0654 sounds great for a lot of use cases, but seems the API interface would be fundamentally different, at least judging by the example in static/dream_web/test.html The "legacy" API (old dream.py) was very simple and stateless. Do a POST request, receive streamed response about progress and finally a In contrast, the new API seems to require 1) create a session 2) subscribe to the session via WebSockets to receive the events and 3) call "invoke" to actually start the response. This adds another protocol on top of already using HTTP + it is now stateful. I guess in the future the "legacy" API could do those things but still expose the good'ol POST request < get response interface, handling the stateness for the API users. (Bit OT, but not sure I share your definition of REST as being "stateless" would be a big part of it [in my opinion], and I didn't see a way of using the new API in a stateless manner, it quite literally requires a |
I had worked really hard to rebuild the old API in Flask a while ago, but the streaming response blocked execution, which made request queueing not work. It's probably solvable, but was also tightly coupled to other parts of the code, and was tough to pull apart/maintain. A lot of the code accidentally made it in (this PR deletes it): https://github.com/invoke-ai/InvokeAI/blob/main/server/application.py It's probably possible to build a streaming response API in FastAPI for compatibility. I think the big challenge is the async/sync boundary, which I'm not as familiar with yet in Python. This PR is draft to get feedback like this, and solicit contribution =). I'd also worry about long-running requests timing out in different hosting scenarios. =/ I also regret using the word "session", but don't have a better name in mind x.x. It's really just a resource representing the node graph and execution history. There shouldn't be any implication that it's a stateful application session on a server - the client isn't remembered at all for the HTTP interface (and the socket.io interface is just for signaling changes - you could poll to accomplish the same thing). I just couldn't come up with a better name for "graph+history". The "create session from graph" API has a query parameter to "invoke now". It might be possible to add another parameter for "wait for results" or "stream progress and results", though that feels like it'd become a large API to maintain. |
I'm searching for documentation on how to use an API with InvokeAI. Is there a PR which summarizes the current state of the "new" API, namely what is described here:
I see some issues listed here, but not a working PR which indicates the work that is being done to support the legacy dream.py code, or the code which is for the "new" API. I would benefit from having those added to this issue report if that's possible. edit: I see the new work here (though the PR does not yet have, IMHO, documentation on how to use it, which is what @lstein asked for): #1070. But, I'm unclear how to investigate the "new" API using websockets; does this require reading through the code? |
@xrd , We have 3 APIs - let's call them "legacy", "current" and "nodes". "Legacy" is HTTP only. There was a volunteer (not a core contributor IIRC) who was going to maintain this but I'm not sure what its state is. It is not documented AFAIK. "Current" is what the web UI uses now. It is mostly socket.io, with some HTTP for transferring images and potentially larger files. It is also not documented because it was not built to be consumed by anything other than the web UI, and it has been changed constantly since it was written. "Nodes" is a future API, mostly built, but to which we have not yet migrated. It is intended to be consumed by external services and is the one you described where processing is described by a session node-link graph. You can find more information about it here: #1047 So at this moment, we do not provide an API that is really suitable for consumption by an external service, certainly not one that is supported. However, we definitely want to support other services by providing a robust web API. We will be migrating the UI over fairly soon - after the upcoming v2.2 release is the plan - and the nodes API will be released alongside the mgirated web UI. Hope that helps and sorry we do not have a good solution at the moment. |
@psychedelicious This really helps a lot. Thank you. |
Is your feature request related to a problem? Please describe.
Currently building my own UI using the HTTP API provided by
dream.py
. It's being deprecated now in favor of a socket-based API, which makes it slightly harder to use for my purposes.Describe the solution you'd like
Move the old
dream.py
HTTP API into alegacy
directory I can help maintain. It'll focus on providing backwards compatibility without any new features unless it makes it still backwards compatible. Discussed as a possible solution with @psychedeliciousDescribe alternatives you've considered
Additional context
Initially raised the conversation via Discord (starting here: https://discord.com/channels/1020123559063990373/1020123559831539744/1025351359446388787)
Message Log:
The text was updated successfully, but these errors were encountered: