Skip to content
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

feat(ui): store workflow in generation tab images #6384

Merged
merged 9 commits into from
May 17, 2024

Conversation

psychedelicious
Copy link
Collaborator

@psychedelicious psychedelicious commented May 17, 2024

Summary

Note: This PR includes a failed attempt at this feature. The failed attempt was reverted.

feat(ui): store graph in image metadata
aecb224

The previous super-minimal implementation had a major issue - the saved workflow didn't take into account batched field values. When generating with multiple iterations or dynamic prompts, the same workflow with the first prompt, seed, etc was stored in each image.

As a result, when the batch results in multiple queue items, only one of the images has the correct workflow - the others are mismatched.

To work around this, we can store the graph in the image metadata (alongside the workflow, if generated via workflow editor). When loading a workflow from an image, we can choose to load the workflow or the graph, preferring the workflow.

Internally, we need to update images router image-saving services. The changes are minimal.

To avoid pydantic errors deserializing the graph, when we extract it from the image, we will leave it as stringified JSON and let the frontend's more sophisticated and flexible parsing handle it. The worklow is also changed to just return stringified JSON, so the API is consistent.

Related Issues / Discussions

QA Instructions

Generate an image in Generation tab. You should be able to load a workflow from it..

Merge Plan

n/a

Checklist

  • The PR has a short but descriptive title, suitable for a changelog
  • Tests added / updated (if applicable)
  • Documentation added / updated (if applicable)

@github-actions github-actions bot added frontend PRs that change frontend files api python PRs that change python files services PRs that change app services frontend-deps PRs that change frontend dependencies labels May 17, 2024
@psychedelicious psychedelicious force-pushed the psyche/feat/ui/save-workflow-in-image branch from aecb224 to 6d11f66 Compare May 17, 2024 08:15
@psychedelicious psychedelicious marked this pull request as ready for review May 17, 2024 09:00
The previous super-minimal implementation had a major issue - the saved workflow didn't take into account batched field values. When generating with multiple iterations or dynamic prompts, the same workflow with the first prompt, seed, etc was stored in each image.

As a result, when the batch results in multiple queue items, only one of the images has the correct workflow - the others are mismatched.

To work around this, we can store the _graph_ in the image metadata (alongside the workflow, if generated via workflow editor). When loading a workflow from an image, we can choose to load the workflow or the graph, preferring the workflow.

Internally, we need to update images router image-saving services. The changes are minimal.

To avoid pydantic errors deserializing the graph, when we extract it from the image, we will leave it as stringified JSON and let the frontend's more sophisticated and flexible parsing handle it. The worklow is also changed to just return stringified JSON, so the API is consistent.
Graph, metadata and workflow all take stringified JSON only. This makes the API consistent and means we don't need to do a round-trip of pydantic parsing when handling this data.

It also prevents a failure mode where an uploaded image's metadata, workflow or graph are old and don't match the current schema.

As before, the frontend does strict validation and parsing when loading these values.
@psychedelicious psychedelicious force-pushed the psyche/feat/ui/save-workflow-in-image branch from 06fff18 to 1fbf72c Compare May 17, 2024 22:49
@psychedelicious psychedelicious enabled auto-merge (rebase) May 17, 2024 22:49
@psychedelicious
Copy link
Collaborator Author

I did one more review and fixed an issue with metadata, then re-tested the functionality. All good.

@psychedelicious psychedelicious enabled auto-merge (rebase) May 17, 2024 23:03
@psychedelicious psychedelicious merged commit b0cfca9 into main May 17, 2024
14 checks passed
@psychedelicious psychedelicious deleted the psyche/feat/ui/save-workflow-in-image branch May 17, 2024 23:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api frontend PRs that change frontend files frontend-deps PRs that change frontend dependencies python PRs that change python files services PRs that change app services
Projects
None yet
3 participants