Module enrgdaq.daq.template.store
Store configuration template generator.
Uses msgspec's built-in JSON schema generation for store configurations.
Functions
def get_store_config_templates() ‑> dict[str, dict]-
Expand source code
def get_store_config_templates() -> dict[str, dict]: """ Generate store configuration templates using msgspec's JSON schema generation. Returns a dictionary of JSON schemas for each store type. """ # Build store type to class mapping from DAQJobStoreConfig annotations try: resolved_hints = get_type_hints(DAQJobStoreConfig) except Exception: resolved_hints = {} store_type_to_class: dict[str, type] = {} for store_type, annotation in resolved_hints.items(): # Get the actual type from the annotation (unwrap Optional) origin = get_origin(annotation) if origin is not None: args = get_args(annotation) non_none_args = [a for a in args if a is not type(None)] if non_none_args: config_class = non_none_args[0] store_type_to_class[store_type] = config_class templates: dict[str, dict] = {} for store_type, config_class in store_type_to_class.items(): try: # Generate JSON schema using msgspec with custom hook for unsupported types schema = msgspec.json.schema(config_class, schema_hook=_schema_hook) except TypeError: # Skip types that can't be converted to schemas continue # Add our custom metadata schema["type_key"] = store_type schema["label"] = STORE_TYPE_LABELS.get( store_type, f"{store_type.upper()} Store" ) schema["description"] = STORE_TYPE_DESCRIPTIONS.get( store_type, schema.get("description", f"Store data using {store_type}") ) templates[store_type] = schema return templatesGenerate store configuration templates using msgspec's JSON schema generation.
Returns a dictionary of JSON schemas for each store type.