From 2367f533674f358ed2deb0fdd0768293c5a694af Mon Sep 17 00:00:00 2001 From: psychedelicious <4822129+psychedelicious@users.noreply.github.com> Date: Mon, 26 Feb 2024 22:26:25 +1100 Subject: [PATCH] tidy(ui): remove unused metadata schemas --- .../web/src/features/nodes/types/metadata.ts | 28 --- invokeai/frontend/web/tests/metadata.ts | 174 ------------------ 2 files changed, 202 deletions(-) delete mode 100644 invokeai/frontend/web/src/features/nodes/types/metadata.ts delete mode 100644 invokeai/frontend/web/tests/metadata.ts diff --git a/invokeai/frontend/web/src/features/nodes/types/metadata.ts b/invokeai/frontend/web/src/features/nodes/types/metadata.ts deleted file mode 100644 index 3a87e96da3..0000000000 --- a/invokeai/frontend/web/src/features/nodes/types/metadata.ts +++ /dev/null @@ -1,28 +0,0 @@ -import { z } from 'zod'; - -import { zControlField, zIPAdapterField, zModelFieldBase, zT2IAdapterField } from './common'; - -export const zLoRAWeight = z.number().nullish(); -// #region Metadata-optimized versions of schemas -// TODO: It's possible that `deepPartial` will be deprecated: -// - https://github.com/colinhacks/zod/issues/2106 -// - https://github.com/colinhacks/zod/issues/2854 -export const zLoRAMetadataItem = z.object({ - lora: zModelFieldBase.deepPartial(), - weight: zLoRAWeight, -}); -const zControlNetMetadataItem = zControlField.merge(z.object({ control_model: z.unknown() })).deepPartial(); -const zIPAdapterMetadataItem = zIPAdapterField.merge(z.object({ ip_adapter_model: z.unknown() })).deepPartial(); -const zT2IAdapterMetadataItem = zT2IAdapterField.merge(z.object({ t2i_adapter_model: z.unknown() })).deepPartial(); -const zSDXLRefinerModelMetadataItem = z.unknown(); -const zModelMetadataItem = z.unknown(); -const zVAEModelMetadataItem = z.unknown(); -export type LoRAMetadataItem = z.infer; -export type ControlNetMetadataItem = z.infer; -export type IPAdapterMetadataItem = z.infer; -export type T2IAdapterMetadataItem = z.infer; -export type SDXLRefinerModelMetadataItem = z.infer; -export type ModelMetadataItem = z.infer; -export type VAEModelMetadataItem = z.infer; -// #endregion - diff --git a/invokeai/frontend/web/tests/metadata.ts b/invokeai/frontend/web/tests/metadata.ts deleted file mode 100644 index c694ce67c7..0000000000 --- a/invokeai/frontend/web/tests/metadata.ts +++ /dev/null @@ -1,174 +0,0 @@ -export default {}; - -// python metadata parsing tests to rebuild - -// # def test_is_good_metadata_unchanged(): -// # parsed_metadata = metadata_service._parse_invokeai_metadata(valid_metadata) - -// # expected = deepcopy(valid_metadata) - -// # assert expected == parsed_metadata - -// # def test_can_parse_missing_session_id(): -// # metadata_missing_session_id = deepcopy(valid_metadata) -// # del metadata_missing_session_id["session_id"] - -// # expected = deepcopy(valid_metadata) -// # del expected["session_id"] - -// # parsed_metadata = metadata_service._parse_invokeai_metadata( -// # metadata_missing_session_id -// # ) -// # assert metadata_missing_session_id == parsed_metadata - -// # def test_can_parse_invalid_session_id(): -// # metadata_invalid_session_id = deepcopy(valid_metadata) -// # metadata_invalid_session_id["session_id"] = 123 - -// # expected = deepcopy(valid_metadata) -// # del expected["session_id"] - -// # parsed_metadata = metadata_service._parse_invokeai_metadata( -// # metadata_invalid_session_id -// # ) -// # assert expected == parsed_metadata - -// # def test_can_parse_missing_node(): -// # metadata_missing_node = deepcopy(valid_metadata) -// # del metadata_missing_node["node"] - -// # expected = deepcopy(valid_metadata) -// # del expected["node"] - -// # parsed_metadata = metadata_service._parse_invokeai_metadata(metadata_missing_node) -// # assert expected == parsed_metadata - -// # def test_can_parse_invalid_node(): -// # metadata_invalid_node = deepcopy(valid_metadata) -// # metadata_invalid_node["node"] = 123 - -// # expected = deepcopy(valid_metadata) -// # del expected["node"] - -// # parsed_metadata = metadata_service._parse_invokeai_metadata(metadata_invalid_node) -// # assert expected == parsed_metadata - -// # def test_can_parse_missing_node_id(): -// # metadata_missing_node_id = deepcopy(valid_metadata) -// # del metadata_missing_node_id["node"]["id"] - -// # expected = deepcopy(valid_metadata) -// # del expected["node"]["id"] - -// # parsed_metadata = metadata_service._parse_invokeai_metadata( -// # metadata_missing_node_id -// # ) -// # assert expected == parsed_metadata - -// # def test_can_parse_invalid_node_id(): -// # metadata_invalid_node_id = deepcopy(valid_metadata) -// # metadata_invalid_node_id["node"]["id"] = 123 - -// # expected = deepcopy(valid_metadata) -// # del expected["node"]["id"] - -// # parsed_metadata = metadata_service._parse_invokeai_metadata( -// # metadata_invalid_node_id -// # ) -// # assert expected == parsed_metadata - -// # def test_can_parse_missing_node_type(): -// # metadata_missing_node_type = deepcopy(valid_metadata) -// # del metadata_missing_node_type["node"]["type"] - -// # expected = deepcopy(valid_metadata) -// # del expected["node"]["type"] - -// # parsed_metadata = metadata_service._parse_invokeai_metadata( -// # metadata_missing_node_type -// # ) -// # assert expected == parsed_metadata - -// # def test_can_parse_invalid_node_type(): -// # metadata_invalid_node_type = deepcopy(valid_metadata) -// # metadata_invalid_node_type["node"]["type"] = 123 - -// # expected = deepcopy(valid_metadata) -// # del expected["node"]["type"] - -// # parsed_metadata = metadata_service._parse_invokeai_metadata( -// # metadata_invalid_node_type -// # ) -// # assert expected == parsed_metadata - -// # def test_can_parse_no_node_attrs(): -// # metadata_no_node_attrs = deepcopy(valid_metadata) -// # metadata_no_node_attrs["node"] = {} - -// # expected = deepcopy(valid_metadata) -// # del expected["node"] - -// # parsed_metadata = metadata_service._parse_invokeai_metadata(metadata_no_node_attrs) -// # assert expected == parsed_metadata - -// # def test_can_parse_array_attr(): -// # metadata_array_attr = deepcopy(valid_metadata) -// # metadata_array_attr["node"]["seed"] = [1, 2, 3] - -// # expected = deepcopy(valid_metadata) -// # del expected["node"]["seed"] - -// # parsed_metadata = metadata_service._parse_invokeai_metadata(metadata_array_attr) -// # assert expected == parsed_metadata - -// # def test_can_parse_invalid_dict_attr(): -// # metadata_invalid_dict_attr = deepcopy(valid_metadata) -// # metadata_invalid_dict_attr["node"]["seed"] = {"a": 1} - -// # expected = deepcopy(valid_metadata) -// # del expected["node"]["seed"] - -// # parsed_metadata = metadata_service._parse_invokeai_metadata( -// # metadata_invalid_dict_attr -// # ) -// # assert expected == parsed_metadata - -// # def test_can_parse_missing_image_field_image_type(): -// # metadata_missing_image_field_image_type = deepcopy(valid_metadata) -// # del metadata_missing_image_field_image_type["node"]["image"]["image_type"] - -// # expected = deepcopy(valid_metadata) -// # del expected["node"]["image"] - -// # parsed_metadata = metadata_service._parse_invokeai_metadata( -// # metadata_missing_image_field_image_type -// # ) -// # assert expected == parsed_metadata - -// # def test_can_parse_invalid_image_field_image_type(): -// # metadata_invalid_image_field_image_type = deepcopy(valid_metadata) -// # metadata_invalid_image_field_image_type["node"]["image"][ -// # "image_type" -// # ] = "bad image type" - -// # expected = deepcopy(valid_metadata) -// # del expected["node"]["image"] - -// # parsed_metadata = metadata_service._parse_invokeai_metadata( -// # metadata_invalid_image_field_image_type -// # ) -// # assert expected == parsed_metadata - -// # def test_can_parse_invalid_latents_field_latents_name(): -// # metadata_invalid_latents_field_latents_name = deepcopy(valid_metadata) -// # metadata_invalid_latents_field_latents_name["node"]["latents"] = { -// # "latents_name": 123 -// # } - -// # expected = deepcopy(valid_metadata) - -// # parsed_metadata = metadata_service._parse_invokeai_metadata( -// # metadata_invalid_latents_field_latents_name -// # ) - -// # assert expected == parsed_metadata