Skip to main content

YAML-heritage

This library enables easy loading of parameters from a YAML file into Python class structures.

Usage

This example.ipynb can be found in the examples folder.

  • Create the expected structure with Python classes

    from yaml_heritage import Heritage
    
    class Subclass(Heritage):
        subparam: str
        param1: int
    
    class Example(Heritage):
        param1: int
        param2: float
        param3: Subclass
    
  • Replicate the same structure in the YAML file

    param1: 1.1
    param2: 2.5
    param3:
    subparam: abc
    param1: 2.3
    
  • Load the parameters from the YAML file into the classes

    example = Example.load('example.yaml')
    
  • Then example would be :

    param1: 1,
    param2: 2.500e+00,
    param3:
      subparam: abc,
      param1: 2
    

Note that the values are converted to the expected type. For example, param1 is expected to be an integer, so 1.1 is converted to 1.

Yaml syntax

  • Float Floats should have the decimal point at the end. For example, '35e6' should be written as '35.e6'.

  • Link other file You can easily link other files as a parameter and they will be loaded.

    etching_param: &etching_param 'const_params/etching_params.yaml'
    
  • Link to a value:

    etching_param: &etching_param 'const_params/etching_params.yaml'
    ...
    somewhere:
        etching_param: *etching_param
    
  • Link by relative link You can link to a value by relative link, example: $.param_a

    • $ sign denotes that it is a link.
    • . denotes to move up one level to find the parameter.
    • param_a is the name of the parameter
    param_a: 1
    ...
    somewhere:
        param_b: $.param_a
    

Metadata

Release files for yaml-heritage 0.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for yaml-heritage 0.0.1
File Size Uploaded Provenance
yaml-heritage-0.0.1.tar.gz 7.7 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for yaml-heritage 0.0.1
File Interpreter ABI Platform
yaml_heritage-0.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 16.5 kB

Release files / yaml-heritage-0.0.1.tar.gz

Download URL yaml-heritage-0.0.1.tar.gz
Size 7.7 kB
Tags Source
SHA-256 checksum
How to use checksums
eb2e86a59b89e323d61af1965c5596e17c2efa175977ae762460293ae110e6b8
BLAKE2b-256 checksum
How to use checksums
6027de1a23a997119e90e1805f8dbe713d40cd6c57259777e4292e12d343d20f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.4

Release files / yaml_heritage-0.0.1-py3-none-any.whl

Download URL yaml_heritage-0.0.1-py3-none-any.whl
Size 8.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
992a0b4382c9ff223e265b5fc137ab8e38b99a80ba74e529350bd4359e6eab62
BLAKE2b-256 checksum
How to use checksums
700ad303c4f2ecdb0b80d820e2c84b11caacb5dbce2963c3d2f1e402e015889d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.4

Security for yaml-heritage 0.0.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Release history Release notifications | RSS feed

This release

0.0.1 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page