pandas_openscm.db.saving#
Functionality for saving data
Classes:
| Name | Description |
|---|---|
DBFileType |
Type of a database file |
SaveAction |
A database save action |
Functions:
| Name | Description |
|---|---|
save_data |
Save data |
save_file |
Save a file to disk |
save_files |
Save database information to disk |
DBFileType #
SaveAction #
A database save action
Attributes:
| Name | Type | Description |
|---|---|---|
backend |
OpenSCMDBDataBackend | OpenSCMDBIndexBackend
|
Backend to use to save the data to disk |
info |
DataFrame | Series[Any]
|
Information to save |
info_kind |
DBFileType
|
The kind of information that this is |
save_path |
Path
|
Path in which to save the information |
Source code in src/pandas_openscm/db/saving.py
backend
instance-attribute
#
backend: OpenSCMDBDataBackend | OpenSCMDBIndexBackend
Backend to use to save the data to disk
save_data #
save_data(
data: DataFrame,
*,
backend_data: OpenSCMDBDataBackend,
get_new_data_file_path: Callable[[int], DBPath],
backend_index: OpenSCMDBIndexBackend,
index_file: Path,
file_map_file: Path,
index_non_data: DataFrame | None = None,
file_map_non_data: Series[Path] | None = None,
min_file_id: int = 0,
groupby: list[str] | None = None,
progress_grouping: ProgressLike | None = None,
parallel_op_config: ParallelOpConfig | None = None,
progress: bool = False,
max_workers: int | None = None,
) -> None
Save data
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
DataFrame
|
Data to save |
required |
backend_data
|
OpenSCMDBDataBackend
|
Backend to use to save the data |
required |
get_new_data_file_path
|
Callable[[int], DBPath]
|
Callable which, given an integer, returns the path info for the new data file |
required |
backend_index
|
OpenSCMDBIndexBackend
|
Backend to use to save the index |
required |
index_file
|
Path
|
File in which to save the index |
required |
file_map_file
|
Path
|
File in which to save the file map |
required |
index_non_data
|
DataFrame | None
|
Index that is already in the database but isn't related to data. If supplied, this is combined with the index generated for |
None
|
file_map_non_data
|
Series[Path] | None
|
File map that is already in the database but isn't related to If supplied, this is combined with the file map generated for |
None
|
min_file_id
|
int
|
Minimum file ID to assign to save data chunks |
0
|
groupby
|
list[str] | None
|
Metadata columns to use to group the data. If not supplied, we save all the data in a single file. |
None
|
progress_grouping
|
ProgressLike | None
|
Progress bar to use when grouping the data |
None
|
parallel_op_config
|
ParallelOpConfig | None
|
Configuration for executing the operation in parallel with progress bars If not supplied, we use the values of |
None
|
progress
|
bool
|
Should progress bar(s) be used to display the progress of the saving? Only used if |
False
|
max_workers
|
int | None
|
Maximum number of workers to use for parallel processing. If supplied, we create an instance of
concurrent.futures.ProcessPoolExecutor
with the provided number of workers.
A process pool seems to be the sensible default from our experimentation,
but it is not a universally better choice.
If you need something else because of how your database is set up,
simply pass If not supplied, the saving is executed serially. Only used if |
None
|
Source code in src/pandas_openscm/db/saving.py
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 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 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 | |
save_file #
save_file(save_action: SaveAction) -> None
Save a file to disk
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
save_action
|
SaveAction
|
Save action to perform |
required |
Source code in src/pandas_openscm/db/saving.py
save_files #
save_files(
save_actions: Iterable[SaveAction],
parallel_op_config: ParallelOpConfig | None = None,
progress: bool = False,
max_workers: int | None = None,
) -> None
Save database information to disk
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
save_actions
|
Iterable[SaveAction]
|
Iterable of save actions |
required |
parallel_op_config
|
ParallelOpConfig | None
|
Configuration for executing the operation in parallel with progress bars If not supplied, we use the values of |
None
|
progress
|
bool
|
Should progress bar(s) be used to display the progress of the deletion? Only used if |
False
|
max_workers
|
int | None
|
Maximum number of workers to use for parallel processing. If supplied, we create an instance of
concurrent.futures.ProcessPoolExecutor
with the provided number of workers.
A process pool seems to be the sensible default from our experimentation,
but it is not a universally better choice.
If you need something else because of how your database is set up,
simply pass If not supplied, the saving is executed serially. Only used if |
None
|
Source code in src/pandas_openscm/db/saving.py
254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 | |