Code Monkey home page Code Monkey logo

lightkube-models's People

Contributors

gtsystem avatar jnsgruk avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

lightkube-models's Issues

Type hints seem broken since December versions

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.

On 1.28.1.4:
image

On 1.28.1.6:
image

Support generation of CRD models from local OpenAPI spec

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.