Skip to main content

Makes network automation pydantic.

Project description

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pydantify-0.6.0.tar.gz (47.3 kB view details)

Uploaded Source

Built Distribution

pydantify-0.6.0-py3-none-any.whl (20.0 kB view details)

Uploaded Python 3

File details

Details for the file pydantify-0.6.0.tar.gz.

File metadata

  • Download URL: pydantify-0.6.0.tar.gz
  • Upload date:
  • Size: 47.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: pdm/2.19.1 CPython/3.12.1 Linux/6.5.0-1025-azure

File hashes

Hashes for pydantify-0.6.0.tar.gz
Algorithm Hash digest
SHA256 04e3a9f3d8dc1a6064aab07c898d827888a3bc62b226a7edb6e21a79934c6cb1
MD5 1cf0c206cce5890322571cc9c1517160
BLAKE2b-256 cdc8656c60e545c06c5082fd9c3c9ea5cf8dfcc14a5a3ddde35bb4cc58d9dcbb

See more details on using hashes here.

File details

Details for the file pydantify-0.6.0-py3-none-any.whl.

File metadata

  • Download URL: pydantify-0.6.0-py3-none-any.whl
  • Upload date:
  • Size: 20.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: pdm/2.19.1 CPython/3.12.1 Linux/6.5.0-1025-azure

File hashes

Hashes for pydantify-0.6.0-py3-none-any.whl
Algorithm Hash digest
SHA256 25f3ffa3898738ed0a7d5408a61ec7c89952c29dddbfcf47b6e9ee2cfda7ca83
MD5 1882f7784d87f4e8feb03ae81c8985cb
BLAKE2b-256 3e4d2fd2c592860d8cb66091ec2dcff1b5e9e0b2bb2fca5ab70ce9659ceb6ce5

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page