Skip to main content

Query Templates and Namespaces

Query resource templates, process templates, and namespace metadata.

Query templates and namespaces through separate query families. All families support all(), first(), count(), ordering, and pagination.

Query namespaces

namespaces = (
    namespace.query_maker()
    .namespaces()
    .filter(name="beamline")
    .filter_effective_metadata(environment="production")
    .all()
)

Use filter_local_metadata() for values defined directly on a namespace and filter_effective_metadata() for inherited values.

Query resource templates

Filter labels and type names, include child templates, and opt into archived templates when needed.

templates = (
    namespace.query_maker()
    .resource_templates()
    .filter_label("sample")
    .filter_by_types(["sample", "container"])
    .include_children()
    .include_archived()
    .all()
)

Other relationship helpers are include_attribute_groups() and include_types(). Use include([...]) for explicit relationship paths.

Query process templates

process_templates = (
    namespace.query_maker()
    .process_templates()
    .filter_label("measurement")
    .include_step_templates()
    .include_resource_slots()
    .include_archived()
    .all()
)

Use canonical models for identity-only results

Template queries return canonical full models. Use load="none" for identity and scalar fields, then add targeted includes when relationships are needed. shape="ref" is deprecated compatibility syntax and normalizes to shape="full"; use load="none" for unloaded relationships. See Choose query shape and loading.