validate configs using json schema
Project description
schematized config
Install
pip install python_schematized_config
usage
python
from schematized_config.core import ConfigValidator
import os
import os.path as _p
if _p.exists('.env') and 'CONFIG_VALIDATOR_JSON_SCHEMA' in os.environ:
ConfigValidator.load_dotenv() # use defaults of .env and CONFIG_VALIDATOR_JSON_SCHEMA
CLI
generate skeleton code for working with a validated .env
this will generate stub files in these conventional locations if they do not yet exist:
Makefilegenerators/env.schema.jsonnetsrc/schemas/autogen/EnvSchema.py- python stub code for loading the validated
EnvSchemaclass against.env, as a variable calledEnv(this is output tostdout)
schematized-config --codegen all > src/env.py
- edit
generators/env.schema.jsonnetto add environment variable names and validation make schemas/env.schema.jsonmake src/schemas/autogen/EnvSchema.py- optionally update the make rule
- use the
src/env.py(or whereever you put it)
development
entering the development environment
assuming you have nix installed and
ready, make sure nix-command and flake are enabled (oneliner: run
export NIX_CONFIG="experimental-features = nix-command flakes" in the
terminal), then enter the dev shell using nix develop
start the jupyter notebook using the provided alias or just
jupyter notebook, and hack away
nbdev
this package is developed using nbdev, so we
use an nbdev-centric development flow. For a quick guide, we recommend
checking out the end-to-end
walkthrough. But in
short: edit notebooks, then run the nbdev_* management commands. The
most essential flow is as follows:
- edit the notebook files (core fore core, and cli for the command line interface)
python setup.py install# note we don’t usenbdev_installbecause we managequartousingnixnbdev_prepare- run code using the package
nbdev_releasenbdev_pypi
running tests
if you share variables between cells in your test blocks, this causes
trouble during nbdev_prepare as it tries to run cells in isolation,
leading to e.g.
NameError: name 'example_properties_schema' is not defined
to deal with this, you can merge cells that use a common variable
updating package dependencies
note that package dependencies are specified in
settings.ini; you shouldn’t be editing setup.py by
hand. To add a requirement, add it to the requuirements entry in
settings.ini, then run python setup.py install
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file python_schematized_config-0.1.0.tar.gz.
File metadata
- Download URL: python_schematized_config-0.1.0.tar.gz
- Upload date:
- Size: 13.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2caf4db5f58908b6e3481885ff32855042e7fa44d8266f483c9bf58cd8e9dabe
|
|
| MD5 |
d8cd0897c096aedf947e68a2a54f1c29
|
|
| BLAKE2b-256 |
f13682e0a0312db5a5ce33d7ac455f62b0b3c0787b43c5bdd3aea225bc4b8245
|
File details
Details for the file python_schematized_config-0.1.0-py3-none-any.whl.
File metadata
- Download URL: python_schematized_config-0.1.0-py3-none-any.whl
- Upload date:
- Size: 13.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
23c3e667e390c9ef0606c3cf260cee1b756e77bd6ea18dbb81077d28e53a34af
|
|
| MD5 |
a111b983a67e2d46ff7a91acf03d0b86
|
|
| BLAKE2b-256 |
7127046aec62e6e49e3972d54c4428ce0b34387929002096c8dd7fcec9e61932
|