Coder Social home page Coder Social logo

Pydantify

A prototype CLI tool to transform YANG models into Pydantic datastructures that can be initialized with config values and serialized into RESTCONF payloads.

Check out the documentation https://pydantify.github.io/pydantify/

For users

Installation

Prerequisites:

  • Python 3.10
  • pip

Installing from PYPI:

pip install pydantify

Installing from local folder:

pip install .

Usage

Example:

pydantify -i ./models_dir -o ./output_dir -t interfaces/ethernet model.yang

Transforms the /interfaces/ethernet node and its children (located in model.yang) into a Python script located in ./output_dir. Imports of definitions found in ./models_dir are included if relevant to the specified model and node.

Command syntax:

pydantify [-h] [-v] [-V] [-S] [-i INPUT_DIR] [-o OUTPUT_DIR] [-t TRIM_PATH] input_file

positional arguments:
  input_file            The YANG file containing the entrypoint to the model to evaluate.

options:
  -h, --help            show this help message and exit
  -v, --verbose         Enables debug output
  -V, --include-verification
                        Adds validation code, as well as the relevant YANG files, to the output model.
  -S, --standalone      Generated output model has no dependency on Pydantify.
                        All required code is copied into the output model.
  -i INPUT_DIR, --input-dir INPUT_DIR, --path INPUT_DIR
                        The directory that contains the YANG input model.
                        Defaults to the input file's folder.
  -o OUTPUT_DIR, --output-dir OUTPUT_DIR
                        The directory that should be used to store the output model. Defaults to "$CWD/out".
  -t TRIM_PATH, --trim-path TRIM_PATH
                        Get only the specified branch of the whole tree.

NOTE: All unknown arguments will be passed to Pyang as-is and without guarantees.

For developers

Requirements:

Instructions:

Note: instructions with the same indentation are alternatives to eachother.

  • Install
    • dependencies through pdm (pdm install in project root)
      • into the local __pypackages__ folder
        • to run your project as a python module
          • locally (python -m pydantify)
          • in a docker container (see Dockerfile)
        • to be accessed by your IDE for intellisense (see .vscode/settings.json)
        • to be accessed by your debug launch configuration (see .vscode/launch.json)
    • project through pip (see guide for users)
  • Build
    • through pdm (pdm build)
      • into the local dist folder
        • to be published on pypi
          • through twine (twine upload dist/*)

Links relevant to project

Pydantic

Explanations

Yang models

Pyang


Thanks

  • Dejan Jovicic and Dominic Walther, who laid the foundations of pydantify

pydantify's Projects

pydantify icon pydantify

Transform YANG models into pydantic datastructures

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.