bookshelf._produce#
| Sub-package | Description |
|---|---|
| activities | Activity contexts for registering produced resources. |
| books | Mutable draft-book handles for producer workflows. |
| facade | Producer write adapters and the seam the public facades bind to. |
| helpers | Shared helpers for synchronous and asynchronous production. |
| provenance | Git provenance and config-hash helpers for the activity surface. |
| resources | Resource handles enriched with producer registration outcomes. |
| serialise | Materialise an in-memory object into the bytes a registration uploads. |
| types | Public value types for producing Bookshelf resources. |
| uploads | Put already-serialised bytes into managed storage, returning the key they landed at. |
| visibility | The visibility argument shared by every producer registration surface. |
bookshelf._produce #
Producer-side facade implementation.
Activity #
Synchronous activity context that attributes every produced resource.
Source code in packages/bookshelf/src/bookshelf/_produce/activities.py
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 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 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 252 253 254 255 256 257 258 259 260 261 262 263 | |
register(obj, *, type, name=None, used=(), visibility=INHERIT, tags=(), metadata=None, tracking_id=None, format=None, dedupe=True) #
Serialise, hash, upload, and register one generated resource.
used= records the inputs consumed by this resource.
Source code in packages/bookshelf/src/bookshelf/_produce/activities.py
register_external(*, type, uri, hash=None, name=None, used=(), visibility=INHERIT, tags=(), metadata=None, tracking_id=None, dedupe=True) #
Register an external output and attribute it to this activity.
used= records the inputs consumed by this resource.
Source code in packages/bookshelf/src/bookshelf/_produce/activities.py
register_many(entries, *, used=(), atomic=True) #
Materialise many outputs, splitting only a non atomic oversized batch.
used= records the inputs consumed by every output in this call.
Source code in packages/bookshelf/src/bookshelf/_produce/activities.py
AsyncActivity #
Asynchronous activity context that attributes every produced resource.
Source code in packages/bookshelf/src/bookshelf/_produce/activities.py
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 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 | |
register(obj, *, type, name=None, used=(), visibility=INHERIT, tags=(), metadata=None, tracking_id=None, format=None, dedupe=True) async #
Serialise, hash, upload, and register one generated resource.
used= records the inputs consumed by this resource.
Source code in packages/bookshelf/src/bookshelf/_produce/activities.py
register_external(*, type, uri, hash=None, name=None, used=(), visibility=INHERIT, tags=(), metadata=None, tracking_id=None, dedupe=True) async #
Register an external output and attribute it to this activity.
used= records the inputs consumed by this resource.
Source code in packages/bookshelf/src/bookshelf/_produce/activities.py
register_many(entries, *, used=(), atomic=True) async #
Materialise many outputs, splitting only a non atomic oversized batch.
used= records the inputs consumed by every output in this call.
Source code in packages/bookshelf/src/bookshelf/_produce/activities.py
AsyncDraftBook #
Mutable asynchronous draft-book handle.
Source code in packages/bookshelf/src/bookshelf/_produce/books.py
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 | |
add(*resources) async #
Attach already registered resources, each under the name it registered as.
Source code in packages/bookshelf/src/bookshelf/_produce/books.py
attach(resource, *, name_in_book, data_dictionary=None) async #
Attach a resource under a book-local name and optional entry dictionary.
Omitting data_dictionary preserves the dictionary on an existing entry. Pass an empty sequence to clear it.
Source code in packages/bookshelf/src/bookshelf/_produce/books.py
publish() async #
Publish the assembled draft and update this handle in place.
write(name, obj, *, type=DEFAULT_WRITE_TYPE, used=(), data_dictionary=None, visibility=INHERIT, tags=(), metadata=None, format=None, dedupe=True) async #
Register one output and attach it under name in a single call.
The asynchronous twin of :meth:DraftBook.write, with the same bundle result.
Source code in packages/bookshelf/src/bookshelf/_produce/books.py
DraftBook #
Mutable synchronous draft-book handle.
Source code in packages/bookshelf/src/bookshelf/_produce/books.py
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 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 | |
add(*resources) #
Attach already registered resources, each under the name it registered as.
Source code in packages/bookshelf/src/bookshelf/_produce/books.py
attach(resource, *, name_in_book, data_dictionary=None) #
Attach a resource under a book-local name and optional entry dictionary.
Omitting data_dictionary preserves the dictionary on an existing entry. Pass an empty sequence to clear it.
Source code in packages/bookshelf/src/bookshelf/_produce/books.py
publish() #
Publish the assembled draft and update this handle in place.
write(name, obj, *, type=DEFAULT_WRITE_TYPE, used=(), data_dictionary=None, visibility=INHERIT, tags=(), metadata=None, format=None, dedupe=True) #
Register one output and attach it under name in a single call.
This is sugar over the layered form, and it produces the same bundle as registering inside bs.activity(...) and then calling :meth:add. The resource name and the book entry name are one name, because that is what replay addresses the resource by.
Source code in packages/bookshelf/src/bookshelf/_produce/books.py
PartialRegistrationError #
Bases: BookshelfError
A non-atomic batch committed some items and rejected others.
Source code in packages/bookshelf/src/bookshelf/_produce/types.py
RegisterItem dataclass #
One managed object to materialise as part of an activity batch.
With the default dedupe=True, byte-identical objects owned by the same organisation collapse to one canonical resource, even when their names differ. The first resource's name remains canonical.
Source code in packages/bookshelf/src/bookshelf/_produce/types.py
RegistrationFailure dataclass #
One failed item from a non-atomic registration response.
Source code in packages/bookshelf/src/bookshelf/_produce/types.py
RegistrationSuccess dataclass #
One successful item from a possibly partial registration batch.
Source code in packages/bookshelf/src/bookshelf/_produce/types.py
Used dataclass #
Resolve a resource input by the name it was registered under.
Resolution is confined to the resources registered by the same request. A resource produced by an earlier build is referenced by its tracking id instead.