gtsystem / lightkube-models Goto Github PK
View Code? Open in Web Editor NEWModels and Resources for lightkube
License: MIT License
Models and Resources for lightkube
License: MIT License
Cross platform deployments of software systems that depend on lightkube-models may want to build it from source for a specific platform before deploying.
At present only prebuilt wheels are available through PyPi
I started using this on a new project and wasn't getting any type hinting for any Resource/Model arguments. After poking around and trying in different IDEs, what seems to be the cause is the new schema.py
method for importing dataclass
. I tested by just changing the import in the model definition to be directly from dataclasses
and type hinting immediately started working again.
I also tested by rolling back to the latest models version I could see before that change went in, which is lightkube-models==1.28.1.4
. There, type hints work out of the box as expected.
If I extract a swagger.json from my cluster, slice out my custom resources, and feed it to lightkube-generate
, it fails because of assertions about schema naming:
python -m lightkube-generate resources models ./swagger.json
Traceback (most recent call last):
File "/usr/local/opt/[email protected]/Frameworks/Python.framework/Versions/3.7/lib/python3.7/runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "/usr/local/opt/[email protected]/Frameworks/Python.framework/Versions/3.7/lib/python3.7/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "/Users/tmiller/Documents/projects/lightkube-models/lightkube-generate/__main__.py", line 19, in <module>
compile_resources.execute(Path(args.specs), Path(args.dest), Path(args.testdir), Path(args.docs), compiler_major)
File "/Users/tmiller/Documents/projects/lightkube-models/lightkube-generate/compile_resources.py", line 321, in execute
modules = compile_resources(aggregate(extract(specs)), dest, testdir.joinpath("test_resources.py"))
File "/Users/tmiller/Documents/projects/lightkube-models/lightkube-generate/compile_resources.py", line 145, in aggregate
for ele in it:
File "/Users/tmiller/Documents/projects/lightkube-models/lightkube-generate/compile_resources.py", line 107, in extract
model_schema = schema_name(schema['$ref'])
File "/Users/tmiller/Documents/projects/lightkube-models/lightkube-generate/model.py", line 24, in schema_name
assert len(parts) <= 3
AssertionError
The definition in question in this case is (orig_name fed to schema_name()):
#/definitions/uk.co.networkop.v1beta1.TopologyList
The parts
length assertion may be only one issue; there could be more buried in deeper.
However, it would be /really convenient/ to be able to generate my own resources and models from swagger. While this clearly what's intended (i.e., lightkube generic models), the ability to turn CRs into first-class lightkube objects would be nice, as it would simplify handling and introspection of K8s objects regardless of source.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.