Base Model Module¶
This section documents the base model components of the Nextmv Python SDK.
base_model
¶
Provides base functionality for handling JSON data in models.
This module contains utilities for converting between dictionaries and model instances, facilitating data serialization and deserialization.
CLASS | DESCRIPTION |
---|---|
BaseModel: |
A base class extending Pydantic's BaseModel with additional methods for JSON data serialization and deserialization. |
FUNCTION | DESCRIPTION |
---|---|
from_dict: |
Load a data model instance from a dictionary containing class information and attributes. |
BaseModel
¶
Bases: BaseModel
Base class for data wrangling tasks with JSON.
This class extends Pydantic's BaseModel
to provide additional methods
for converting between Python objects and JSON/dictionary representations.
from_dict
classmethod
¶
from_dict(data: Optional[dict[str, Any]] = None)
Instantiate the class from a dictionary.
PARAMETER | DESCRIPTION |
---|---|
|
The dictionary containing the data to instantiate the class. If None, returns None.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
cls or None
|
An instance of the class with the given data or None if data is None. |
Source code in nextmv/nextmv/base_model.py
to_dict
¶
Convert the class instance to a dictionary.
The conversion uses Pydantic's model_dump method, excluding None values and using field aliases if defined.
RETURNS | DESCRIPTION |
---|---|
dict[str, Any]
|
Dictionary representation of the class instance. |
Source code in nextmv/nextmv/base_model.py
from_dict
¶
from_dict(data: dict[str, Any]) -> Any
Load a data model instance from a dict
with associated class info.
PARAMETER | DESCRIPTION |
---|---|
|
The data to load.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Any
|
The loaded data model instance. |