common_base_model
- exception NodeNotFoundError
Bases:
Exception
Exception raised when a node is not found in the ADH.
- exception PathAlreadyExistsError
Bases:
Exception
Exception raised when a path already exists in the ADH.
- class CommonBaseModel
Bases:
BaseModel
A base model providing common validation logic for all derived models.
- adh_data
Dictionary for storing additional data.
- Type:
Optional[Dict[str, Any]]
- adh_root
Dictionary representing the root of the ADH (Application Data Hierarchy).
- Type:
Optional[Dict[str, Any]]
- aliases
Dictionary for storing alias to path mappings.
- Type:
Optional[Dict[str, str]]
Methods:
strip_strings
(value, info)Strip leading and trailing whitespace from string fields before further validation.
create_node
(path, data)Create a new node in the ADH at the specified path with the provided data.
get_node
(path)Retrieve a node from the ADH at the specified path.
search_nodes
(filter_criteria)Search for nodes in the ADH that match the provided filter criteria.
update_node
(path, data)Update a node in the ADH at the specified path with the provided data.
move_node
(source_path, target_path)Move a node from one path to another in the ADH.
delete_node
(path)Delete a node from the ADH at the specified path.
merge_nodes
(source_path, target_path)Merge the data of a source node into a target node in the ADH.
copy_node
(source_path, target_path)Copy a node from a source path to a target path in the ADH.
link_nodes
(source_path, target_path)Create a link between a source node and a target node in the ADH.
unlink_nodes
(source_path)Remove the link between a source node and its target node in the ADH.
Attributes:
__setattr__ handlers.
- classmethod strip_strings(value, info)
Strip leading and trailing whitespace from string fields before further validation.
- Parameters:
value (Any) – The value to be validated.
info (Any) – The field information.
- Returns:
The validated and possibly modified value.
- Return type:
Any
- Raises:
ValueError – If the field value is an empty string after trimming.
- create_node(path, data)
Create a new node in the ADH at the specified path with the provided data.
- Parameters:
path (str) – The path where the new node should be created in the ADH.
data (Dict[str, Any]) – A dictionary containing the data to be stored in the new node.
- Raises:
PathAlreadyExistsError – If the specified path already exists in the ADH.
TypeError – If the provided data is not a valid dictionary.
- Return type:
None
- get_node(path)
Retrieve a node from the ADH at the specified path.
- Parameters:
path (str) – The path of the node to retrieve from the ADH.
- Returns:
The node data as a dictionary if found, or None if the node doesn’t exist.
- Return type:
Optional[Dict[str, Any]]
- search_nodes(filter_criteria)
Search for nodes in the ADH that match the provided filter criteria.
- Parameters:
filter_criteria (Dict[str, Any]) – A dictionary specifying the filter criteria for the search.
- Returns:
A list of nodes (as dictionaries) that match the filter criteria.
- Return type:
List[Dict[str, Any]]
- update_node(path, data)
Update a node in the ADH at the specified path with the provided data.
- Parameters:
path (str) – The path of the node to update in the ADH.
data (Dict[str, Any]) – A dictionary containing the updated data for the node.
- Raises:
NodeNotFoundError – If the specified path doesn’t exist in the ADH.
TypeError – If the provided data is not a valid dictionary.
- Return type:
None
- move_node(source_path, target_path)
Move a node from one path to another in the ADH.
- Parameters:
source_path (str) – The path of the node to be moved.
target_path (str) – The path where the node should be moved to.
- Raises:
NodeNotFoundError – If the source path doesn’t exist.
PathAlreadyExistsError – If the target path already exists in the ADH.
- Return type:
None
- delete_node(path)
Delete a node from the ADH at the specified path.
- Parameters:
path (str) – The path of the node to delete from the ADH.
- Raises:
NodeNotFoundError – If the specified path doesn’t exist in the ADH.
- Return type:
None
- merge_nodes(source_path, target_path)
Merge the data of a source node into a target node in the ADH.
- Parameters:
source_path (str) – The path of the source node to merge from.
target_path (str) – The path of the target node to merge into.
- Raises:
NodeNotFoundError – If either the source or target path doesn’t exist in the ADH.
- Return type:
None
- copy_node(source_path, target_path)
Copy a node from a source path to a target path in the ADH.
- Parameters:
source_path (str) – The path of the node to be copied.
target_path (str) – The path where the node should be copied to.
- Raises:
NodeNotFoundError – If the source path doesn’t exist.
PathAlreadyExistsError – If the target path already exists in the ADH.
- Return type:
None
- link_nodes(source_path, target_path)
Create a link between a source node and a target node in the ADH.
- Parameters:
source_path (str) – The path of the source node to link from.
target_path (str) – The path of the target node to link to.
- Raises:
NodeNotFoundError – If either the source or target path doesn’t exist in the ADH.
- Return type:
None
- unlink_nodes(source_path)
Remove the link between a source node and its target node in the ADH.
- Parameters:
source_path (str) – The path of the source node to unlink.
- Raises:
NodeNotFoundError – If the specified path is not linked to any other node.
- Return type:
None
- __pydantic_setattr_handlers__: ClassVar[Dict[str, Callable[[BaseModel, str, Any], None]]] = {}
__setattr__ handlers. Memoizing the handlers leads to a dramatic performance improvement in __setattr__
- class Metadata
Bases:
CommonBaseModel
A metadata model for storing and managing key-value pairs.
- key
The key of the metadata entry.
- Type:
str
- value
The value associated with the key.
- Type:
Any
- units
The units of measure for the data.
- Type:
Optional[str]
- uncertainty
The uncertainty associated with the data.
- Type:
Optional[Any]
- lower_bounds
The lower bounds of the data.
- Type:
Optional[List[Bounds]]
- upper_bounds
The upper bounds of the data.
- Type:
Optional[List[Bounds]]
Methods:
Ensure the key is non-empty and within specified length limits.
Attributes:
__setattr__ handlers.
- class Config
Bases:
object
Pydantic configuration for the Metadata model.
- classmethod key_must_be_non_empty(key)
Ensure the key is non-empty and within specified length limits.
- Parameters:
key (str) – The key to validate.
- Returns:
The validated key.
- Return type:
str
- Raises:
ValueError – If the key is empty or exceeds the specified length limits.
- __pydantic_setattr_handlers__: ClassVar[Dict[str, Callable[[BaseModel, str, Any], None]]] = {}
__setattr__ handlers. Memoizing the handlers leads to a dramatic performance improvement in __setattr__
Classes
A base model providing common validation logic for all derived models. |
|
A metadata model for storing and managing key-value pairs. |
|
Exception raised when a node is not found in the ADH. |
|
Exception raised when a path already exists in the ADH. |