Replies: 5 comments 23 replies
-
Hi, dealing with large description documents? But 56MB is … interesting. First - convert to json, test loading speed with orjson, pycsimdjson, ijson Second - as you already do, limit models to the models you need. class SchemaSelector(Init):
"""
remove the schemas we do not need models for
"""
def __init__(self, *schemas):
super().__init__()
self.schemas = schemas
def schema(self, ctx: "Init.Context") -> "Init.Context":
ctx.schema = {k: ctx.schema[k] for k in (set(self.schemas) & set(ctx.schema.keys()))}
return ctx The logic will resolve required/related/linked models - as your own logic does. remove pathes you do not need class RemovePaths(Document):
def parsed(self, ctx: "Document.Context") -> "Document.Context":
"""
emtpy the paths - not needed
"""
ctx.document["paths"] = {}
return ctx Last, do it "once" - once you are satisfied with the result, use cache_store/cache_load. You can profile easily.
Currently does not load …
required, nullable pathparameter which does not exist - I consider this invalid.
Now it's taking me about 6 GB RAM and I'll submit this before my machine dies oom … . _init_schema_types() creates the model classes from the json schemas - time which needs to be spent. |
Beta Was this translation helpful? Give feedback.
-
Cloned the mypy branch, and I'm running in to this. Not an issue with the branch, but with pydantic. |
Beta Was this translation helpful? Give feedback.
-
Is there a functional purpose for using a ChainMap in this method? aiopenapi3/aiopenapi3/openapi.py Lines 399 to 459 in 9947b29 I did some testing and iterating without recursion, using just
For my tests, the |
Beta Was this translation helpful? Give feedback.
-
Curious of your thoughts on my changes here: ggpwnkthx@645f1af Sub 4 second but I'm culling things from the |
Beta Was this translation helpful? Give feedback.
-
Just pushed to my fork an update that handles things with class inheritance. I'm not 100% on their names, though. |
Beta Was this translation helpful? Give feedback.
-
I'm trying to work with some rather large OpenAPI files (specifically this one Microsoft Graph OpenAPI). Since the majority of that file is unnecessary to load at runtime (especially when I may only need one endpoint for a given process/instance), I wrote some code that essentially indexes the components and paths into a zip file as JSON data, as well as some code to generate an OpenAPI file based the desired paths and any
$refs
.This works well as it only takes about a minute to generate the zip file and less than a second to compile only the necessary assets. That said, sometimes I'm still left with definitions that can be 100k-200k lines long (in YAML format). The method that seems to take the longest to process is
_init_schema_types
aiopenapi3/aiopenapi3/openapi.py
Line 467 in 0a0789c
I was going to dive into this and see what I could improve on, but figured I'd touch base to see if you had any thoughts.
Beta Was this translation helpful? Give feedback.
All reactions