Base
Data models - Base Pydantic model with custom methods.
BaseCells
Bases: UserList, Generic[T]
Base abstract class for notebook cells.
Source code in databooks/data_models/base.py
25 26 27 28 29 30 31 | |
resolve(**kwargs)
abstractmethod
Return valid notebook cells from differences.
Source code in databooks/data_models/base.py
28 29 30 31 | |
DatabooksBase
Bases: BaseModel
Base Pydantic class with extras on managing fields.
Source code in databooks/data_models/base.py
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 | |
__str__()
Return outputs of repr.
Source code in databooks/data_models/base.py
117 118 119 | |
__sub__(other)
Subtraction between databooks.data_models.base.DatabooksBase objects.
The difference basically return models that replace each fields by a tuple,
where for each field we have field = (self_value, other_value)
Source code in databooks/data_models/base.py
121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 | |
remove_fields(fields, *, recursive=False, missing_ok=False)
Remove selected fields.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
fields
|
Iterable[str]
|
Fields to remove |
required |
recursive
|
bool
|
Whether to remove the fields recursively in case of nested models |
False
|
missing_ok
|
bool
|
Whether to raise errors in case field is missing |
False
|
Returns:
| Type | Description |
|---|---|
None
|
|
Source code in databooks/data_models/base.py
93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 | |
DiffModel
Bases: Iterable, Protocol
Protocol for static type checking.
Source code in databooks/data_models/base.py
15 16 17 18 19 20 21 22 | |
resolve(*args, **kwargs)
Protocol method that returns a valid base object.
Source code in databooks/data_models/base.py
21 22 | |
resolve(model, *, keep_first=True, ignore_none=True, **kwargs)
resolve(model: DiffModel, **kwargs: Any) -> DatabooksBase
resolve(model: BaseCells, **kwargs: Any) -> List[T]
Resolve differences for 'diff models'.
Return instance alike the parent class databooks.data_models.base.DatabooksBase.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model
|
DiffModel | BaseCells
|
DiffModel that is to be resolved (self when added as a method to a class |
required |
keep_first
|
bool
|
Whether to keep the information from the prior in the 'diff model' or the latter |
True
|
ignore_none
|
bool
|
Whether to ignore |
True
|
Returns:
| Type | Description |
|---|---|
DatabooksBase | List[T]
|
Model with selected fields from the differences |
Source code in databooks/data_models/base.py
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 | |