pip install python_schematized_configfrom schematized_config.core import ConfigValidatorimport 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_SCHEMAthis 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)
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
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
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
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