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): metadata recall backcompat #5782

Merged
merged 19 commits into from
Feb 26, 2024

Conversation

psychedelicious
Copy link
Collaborator

@psychedelicious psychedelicious commented Feb 23, 2024

Description

Main changes:

feat(api): add MM get_by_attrs route

Gets the first model that matches the given name, base and type. Raises 404 if there isn't one.

This will be used for backwards compatibility with old metadata.

feat(ui): refactor metadata handling (again)

Add concepts for metadata handlers. Handlers include parsers, recallers and validators for different metadata types:

  • Parsers parse a raw metadata object of any shape to a structured object.
  • Recallers load the parsed metadata into state. Recallers are optional, as some metadata types don't need to be loaded into state.
  • Validators provide an additional layer of validation before recalling the metadata. This is needed because a metadata object may be valid, but not able to be recalled due to some other requirement, like base model compatibility. Validators are optional.

Sometimes metadata is not a single object but a list of items - like LoRAs. Metadata handlers may implement an optional set of "item" handlers which operate on individual items in the list.

Parsers and validators are async to allow fetching additional data, like a model config. Recallers are synchronous.

The these handlers are composed into a public API, exported as a handlers object. Besides the handlers functions, a metadata handler set includes:

  • A function to get the label of the metadata type.
  • An optional function to render the value of the metadata type.
  • An optional function to render the item value of the metadata type.

QA Instructions, Screenshots, Recordings

Recalling metadata should work, both both v3 and v4. I will be doing another pass over this functionality soon - please report any issues you run into.

TODO (future PR):

  • Add tests for metadata parsing. This requires setting up some API mocks. I'll probably use msw for this but haven't gotten to it yet.

Merge Plan

This PR can be merged when approved.

@github-actions github-actions bot added api python PRs that change python files frontend PRs that change frontend files labels Feb 23, 2024
@psychedelicious psychedelicious force-pushed the feat/ui/metadata-backcompat-2 branch 2 times, most recently from ebfcbf1 to 907dcf7 Compare February 25, 2024 23:27
@psychedelicious psychedelicious marked this pull request as ready for review February 26, 2024 11:14
Gets the first model that matches the given name, base and type. Raises 404 if there isn't one.

This will be used for backwards compatibility with old metadata.
Add concepts for metadata handlers. Handlers include parsers, recallers and validators for different metadata types:
- Parsers parse a raw metadata object of any shape to a structured object.
- Recallers load the parsed metadata into state. Recallers are optional, as some metadata types don't need to be loaded into state.
- Validators provide an additional layer of validation before recalling the metadata. This is needed because a metadata object may be valid, but not able to be recalled due to some other requirement, like base model compatibility. Validators are optional.

Sometimes metadata is not a single object but a list of items - like LoRAs. Metadata handlers may implement an optional set of "item" handlers which operate on individual items in the list.

Parsers and validators are async to allow fetching additional data, like a model config. Recallers are synchronous.

The these handlers are composed into a public API, exported as a `handlers` object. Besides the handlers functions, a metadata handler set includes:
- A function to get the label of the metadata type.
- An optional function to render the value of the metadata type.
- An optional function to render the _item_ value of the metadata type.
…nd to multiple of 8

This allows image dimensions that are not multiples of 8 to still be recalled with best effort.
When we retrieve a list of models, upsert that data into the `getModelConfig` and `getModelConfigByAttrs` query caches.

With this change, calls to those two queries are almost always going to be free, because their caches will already have all models in them. The exception is queries for models that no longer exist.
- Move some files around
- Use util to extract key and base from model config
@psychedelicious psychedelicious force-pushed the feat/ui/metadata-backcompat-2 branch from db4d127 to 32a9ed2 Compare February 26, 2024 11:16
@github-actions github-actions bot added the invocations PRs that change invocations label Feb 26, 2024
Model metadata includes the main model, VAE and refiner model.

These used full model configs, as returned by the server, as their metadata type.

LoRA and control adapter metadata only use the metadata identifier.

This created a difference in handling. After parsing a model/vae/refiner, we have its name and can display it. But for LoRAs and control adapters, we only have the model key and must query for the full model config to get the name.

This change makes main model/vae/refiner metadata only have the model key, like LoRAs and control adapters.

The render function is now async so fetching can occur within it. All metadata fields with models now only contain the identifier, and fetch the model name to render their values.
These are the same as the existing control adapter types, but the model field is non-nullable, simplifying handling of these objects.
@hipsterusername hipsterusername merged commit 3efd946 into next Feb 26, 2024
7 of 8 checks passed
@hipsterusername hipsterusername deleted the feat/ui/metadata-backcompat-2 branch February 26, 2024 19:49
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 invocations PRs that change invocations python PRs that change python files
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants