DataSchemer
DataSchemer (DS) connects structured user input to application code. A schema declares the expected fields, optional type constraints, defaults, and relationships between fields. DS validates the input and makes the result available for application construction.
Input to the schema processor is a DataCanon Instance (DCI). DataCanon (DC) defines the data types, equality, canonical bytes, and fingerprints. DS adds the application’s input requirements: which fields are permitted, which are required, and how the fields map to constructor arguments.
Define the requirements your application needs
schema = {
"variables": {
"matrix": {},
"iterations": {"type": "Integer"},
"tolerance": {"type": "Float", "optional": True, "default": 1e-8},
},
}
The matrix field accepts any DCI. An application constructor can turn a nested
List or an Array into the numerical container it needs. The iterations field
requires an Integer DCI, and an omitted tolerance receives a default.
A declared type is checked strictly. DS rejects a Float DCI where the schema requires an Integer DCI; it does not silently change the supplied value.
Preserve the data and construct application objects
DS exposes both the processed DCI and its conversion to instances of
conventional types: the usual types used in a programming language, including
builtins, library types, and user-defined classes. In Python, a List DCI can
convert to a list; an Array DCI can convert to a NumPy array. Both a ListDC
instance and a list are Python objects, but they serve different roles.
Schema processing retains the DCI distinctions. Conventional conversion happens when requested and can perform the normalizations of the destination types.
SchemaCommandLine (SCL) uses the same processor for command-line options and input files. SCL supplies help, tab completion, nested child commands, source merging, and optional application construction.
Read the documentation
- Getting Started: validate a DCI and construct an application object.
- Guides: input, projection, schema composition, child schemas, SCL, and output.
- Reference: behavioral rules, Python interfaces, and errors.
DS is used by Principia Materia and is available as a standalone library. See the DataCanon documentation for DC’s data model and representations.
Citation
If you use DataSchemer in published work, please cite the project using
CITATION.cff in the code repository.
Feedback
Was this page helpful?
Glad to hear it! Please tell us how we can improve.
Sorry to hear that. Please tell us how we can improve.