Python API

Import the public classes from their defining modules:

from data_schemer.schema_projector import SchemaProjector, SchemaProjection
from data_schemer.schema_command_line import SchemaCommandLine

SchemaProjector

SchemaProjector(schema_definitions, *, schema_name=None, input_data=None,
                registry=None, source=None)

schema_definitions is a conventional Python dictionary in single-schema or named-schema form. schema_name selects a definition in named-schema form. registry supplies a DataCanon (DC) conversion registry. source supplies external-resource context for conventional conversion. An optional input_data DataCanon Instance (DCI) creates an initial projection.

MemberMeaning
get_projection(input_data)Validate one Mapping DCI and return a SchemaProjection
compile_child(name)Compile or return a reusable declared child projector
find_projectors_with_paths(name, include_self=False)Find compiled definitions by schema name, returning (path, projector) pairs; include_self is keyword-only
schema_nameSelected schema name
schema_variablesCopy of the compiled field metadata
allowed_typesSet of accepted DataCanon Type (DCT) constraint names
child_schema_namesAccumulated declared child names
child_projectorsSnapshot of child projectors compiled so far
conflictsCopy of the resolved conflict groups
projectionInitial projection, if input_data was supplied
data_dci, data, get_instance(callable)Access or construct from the initial projection

Accessing initial-projection members without an initial input raises DSUserError. Reusable projectors and per-input projections have distinct roles; passing a new input to get_projection() does not replace the initial projection.

For a field declared type: "Array", optional array_type constrains its portable element type, for example float64. It requires an exact match and preserves the supplied Array. This metadata is resolved during schema composition and validated before projection; defaults are checked as well.

SchemaProjection

Obtain a projection through projector.get_projection(input_dci).

MemberMeaning
input_dciOriginal complete Mapping DCI
data_dciProcessed local fields
dataConventional conversion of local fields
data_tree_dciComplete processed tree
data_treeConventional conversion of the complete tree
child_projectionsImmediate supplied children and their per-input results
child_dataImmediate children’s conventional local fields
get_instance(callable)Bind selected local arguments, convert them, and invoke the callable

Conventional views are computed on request. get_instance() selects fields before converting, so unrelated external references need not be materialized. See Application construction.

SchemaCommandLine

SchemaCommandLine(schema_definitions, target_class=None, schema_name=None,
                  argv=None, input_files_tag="input_files",
                  prog=None, registry=None, stdin_format="yaml")

Construction parses sources, validates the merged DCI, optionally constructs the target, calls _operations(), and handles requested attribute output. Omit argv to use sys.argv[1:]. prog selects the displayed executable name. stdin_format accepts "yaml" or "shorthand" for structured stdin.

SchemaCommandLine (SCL) exposes input_dci, data_dci, data, data_tree_dci, data_tree, child_projections, and child_data from its projection. Additional members:

MemberMeaning
target_objConstructed target or None
raw_child_dataImmediate supplied child input DCIs
required_file_pathSelected required positional file, if enabled
required_file_contentApplication-specific text/bytes when requested; otherwise None
_operations()Subclass hook after construction and before attribute output
main(*args, debug=False, **kwargs)Class method returning zero on success or the caught DataSchemer (DS) user-error exit code

main() forwards arguments to the constructor. debug=True reraises caught DS user errors. Argparse help can exit through normal SystemExit(0) behavior.

Schema metadata helpers

The following helpers are available from data_schemer.schema_projector:

get_schema_variables(schema_name, schema_definitions, allowed_types=None, defaults=None)
get_schema_child_schemas(schema_name, schema_definitions)
get_schema_conflicts(schema_name, schema_definitions)
get_schema_print_attribute(schema_name, schema_definitions)

get_schema_variables() resolves metadata. SchemaProjector performs additional compilation checks and converts defaults and choices to DCIs; use the projector when processing input.

For SCL tooling, compute_print_attribute_choices() is available from data_schemer.schema_command_line:

compute_print_attribute_choices(print_attribute, *, target_class, schema_vars)

It returns (choices, external_to_internal) for attribute validation and completion. Callers should reuse it when they need SCL’s naming rules.

Output formatting

SCL attribute output uses DC YAML interchange. Applications handle their own numerical reports. render_data.py, numpy_print.py, and SCL’s numerical report controls have been removed; see Output and application reports.