Skip to main content

Makes network automation pydantic.

Project description

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".
  -f OUTPUT_FILE, --output-file OUTPUT_FILE
                        The name of the output file. Defaults to "out.py".
  -t TRIM_PATH, --trim-path TRIM_PATH
                        Get only the specified branch of the whole tree.
  -j, --json-schema     Output JSON schema instead of Pydantic models.
  -d, --data-type {config,state}
                        Limit output to config or state only. Default is config and state combined.
  -n, --strip-namespace
                        Strip the YANG namespace from the output model aliases.

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

For developers

Requirements

  • Visual Studio Code
  • Python 3.10
  • UV

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.10.0b0.tar.gz (15.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pydantify-0.10.0b0-py3-none-any.whl (21.2 kB view details)

Uploaded Python 3

File details

Details for the file pydantify-0.10.0b0.tar.gz.

File metadata

  • Download URL: pydantify-0.10.0b0.tar.gz
  • Upload date:
  • Size: 15.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pydantify-0.10.0b0.tar.gz
Algorithm Hash digest
SHA256 5f5cac277f3476e51d1a215f61f45babedfe0b34c81592a3254db7b1ecba9c8c
MD5 ee227b13053342ef4cf7742d51838db3
BLAKE2b-256 b08b528ac9422d4ac88348379bfc38e64725db2f993cb578f7e6d51d232dc28e

See more details on using hashes here.

File details

Details for the file pydantify-0.10.0b0-py3-none-any.whl.

File metadata

  • Download URL: pydantify-0.10.0b0-py3-none-any.whl
  • Upload date:
  • Size: 21.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pydantify-0.10.0b0-py3-none-any.whl
Algorithm Hash digest
SHA256 0a5fba99baf5461f803a34b6ba92b4729b4a6eac48435ce6514f701d0dbf7b46
MD5 20194b203a60d6093fc2193e2cfc3b3e
BLAKE2b-256 abdb94701d0d980f2324267c173e901ca9de3dd4589f1ee3a2d0d185f87021c5

See more details on using hashes here.

Supported by

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