aboutsummaryrefslogtreecommitdiff
path: root/modules/api/processing.py
diff options
context:
space:
mode:
authorJonathan <jbelt021@fiu.edu>2022-10-17 03:18:41 -0400
committerAUTOMATIC1111 <16777216c@gmail.com>2022-10-17 11:34:22 +0300
commit832b490e5173f78c4d3aa7ca9ca9ac794d140664 (patch)
treec06a0996d1b70379f2c6e24bf460fbfe1559e2b5 /modules/api/processing.py
parentf3fe487e6340b1a2db5d2e2ddf5ae885b4eef54c (diff)
Update processing.py
Diffstat (limited to 'modules/api/processing.py')
-rw-r--r--modules/api/processing.py41
1 files changed, 5 insertions, 36 deletions
diff --git a/modules/api/processing.py b/modules/api/processing.py
index 459a8f49..4c3d0bd0 100644
--- a/modules/api/processing.py
+++ b/modules/api/processing.py
@@ -16,46 +16,15 @@ class ModelDef(BaseModel):
class pydanticModelGenerator:
"""
- Takes source_data:Dict ( a single instance example of something like a JSON node) and self generates a pythonic data model with Alias to original source field names. This makes it easy to popuate or export to other systems yet handle the data in a pythonic way.
- Being a pydantic datamodel all the richness of pydantic data validation is available and these models can easily be used in FastAPI and or a ORM
-
- It does not process full JSON data structures but takes simple JSON document with basic elements
-
- Provide a model_name, an example of JSON data and a dict of type overrides
-
- Example:
-
- source_data = {'Name': '48 Rainbow Rd',
- 'GroupAddressStyle': 'ThreeLevel',
- 'LastModified': '2020-12-21T07:02:51.2400232Z',
- 'ProjectStart': '2020-12-03T07:36:03.324856Z',
- 'Comment': '',
- 'CompletionStatus': 'Editing',
- 'LastUsedPuid': '955',
- 'Guid': '0c85957b-c2ae-4985-9752-b300ab385b36'}
-
- source_overrides = {'Guid':{'type':uuid.UUID},
- 'LastModified':{'type':datetime },
- 'ProjectStart':{'type':datetime },
- }
- source_optionals = {"Comment":True}
-
- #create Model
- model_Project=pydanticModelGenerator(
- model_name="Project",
- source_data=source_data,
- overrides=source_overrides,
- optionals=source_optionals).generate_model()
-
- #create instance using DynamicModel
- project_instance=model_Project(**project_info)
-
+ Takes in created classes and stubs them out in a way FastAPI/Pydantic is happy about:
+ source_data is a snapshot of the default values produced by the class
+ params are the names of the actual keys required by __init__
"""
def __init__(
self,
model_name: str = None,
- source_data: str = None,
+ source_data: {} = {},
params: Dict = {},
overrides: Dict = {},
optionals: Dict = {},
@@ -96,4 +65,4 @@ class pydanticModelGenerator:
StableDiffusionProcessingAPI = pydanticModelGenerator("StableDiffusionProcessing",
StableDiffusionProcessing().__dict__,
- inspect.signature(StableDiffusionProcessing.__init__).parameters).generate_model() \ No newline at end of file
+ inspect.signature(StableDiffusionProcessing.__init__).parameters).generate_model()