-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathusing_pydantic.py
49 lines (43 loc) · 1.08 KB
/
using_pydantic.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# -*- coding: utf-8 -*-
# SPDX-License-Identifier: MIT
#
# The Comfy Catapult project requires contributions made to this file be licensed
# under the MIT license or a compatible open source license. See LICENSE.md for
# the license text.
# SNIPPETSTART
from comfy_catapult.comfy_schema import APIWorkflow
api_workflow_json_str: str = """
{
"1": {
"inputs": {
"image": "{remote_image_path} [input]",
"upload": "image"
},
"class_type": "LoadImage",
"_meta": {
"title": "My Loader Title"
}
},
"25": {
"inputs": {
"images": [
"8",
0
]
},
"class_type": "PreviewImage",
"_meta": {
"title": "Preview Image"
}
}
}
"""
api_workflow: APIWorkflow = APIWorkflow.model_validate_json(
api_workflow_json_str)
# Or, if you have a APIWorkflow, and you want to deal with a dict instead:
api_workflow_dict = api_workflow.model_dump()
# Or, back to json:
api_workflow_json = api_workflow.model_dump_json()
# See comfy_catapult/comfyui_schema.py for the schema definition.
print(api_workflow_json)
# SNIPPETEND