Lower import time + optional schema validation
Opened this issue · 0 comments
Importing dnacentersdk is ~1 sec - half of this is importing the schema classes: https://ctrl.vi/i/hdKtAuyj6
For dev/test good validation desirable, but for production it is important to lower load time, memory, IO and CPU utilisation and assuming proper tests were done, it should be legitimate to run this without the validations.
Even in dev/test, it is important to increase efficiency, thus using less power, save the planet and all that 😉 and avoid wasting memory, CPU and pipeline time for loading irrelevant Schema classes for unused DNAC versions.
I propose to:
- lazily import schema classes in
SchemaValidator.load_validators()
- avoid using memory, IO, CPU on irrelevant DNAC Versions - Add a
NoSchemaValidator
class, wherejson_schema_validate()
returns itself, and also has avalidate()
which just doespass
- can be used in production after validation to save even more memory, IO & CPU.
I considered just doing my own NoSchemaValidator
to use for efficient production, but I would still import all the schema classes, no matter what I do - I would need to do something really shady, like manipulating the installed sdk.
To measure import times and display locally in browser:
python3.11 -m venv venv-dnac
pip install dnacentersdk tuna importTime
python -X importtime -c "from dnacentersdk import DNACenterAPI; print('done')" 2> dnac-import.log
tuna dnac-import.log