Schema Utilities
This section documents the schema utility functions used throughout the NDF Studio backend.
backend.core.schema_utils
NDF Studio Schema Utilities
This module provides utility functions for managing schema definitions in YAML format in the NDF Studio backend. It handles filtering of used schema types from global schemas based on actual usage in parsed graphs.
Functions:
| Name | Description |
|---|---|
filter_used_schema |
Filter schema to only include used types from YAML files |
Functions
filter_used_schema(parsed_yaml_path, relation_schema_path, attribute_schema_path, output_path)
Filters only the used relation and attribute types from the global schema and writes them into used_schema.yaml.
This function analyzes a parsed graph in YAML format to identify which relation and attribute types are actually used, then creates a filtered schema containing only those types. This is useful for creating lightweight schemas for specific graphs.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
parsed_yaml_path
|
str
|
Path to the parsed graph YAML file |
required |
relation_schema_path
|
str
|
Path to the global relation schema YAML file |
required |
attribute_schema_path
|
str
|
Path to the global attribute schema YAML file |
required |
output_path
|
str
|
Path where the filtered schema will be written |
required |
Returns:
| Name | Type | Description |
|---|---|---|
dict |
The filtered schema containing only used types |
Example
filter_used_schema( ... "parsed_graph.yaml", ... "relation_types.yaml", ... "attribute_types.yaml", ... "used_schema.yaml" ... ) {'relation_types': [...], 'attribute_types': [...]}
Note
This function is similar to the JSON version in schema_ops.py but works with YAML files instead of JSON files.