A loose federation of distributed, typed datasets
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

at main 1071 lines 44 kB view raw
1<!DOCTYPE html> 2<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"><head> 3 4<meta charset="utf-8"> 5<meta name="generator" content="quarto-1.7.34"> 6 7<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes"> 8 9 10<title>blobsource – atdata</title> 11<style> 12code{white-space: pre-wrap;} 13span.smallcaps{font-variant: small-caps;} 14div.columns{display: flex; gap: min(4vw, 1.5em);} 15div.column{flex: auto; overflow-x: auto;} 16div.hanging-indent{margin-left: 1.5em; text-indent: -1.5em;} 17ul.task-list{list-style: none;} 18ul.task-list li input[type="checkbox"] { 19 width: 0.8em; 20 margin: 0 0.8em 0.2em -1em; /* quarto-specific, see https://github.com/quarto-dev/quarto-cli/issues/4556 */ 21 vertical-align: middle; 22} 23/* CSS for syntax highlighting */ 24html { -webkit-text-size-adjust: 100%; } 25pre > code.sourceCode { white-space: pre; position: relative; } 26pre > code.sourceCode > span { display: inline-block; line-height: 1.25; } 27pre > code.sourceCode > span:empty { height: 1.2em; } 28.sourceCode { overflow: visible; } 29code.sourceCode > span { color: inherit; text-decoration: inherit; } 30div.sourceCode { margin: 1em 0; } 31pre.sourceCode { margin: 0; } 32@media screen { 33div.sourceCode { overflow: auto; } 34} 35@media print { 36pre > code.sourceCode { white-space: pre-wrap; } 37pre > code.sourceCode > span { text-indent: -5em; padding-left: 5em; } 38} 39pre.numberSource code 40 { counter-reset: source-line 0; } 41pre.numberSource code > span 42 { position: relative; left: -4em; counter-increment: source-line; } 43pre.numberSource code > span > a:first-child::before 44 { content: counter(source-line); 45 position: relative; left: -1em; text-align: right; vertical-align: baseline; 46 border: none; display: inline-block; 47 -webkit-touch-callout: none; -webkit-user-select: none; 48 -khtml-user-select: none; -moz-user-select: none; 49 -ms-user-select: none; user-select: none; 50 padding: 0 4px; width: 4em; 51 } 52pre.numberSource { margin-left: 3em; padding-left: 4px; } 53div.sourceCode 54 { } 55@media screen { 56pre > code.sourceCode > span > a:first-child::before { text-decoration: underline; } 57} 58</style> 59 60 61<script src="../site_libs/quarto-nav/quarto-nav.js"></script> 62<script src="../site_libs/quarto-nav/headroom.min.js"></script> 63<script src="../site_libs/clipboard/clipboard.min.js"></script> 64<script src="../site_libs/quarto-search/autocomplete.umd.js"></script> 65<script src="../site_libs/quarto-search/fuse.min.js"></script> 66<script src="../site_libs/quarto-search/quarto-search.js"></script> 67<meta name="quarto:offset" content="../"> 68<script src="../site_libs/quarto-html/quarto.js" type="module"></script> 69<script src="../site_libs/quarto-html/tabsets/tabsets.js" type="module"></script> 70<script src="../site_libs/quarto-html/popper.min.js"></script> 71<script src="../site_libs/quarto-html/tippy.umd.min.js"></script> 72<script src="../site_libs/quarto-html/anchor.min.js"></script> 73<link href="../site_libs/quarto-html/tippy.css" rel="stylesheet"> 74<link href="../site_libs/quarto-html/quarto-syntax-highlighting-9582434199d49cc9e91654cdeeb4866b.css" rel="stylesheet" class="quarto-color-scheme" id="quarto-text-highlighting-styles"> 75<link href="../site_libs/quarto-html/quarto-syntax-highlighting-dark-8dcd8563ea6803ab7cbb3d71ca5772e1.css" rel="stylesheet" class="quarto-color-scheme quarto-color-alternate" id="quarto-text-highlighting-styles"> 76<link href="../site_libs/quarto-html/quarto-syntax-highlighting-9582434199d49cc9e91654cdeeb4866b.css" rel="stylesheet" class="quarto-color-scheme-extra" id="quarto-text-highlighting-styles"> 77<script src="../site_libs/bootstrap/bootstrap.min.js"></script> 78<link href="../site_libs/bootstrap/bootstrap-icons.css" rel="stylesheet"> 79<link href="../site_libs/bootstrap/bootstrap-62bce24ca844314e7bb1a34dbdfe05cc.min.css" rel="stylesheet" append-hash="true" class="quarto-color-scheme" id="quarto-bootstrap" data-mode="light"> 80<link href="../site_libs/bootstrap/bootstrap-dark-7964ffd8887b0991fe8d71c6c8bc75d6.min.css" rel="stylesheet" append-hash="true" class="quarto-color-scheme quarto-color-alternate" id="quarto-bootstrap" data-mode="dark"> 81<link href="../site_libs/bootstrap/bootstrap-62bce24ca844314e7bb1a34dbdfe05cc.min.css" rel="stylesheet" append-hash="true" class="quarto-color-scheme-extra" id="quarto-bootstrap" data-mode="light"> 82<script id="quarto-search-options" type="application/json">{ 83 "location": "navbar", 84 "copy-button": false, 85 "collapse-after": 3, 86 "panel-placement": "end", 87 "type": "overlay", 88 "limit": 50, 89 "keyboard-shortcut": [ 90 "f", 91 "/", 92 "s" 93 ], 94 "show-item-context": false, 95 "language": { 96 "search-no-results-text": "No results", 97 "search-matching-documents-text": "matching documents", 98 "search-copy-link-title": "Copy link to search", 99 "search-hide-matches-text": "Hide additional matches", 100 "search-more-match-text": "more match in this document", 101 "search-more-matches-text": "more matches in this document", 102 "search-clear-button-title": "Clear", 103 "search-text-placeholder": "", 104 "search-detached-cancel-button-title": "Cancel", 105 "search-submit-button-title": "Submit", 106 "search-label": "Search" 107 } 108}</script> 109 110 111<link rel="stylesheet" href="../assets/styles.css"> 112</head> 113 114<body class="nav-fixed quarto-light"><script id="quarto-html-before-body" type="application/javascript"> 115 const toggleBodyColorMode = (bsSheetEl) => { 116 const mode = bsSheetEl.getAttribute("data-mode"); 117 const bodyEl = window.document.querySelector("body"); 118 if (mode === "dark") { 119 bodyEl.classList.add("quarto-dark"); 120 bodyEl.classList.remove("quarto-light"); 121 } else { 122 bodyEl.classList.add("quarto-light"); 123 bodyEl.classList.remove("quarto-dark"); 124 } 125 } 126 const toggleBodyColorPrimary = () => { 127 const bsSheetEl = window.document.querySelector("link#quarto-bootstrap:not([rel=disabled-stylesheet])"); 128 if (bsSheetEl) { 129 toggleBodyColorMode(bsSheetEl); 130 } 131 } 132 const setColorSchemeToggle = (alternate) => { 133 const toggles = window.document.querySelectorAll('.quarto-color-scheme-toggle'); 134 for (let i=0; i < toggles.length; i++) { 135 const toggle = toggles[i]; 136 if (toggle) { 137 if (alternate) { 138 toggle.classList.add("alternate"); 139 } else { 140 toggle.classList.remove("alternate"); 141 } 142 } 143 } 144 }; 145 const toggleColorMode = (alternate) => { 146 // Switch the stylesheets 147 const primaryStylesheets = window.document.querySelectorAll('link.quarto-color-scheme:not(.quarto-color-alternate)'); 148 const alternateStylesheets = window.document.querySelectorAll('link.quarto-color-scheme.quarto-color-alternate'); 149 manageTransitions('#quarto-margin-sidebar .nav-link', false); 150 if (alternate) { 151 // note: dark is layered on light, we don't disable primary! 152 enableStylesheet(alternateStylesheets); 153 for (const sheetNode of alternateStylesheets) { 154 if (sheetNode.id === "quarto-bootstrap") { 155 toggleBodyColorMode(sheetNode); 156 } 157 } 158 } else { 159 disableStylesheet(alternateStylesheets); 160 enableStylesheet(primaryStylesheets) 161 toggleBodyColorPrimary(); 162 } 163 manageTransitions('#quarto-margin-sidebar .nav-link', true); 164 // Switch the toggles 165 setColorSchemeToggle(alternate) 166 // Hack to workaround the fact that safari doesn't 167 // properly recolor the scrollbar when toggling (#1455) 168 if (navigator.userAgent.indexOf('Safari') > 0 && navigator.userAgent.indexOf('Chrome') == -1) { 169 manageTransitions("body", false); 170 window.scrollTo(0, 1); 171 setTimeout(() => { 172 window.scrollTo(0, 0); 173 manageTransitions("body", true); 174 }, 40); 175 } 176 } 177 const disableStylesheet = (stylesheets) => { 178 for (let i=0; i < stylesheets.length; i++) { 179 const stylesheet = stylesheets[i]; 180 stylesheet.rel = 'disabled-stylesheet'; 181 } 182 } 183 const enableStylesheet = (stylesheets) => { 184 for (let i=0; i < stylesheets.length; i++) { 185 const stylesheet = stylesheets[i]; 186 if(stylesheet.rel !== 'stylesheet') { // for Chrome, which will still FOUC without this check 187 stylesheet.rel = 'stylesheet'; 188 } 189 } 190 } 191 const manageTransitions = (selector, allowTransitions) => { 192 const els = window.document.querySelectorAll(selector); 193 for (let i=0; i < els.length; i++) { 194 const el = els[i]; 195 if (allowTransitions) { 196 el.classList.remove('notransition'); 197 } else { 198 el.classList.add('notransition'); 199 } 200 } 201 } 202 const isFileUrl = () => { 203 return window.location.protocol === 'file:'; 204 } 205 const hasAlternateSentinel = () => { 206 let styleSentinel = getColorSchemeSentinel(); 207 if (styleSentinel !== null) { 208 return styleSentinel === "alternate"; 209 } else { 210 return false; 211 } 212 } 213 const setStyleSentinel = (alternate) => { 214 const value = alternate ? "alternate" : "default"; 215 if (!isFileUrl()) { 216 window.localStorage.setItem("quarto-color-scheme", value); 217 } else { 218 localAlternateSentinel = value; 219 } 220 } 221 const getColorSchemeSentinel = () => { 222 if (!isFileUrl()) { 223 const storageValue = window.localStorage.getItem("quarto-color-scheme"); 224 return storageValue != null ? storageValue : localAlternateSentinel; 225 } else { 226 return localAlternateSentinel; 227 } 228 } 229 const toggleGiscusIfUsed = (isAlternate, darkModeDefault) => { 230 const baseTheme = document.querySelector('#giscus-base-theme')?.value ?? 'light'; 231 const alternateTheme = document.querySelector('#giscus-alt-theme')?.value ?? 'dark'; 232 let newTheme = ''; 233 if(authorPrefersDark) { 234 newTheme = isAlternate ? baseTheme : alternateTheme; 235 } else { 236 newTheme = isAlternate ? alternateTheme : baseTheme; 237 } 238 const changeGiscusTheme = () => { 239 // From: https://github.com/giscus/giscus/issues/336 240 const sendMessage = (message) => { 241 const iframe = document.querySelector('iframe.giscus-frame'); 242 if (!iframe) return; 243 iframe.contentWindow.postMessage({ giscus: message }, 'https://giscus.app'); 244 } 245 sendMessage({ 246 setConfig: { 247 theme: newTheme 248 } 249 }); 250 } 251 const isGiscussLoaded = window.document.querySelector('iframe.giscus-frame') !== null; 252 if (isGiscussLoaded) { 253 changeGiscusTheme(); 254 } 255 }; 256 const authorPrefersDark = false; 257 const darkModeDefault = authorPrefersDark; 258 document.querySelector('link#quarto-text-highlighting-styles.quarto-color-scheme-extra').rel = 'disabled-stylesheet'; 259 document.querySelector('link#quarto-bootstrap.quarto-color-scheme-extra').rel = 'disabled-stylesheet'; 260 let localAlternateSentinel = darkModeDefault ? 'alternate' : 'default'; 261 // Dark / light mode switch 262 window.quartoToggleColorScheme = () => { 263 // Read the current dark / light value 264 let toAlternate = !hasAlternateSentinel(); 265 toggleColorMode(toAlternate); 266 setStyleSentinel(toAlternate); 267 toggleGiscusIfUsed(toAlternate, darkModeDefault); 268 window.dispatchEvent(new Event('resize')); 269 }; 270 // Switch to dark mode if need be 271 if (hasAlternateSentinel()) { 272 toggleColorMode(true); 273 } else { 274 toggleColorMode(false); 275 } 276 </script> 277 278<div id="quarto-search-results"></div> 279 <header id="quarto-header" class="headroom fixed-top"> 280 <nav class="navbar navbar-expand-lg " data-bs-theme="dark"> 281 <div class="navbar-container container-fluid"> 282 <div class="navbar-brand-container mx-auto"> 283 <a class="navbar-brand" href="../index.html"> 284 <span class="navbar-title">atdata</span> 285 </a> 286 </div> 287 <div id="quarto-search" class="" title="Search"></div> 288 <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarCollapse" aria-controls="navbarCollapse" role="menu" aria-expanded="false" aria-label="Toggle navigation" onclick="if (window.quartoToggleHeadroom) { window.quartoToggleHeadroom(); }"> 289 <span class="navbar-toggler-icon"></span> 290</button> 291 <div class="collapse navbar-collapse" id="navbarCollapse"> 292 <ul class="navbar-nav navbar-nav-scroll me-auto"> 293 <li class="nav-item"> 294 <a class="nav-link" href="../index.html"> 295<span class="menu-text">Guide</span></a> 296 </li> 297 <li class="nav-item dropdown "> 298 <a class="nav-link dropdown-toggle" href="#" id="nav-menu-tutorials" role="link" data-bs-toggle="dropdown" aria-expanded="false"> 299 <span class="menu-text">Tutorials</span> 300 </a> 301 <ul class="dropdown-menu" aria-labelledby="nav-menu-tutorials"> 302 <li> 303 <a class="dropdown-item" href="../tutorials/quickstart.html"> 304 <span class="dropdown-text">Quick Start</span></a> 305 </li> 306 <li> 307 <a class="dropdown-item" href="../tutorials/local-workflow.html"> 308 <span class="dropdown-text">Local Workflow</span></a> 309 </li> 310 <li> 311 <a class="dropdown-item" href="../tutorials/atmosphere.html"> 312 <span class="dropdown-text">Atmosphere Publishing</span></a> 313 </li> 314 <li> 315 <a class="dropdown-item" href="../tutorials/promotion.html"> 316 <span class="dropdown-text">Promotion Workflow</span></a> 317 </li> 318 </ul> 319 </li> 320 <li class="nav-item dropdown "> 321 <a class="nav-link dropdown-toggle" href="#" id="nav-menu-reference" role="link" data-bs-toggle="dropdown" aria-expanded="false"> 322 <span class="menu-text">Reference</span> 323 </a> 324 <ul class="dropdown-menu" aria-labelledby="nav-menu-reference"> 325 <li> 326 <a class="dropdown-item" href="../reference/architecture.html"> 327 <span class="dropdown-text">Architecture Overview</span></a> 328 </li> 329 <li> 330 <a class="dropdown-item" href="../reference/packable-samples.html"> 331 <span class="dropdown-text">Packable Samples</span></a> 332 </li> 333 <li> 334 <a class="dropdown-item" href="../reference/datasets.html"> 335 <span class="dropdown-text">Datasets</span></a> 336 </li> 337 <li> 338 <a class="dropdown-item" href="../reference/lenses.html"> 339 <span class="dropdown-text">Lenses</span></a> 340 </li> 341 <li> 342 <a class="dropdown-item" href="../reference/local-storage.html"> 343 <span class="dropdown-text">Local Storage</span></a> 344 </li> 345 <li> 346 <a class="dropdown-item" href="../reference/atmosphere.html"> 347 <span class="dropdown-text">Atmosphere</span></a> 348 </li> 349 <li> 350 <a class="dropdown-item" href="../reference/promotion.html"> 351 <span class="dropdown-text">Promotion</span></a> 352 </li> 353 <li> 354 <a class="dropdown-item" href="../reference/load-dataset.html"> 355 <span class="dropdown-text">load_dataset API</span></a> 356 </li> 357 <li> 358 <a class="dropdown-item" href="../reference/protocols.html"> 359 <span class="dropdown-text">Protocols</span></a> 360 </li> 361 <li> 362 <a class="dropdown-item" href="../reference/uri-spec.html"> 363 <span class="dropdown-text">URI Specification</span></a> 364 </li> 365 <li> 366 <a class="dropdown-item" href="../reference/troubleshooting.html"> 367 <span class="dropdown-text">Troubleshooting &amp; FAQ</span></a> 368 </li> 369 <li> 370 <a class="dropdown-item" href="../reference/deployment.html"> 371 <span class="dropdown-text">Deployment Guide</span></a> 372 </li> 373 </ul> 374 </li> 375 <li class="nav-item"> 376 <a class="nav-link" href="../api/index.html"> 377<span class="menu-text">API</span></a> 378 </li> 379</ul> 380 <ul class="navbar-nav navbar-nav-scroll ms-auto"> 381 <li class="nav-item compact"> 382 <a class="nav-link" href="https://github.com/your-org/atdata"> <i class="bi bi-github" role="img"> 383</i> 384<span class="menu-text"></span></a> 385 </li> 386</ul> 387 </div> <!-- /navcollapse --> 388 <div class="quarto-navbar-tools"> 389 <a href="" class="quarto-color-scheme-toggle quarto-navigation-tool px-1" onclick="window.quartoToggleColorScheme(); return false;" title="Toggle dark mode"><i class="bi"></i></a> 390</div> 391 </div> <!-- /container-fluid --> 392 </nav> 393</header> 394<!-- content --> 395<div id="quarto-content" class="quarto-container page-columns page-rows-contents page-layout-article page-navbar"> 396<!-- sidebar --> 397<!-- margin-sidebar --> 398 <div id="quarto-margin-sidebar" class="sidebar margin-sidebar"> 399 <nav id="TOC" role="doc-toc" class="toc-active"> 400 <h2 id="toc-title">On this page</h2> 401 402 <ul> 403 <li><a href="#atdata.BlobSource" id="toc-atdata.BlobSource" class="nav-link active" data-scroll-target="#atdata.BlobSource">BlobSource</a> 404 <ul class="collapse"> 405 <li><a href="#attributes" id="toc-attributes" class="nav-link" data-scroll-target="#attributes">Attributes</a></li> 406 <li><a href="#examples" id="toc-examples" class="nav-link" data-scroll-target="#examples">Examples</a></li> 407 <li><a href="#methods" id="toc-methods" class="nav-link" data-scroll-target="#methods">Methods</a> 408 <ul class="collapse"> 409 <li><a href="#atdata.BlobSource.from_refs" id="toc-atdata.BlobSource.from_refs" class="nav-link" data-scroll-target="#atdata.BlobSource.from_refs">from_refs</a></li> 410 <li><a href="#atdata.BlobSource.list_shards" id="toc-atdata.BlobSource.list_shards" class="nav-link" data-scroll-target="#atdata.BlobSource.list_shards">list_shards</a></li> 411 <li><a href="#atdata.BlobSource.open_shard" id="toc-atdata.BlobSource.open_shard" class="nav-link" data-scroll-target="#atdata.BlobSource.open_shard">open_shard</a></li> 412 </ul></li> 413 </ul></li> 414 </ul> 415<div class="toc-actions"><ul><li><a href="https://github.com/your-org/atdata/edit/main/api/BlobSource.qmd" class="toc-action"><i class="bi bi-github"></i>Edit this page</a></li><li><a href="https://github.com/your-org/atdata/issues/new" class="toc-action"><i class="bi empty"></i>Report an issue</a></li></ul></div></nav> 416 </div> 417<!-- main --> 418<main class="content" id="quarto-document-content"><header id="title-block-header" class="quarto-title-block"></header> 419 420 421 422 423 424<section id="atdata.BlobSource" class="level1"> 425<h1>BlobSource</h1> 426<div class="sourceCode" id="cb1"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a>BlobSource(blob_refs, pds_endpoint<span class="op">=</span><span class="va">None</span>, _endpoint_cache<span class="op">=</span><span class="bu">dict</span>())</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div> 427<p>Data source for ATProto PDS blob storage.</p> 428<p>Streams dataset shards stored as blobs on an ATProto Personal Data Server. Each shard is identified by a blob reference containing the DID and CID.</p> 429<p>This source resolves blob references to HTTP URLs and streams the content directly, supporting efficient iteration over shards without downloading everything upfront.</p> 430<section id="attributes" class="level2 doc-section doc-section-attributes"> 431<h2 class="doc-section doc-section-attributes anchored" data-anchor-id="attributes">Attributes</h2> 432<table class="caption-top table"> 433<thead> 434<tr class="header"> 435<th>Name</th> 436<th>Type</th> 437<th>Description</th> 438</tr> 439</thead> 440<tbody> 441<tr class="odd"> 442<td>blob_refs</td> 443<td><a href="`list`">list</a>[<a href="`dict`">dict</a>[<a href="`str`">str</a>, <a href="`str`">str</a>]]</td> 444<td>List of blob reference dicts with ‘did’ and ‘cid’ keys.</td> 445</tr> 446<tr class="even"> 447<td>pds_endpoint</td> 448<td><a href="`str`">str</a> | None</td> 449<td>Optional PDS endpoint URL. If not provided, resolved from DID.</td> 450</tr> 451</tbody> 452</table> 453</section> 454<section id="examples" class="level2 doc-section doc-section-examples"> 455<h2 class="doc-section doc-section-examples anchored" data-anchor-id="examples">Examples</h2> 456<div class="sourceCode" id="cb2"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb2-1"><a href="#cb2-1" aria-hidden="true" tabindex="-1"></a><span class="op">&gt;&gt;&gt;</span> source <span class="op">=</span> BlobSource(</span> 457<span id="cb2-2"><a href="#cb2-2" aria-hidden="true" tabindex="-1"></a>... blob_refs<span class="op">=</span>[</span> 458<span id="cb2-3"><a href="#cb2-3" aria-hidden="true" tabindex="-1"></a>... {<span class="st">"did"</span>: <span class="st">"did:plc:abc123"</span>, <span class="st">"cid"</span>: <span class="st">"bafyrei..."</span>},</span> 459<span id="cb2-4"><a href="#cb2-4" aria-hidden="true" tabindex="-1"></a>... {<span class="st">"did"</span>: <span class="st">"did:plc:abc123"</span>, <span class="st">"cid"</span>: <span class="st">"bafyrei..."</span>},</span> 460<span id="cb2-5"><a href="#cb2-5" aria-hidden="true" tabindex="-1"></a>... ],</span> 461<span id="cb2-6"><a href="#cb2-6" aria-hidden="true" tabindex="-1"></a>... )</span> 462<span id="cb2-7"><a href="#cb2-7" aria-hidden="true" tabindex="-1"></a><span class="op">&gt;&gt;&gt;</span> <span class="cf">for</span> shard_id, stream <span class="kw">in</span> source.shards:</span> 463<span id="cb2-8"><a href="#cb2-8" aria-hidden="true" tabindex="-1"></a>... process(stream)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div> 464</section> 465<section id="methods" class="level2"> 466<h2 class="anchored" data-anchor-id="methods">Methods</h2> 467<table class="caption-top table"> 468<thead> 469<tr class="header"> 470<th>Name</th> 471<th>Description</th> 472</tr> 473</thead> 474<tbody> 475<tr class="odd"> 476<td><a href="#atdata.BlobSource.from_refs">from_refs</a></td> 477<td>Create BlobSource from blob reference dicts.</td> 478</tr> 479<tr class="even"> 480<td><a href="#atdata.BlobSource.list_shards">list_shards</a></td> 481<td>Return list of AT URI-style shard identifiers.</td> 482</tr> 483<tr class="odd"> 484<td><a href="#atdata.BlobSource.open_shard">open_shard</a></td> 485<td>Open a single shard by its AT URI.</td> 486</tr> 487</tbody> 488</table> 489<section id="atdata.BlobSource.from_refs" class="level3"> 490<h3 class="anchored" data-anchor-id="atdata.BlobSource.from_refs">from_refs</h3> 491<div class="sourceCode" id="cb3"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb3-1"><a href="#cb3-1" aria-hidden="true" tabindex="-1"></a>BlobSource.from_refs(refs, <span class="op">*</span>, pds_endpoint<span class="op">=</span><span class="va">None</span>)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div> 492<p>Create BlobSource from blob reference dicts.</p> 493<p>Accepts blob references in the format returned by upload_blob: <code>{"$type": "blob", "ref": {"$link": "cid"}, ...}</code></p> 494<p>Also accepts simplified format: <code>{"did": "...", "cid": "..."}</code></p> 495<section id="parameters" class="level4 doc-section doc-section-parameters"> 496<h4 class="doc-section doc-section-parameters anchored" data-anchor-id="parameters">Parameters</h4> 497<table class="caption-top table"> 498<thead> 499<tr class="header"> 500<th>Name</th> 501<th>Type</th> 502<th>Description</th> 503<th>Default</th> 504</tr> 505</thead> 506<tbody> 507<tr class="odd"> 508<td>refs</td> 509<td><a href="`list`">list</a>[<a href="`dict`">dict</a>]</td> 510<td>List of blob reference dicts.</td> 511<td><em>required</em></td> 512</tr> 513<tr class="even"> 514<td>pds_endpoint</td> 515<td><a href="`str`">str</a> | None</td> 516<td>Optional PDS endpoint to use for all blobs.</td> 517<td><code>None</code></td> 518</tr> 519</tbody> 520</table> 521</section> 522<section id="returns" class="level4 doc-section doc-section-returns"> 523<h4 class="doc-section doc-section-returns anchored" data-anchor-id="returns">Returns</h4> 524<table class="caption-top table"> 525<thead> 526<tr class="header"> 527<th>Name</th> 528<th>Type</th> 529<th>Description</th> 530</tr> 531</thead> 532<tbody> 533<tr class="odd"> 534<td></td> 535<td>'BlobSource'</td> 536<td>Configured BlobSource.</td> 537</tr> 538</tbody> 539</table> 540</section> 541<section id="raises" class="level4 doc-section doc-section-raises"> 542<h4 class="doc-section doc-section-raises anchored" data-anchor-id="raises">Raises</h4> 543<table class="caption-top table"> 544<thead> 545<tr class="header"> 546<th>Name</th> 547<th>Type</th> 548<th>Description</th> 549</tr> 550</thead> 551<tbody> 552<tr class="odd"> 553<td></td> 554<td><a href="`ValueError`">ValueError</a></td> 555<td>If refs is empty or format is invalid.</td> 556</tr> 557</tbody> 558</table> 559</section> 560</section> 561<section id="atdata.BlobSource.list_shards" class="level3"> 562<h3 class="anchored" data-anchor-id="atdata.BlobSource.list_shards">list_shards</h3> 563<div class="sourceCode" id="cb4"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb4-1"><a href="#cb4-1" aria-hidden="true" tabindex="-1"></a>BlobSource.list_shards()</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div> 564<p>Return list of AT URI-style shard identifiers.</p> 565</section> 566<section id="atdata.BlobSource.open_shard" class="level3"> 567<h3 class="anchored" data-anchor-id="atdata.BlobSource.open_shard">open_shard</h3> 568<div class="sourceCode" id="cb5"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb5-1"><a href="#cb5-1" aria-hidden="true" tabindex="-1"></a>BlobSource.open_shard(shard_id)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div> 569<p>Open a single shard by its AT URI.</p> 570<section id="parameters-1" class="level4 doc-section doc-section-parameters"> 571<h4 class="doc-section doc-section-parameters anchored" data-anchor-id="parameters-1">Parameters</h4> 572<table class="caption-top table"> 573<thead> 574<tr class="header"> 575<th>Name</th> 576<th>Type</th> 577<th>Description</th> 578<th>Default</th> 579</tr> 580</thead> 581<tbody> 582<tr class="odd"> 583<td>shard_id</td> 584<td><a href="`str`">str</a></td> 585<td>AT URI of the shard (at://did/blob/cid).</td> 586<td><em>required</em></td> 587</tr> 588</tbody> 589</table> 590</section> 591<section id="returns-1" class="level4 doc-section doc-section-returns"> 592<h4 class="doc-section doc-section-returns anchored" data-anchor-id="returns-1">Returns</h4> 593<table class="caption-top table"> 594<thead> 595<tr class="header"> 596<th>Name</th> 597<th>Type</th> 598<th>Description</th> 599</tr> 600</thead> 601<tbody> 602<tr class="odd"> 603<td></td> 604<td><a href="`typing.IO`">IO</a>[<a href="`bytes`">bytes</a>]</td> 605<td>Streaming response body for reading the blob.</td> 606</tr> 607</tbody> 608</table> 609</section> 610<section id="raises-1" class="level4 doc-section doc-section-raises"> 611<h4 class="doc-section doc-section-raises anchored" data-anchor-id="raises-1">Raises</h4> 612<table class="caption-top table"> 613<thead> 614<tr class="header"> 615<th>Name</th> 616<th>Type</th> 617<th>Description</th> 618</tr> 619</thead> 620<tbody> 621<tr class="odd"> 622<td></td> 623<td><a href="`KeyError`">KeyError</a></td> 624<td>If shard_id is not in list_shards().</td> 625</tr> 626<tr class="even"> 627<td></td> 628<td><a href="`ValueError`">ValueError</a></td> 629<td>If shard_id format is invalid.</td> 630</tr> 631</tbody> 632</table> 633 634 635</section> 636</section> 637</section> 638</section> 639 640</main> <!-- /main --> 641<script id="quarto-html-after-body" type="application/javascript"> 642 window.document.addEventListener("DOMContentLoaded", function (event) { 643 // Ensure there is a toggle, if there isn't float one in the top right 644 if (window.document.querySelector('.quarto-color-scheme-toggle') === null) { 645 const a = window.document.createElement('a'); 646 a.classList.add('top-right'); 647 a.classList.add('quarto-color-scheme-toggle'); 648 a.href = ""; 649 a.onclick = function() { try { window.quartoToggleColorScheme(); } catch {} return false; }; 650 const i = window.document.createElement("i"); 651 i.classList.add('bi'); 652 a.appendChild(i); 653 window.document.body.appendChild(a); 654 } 655 setColorSchemeToggle(hasAlternateSentinel()) 656 const icon = ""; 657 const anchorJS = new window.AnchorJS(); 658 anchorJS.options = { 659 placement: 'right', 660 icon: icon 661 }; 662 anchorJS.add('.anchored'); 663 const isCodeAnnotation = (el) => { 664 for (const clz of el.classList) { 665 if (clz.startsWith('code-annotation-')) { 666 return true; 667 } 668 } 669 return false; 670 } 671 const onCopySuccess = function(e) { 672 // button target 673 const button = e.trigger; 674 // don't keep focus 675 button.blur(); 676 // flash "checked" 677 button.classList.add('code-copy-button-checked'); 678 var currentTitle = button.getAttribute("title"); 679 button.setAttribute("title", "Copied!"); 680 let tooltip; 681 if (window.bootstrap) { 682 button.setAttribute("data-bs-toggle", "tooltip"); 683 button.setAttribute("data-bs-placement", "left"); 684 button.setAttribute("data-bs-title", "Copied!"); 685 tooltip = new bootstrap.Tooltip(button, 686 { trigger: "manual", 687 customClass: "code-copy-button-tooltip", 688 offset: [0, -8]}); 689 tooltip.show(); 690 } 691 setTimeout(function() { 692 if (tooltip) { 693 tooltip.hide(); 694 button.removeAttribute("data-bs-title"); 695 button.removeAttribute("data-bs-toggle"); 696 button.removeAttribute("data-bs-placement"); 697 } 698 button.setAttribute("title", currentTitle); 699 button.classList.remove('code-copy-button-checked'); 700 }, 1000); 701 // clear code selection 702 e.clearSelection(); 703 } 704 const getTextToCopy = function(trigger) { 705 const codeEl = trigger.previousElementSibling.cloneNode(true); 706 for (const childEl of codeEl.children) { 707 if (isCodeAnnotation(childEl)) { 708 childEl.remove(); 709 } 710 } 711 return codeEl.innerText; 712 } 713 const clipboard = new window.ClipboardJS('.code-copy-button:not([data-in-quarto-modal])', { 714 text: getTextToCopy 715 }); 716 clipboard.on('success', onCopySuccess); 717 if (window.document.getElementById('quarto-embedded-source-code-modal')) { 718 const clipboardModal = new window.ClipboardJS('.code-copy-button[data-in-quarto-modal]', { 719 text: getTextToCopy, 720 container: window.document.getElementById('quarto-embedded-source-code-modal') 721 }); 722 clipboardModal.on('success', onCopySuccess); 723 } 724 var localhostRegex = new RegExp(/^(?:http|https):\/\/localhost\:?[0-9]*\//); 725 var mailtoRegex = new RegExp(/^mailto:/); 726 var filterRegex = new RegExp("https:\/\/github\.com\/your-org\/atdata"); 727 var isInternal = (href) => { 728 return filterRegex.test(href) || localhostRegex.test(href) || mailtoRegex.test(href); 729 } 730 // Inspect non-navigation links and adorn them if external 731 var links = window.document.querySelectorAll('a[href]:not(.nav-link):not(.navbar-brand):not(.toc-action):not(.sidebar-link):not(.sidebar-item-toggle):not(.pagination-link):not(.no-external):not([aria-hidden]):not(.dropdown-item):not(.quarto-navigation-tool):not(.about-link)'); 732 for (var i=0; i<links.length; i++) { 733 const link = links[i]; 734 if (!isInternal(link.href)) { 735 // undo the damage that might have been done by quarto-nav.js in the case of 736 // links that we want to consider external 737 if (link.dataset.originalHref !== undefined) { 738 link.href = link.dataset.originalHref; 739 } 740 } 741 } 742 function tippyHover(el, contentFn, onTriggerFn, onUntriggerFn) { 743 const config = { 744 allowHTML: true, 745 maxWidth: 500, 746 delay: 100, 747 arrow: false, 748 appendTo: function(el) { 749 return el.parentElement; 750 }, 751 interactive: true, 752 interactiveBorder: 10, 753 theme: 'quarto', 754 placement: 'bottom-start', 755 }; 756 if (contentFn) { 757 config.content = contentFn; 758 } 759 if (onTriggerFn) { 760 config.onTrigger = onTriggerFn; 761 } 762 if (onUntriggerFn) { 763 config.onUntrigger = onUntriggerFn; 764 } 765 window.tippy(el, config); 766 } 767 const noterefs = window.document.querySelectorAll('a[role="doc-noteref"]'); 768 for (var i=0; i<noterefs.length; i++) { 769 const ref = noterefs[i]; 770 tippyHover(ref, function() { 771 // use id or data attribute instead here 772 let href = ref.getAttribute('data-footnote-href') || ref.getAttribute('href'); 773 try { href = new URL(href).hash; } catch {} 774 const id = href.replace(/^#\/?/, ""); 775 const note = window.document.getElementById(id); 776 if (note) { 777 return note.innerHTML; 778 } else { 779 return ""; 780 } 781 }); 782 } 783 const xrefs = window.document.querySelectorAll('a.quarto-xref'); 784 const processXRef = (id, note) => { 785 // Strip column container classes 786 const stripColumnClz = (el) => { 787 el.classList.remove("page-full", "page-columns"); 788 if (el.children) { 789 for (const child of el.children) { 790 stripColumnClz(child); 791 } 792 } 793 } 794 stripColumnClz(note) 795 if (id === null || id.startsWith('sec-')) { 796 // Special case sections, only their first couple elements 797 const container = document.createElement("div"); 798 if (note.children && note.children.length > 2) { 799 container.appendChild(note.children[0].cloneNode(true)); 800 for (let i = 1; i < note.children.length; i++) { 801 const child = note.children[i]; 802 if (child.tagName === "P" && child.innerText === "") { 803 continue; 804 } else { 805 container.appendChild(child.cloneNode(true)); 806 break; 807 } 808 } 809 if (window.Quarto?.typesetMath) { 810 window.Quarto.typesetMath(container); 811 } 812 return container.innerHTML 813 } else { 814 if (window.Quarto?.typesetMath) { 815 window.Quarto.typesetMath(note); 816 } 817 return note.innerHTML; 818 } 819 } else { 820 // Remove any anchor links if they are present 821 const anchorLink = note.querySelector('a.anchorjs-link'); 822 if (anchorLink) { 823 anchorLink.remove(); 824 } 825 if (window.Quarto?.typesetMath) { 826 window.Quarto.typesetMath(note); 827 } 828 if (note.classList.contains("callout")) { 829 return note.outerHTML; 830 } else { 831 return note.innerHTML; 832 } 833 } 834 } 835 for (var i=0; i<xrefs.length; i++) { 836 const xref = xrefs[i]; 837 tippyHover(xref, undefined, function(instance) { 838 instance.disable(); 839 let url = xref.getAttribute('href'); 840 let hash = undefined; 841 if (url.startsWith('#')) { 842 hash = url; 843 } else { 844 try { hash = new URL(url).hash; } catch {} 845 } 846 if (hash) { 847 const id = hash.replace(/^#\/?/, ""); 848 const note = window.document.getElementById(id); 849 if (note !== null) { 850 try { 851 const html = processXRef(id, note.cloneNode(true)); 852 instance.setContent(html); 853 } finally { 854 instance.enable(); 855 instance.show(); 856 } 857 } else { 858 // See if we can fetch this 859 fetch(url.split('#')[0]) 860 .then(res => res.text()) 861 .then(html => { 862 const parser = new DOMParser(); 863 const htmlDoc = parser.parseFromString(html, "text/html"); 864 const note = htmlDoc.getElementById(id); 865 if (note !== null) { 866 const html = processXRef(id, note); 867 instance.setContent(html); 868 } 869 }).finally(() => { 870 instance.enable(); 871 instance.show(); 872 }); 873 } 874 } else { 875 // See if we can fetch a full url (with no hash to target) 876 // This is a special case and we should probably do some content thinning / targeting 877 fetch(url) 878 .then(res => res.text()) 879 .then(html => { 880 const parser = new DOMParser(); 881 const htmlDoc = parser.parseFromString(html, "text/html"); 882 const note = htmlDoc.querySelector('main.content'); 883 if (note !== null) { 884 // This should only happen for chapter cross references 885 // (since there is no id in the URL) 886 // remove the first header 887 if (note.children.length > 0 && note.children[0].tagName === "HEADER") { 888 note.children[0].remove(); 889 } 890 const html = processXRef(null, note); 891 instance.setContent(html); 892 } 893 }).finally(() => { 894 instance.enable(); 895 instance.show(); 896 }); 897 } 898 }, function(instance) { 899 }); 900 } 901 let selectedAnnoteEl; 902 const selectorForAnnotation = ( cell, annotation) => { 903 let cellAttr = 'data-code-cell="' + cell + '"'; 904 let lineAttr = 'data-code-annotation="' + annotation + '"'; 905 const selector = 'span[' + cellAttr + '][' + lineAttr + ']'; 906 return selector; 907 } 908 const selectCodeLines = (annoteEl) => { 909 const doc = window.document; 910 const targetCell = annoteEl.getAttribute("data-target-cell"); 911 const targetAnnotation = annoteEl.getAttribute("data-target-annotation"); 912 const annoteSpan = window.document.querySelector(selectorForAnnotation(targetCell, targetAnnotation)); 913 const lines = annoteSpan.getAttribute("data-code-lines").split(","); 914 const lineIds = lines.map((line) => { 915 return targetCell + "-" + line; 916 }) 917 let top = null; 918 let height = null; 919 let parent = null; 920 if (lineIds.length > 0) { 921 //compute the position of the single el (top and bottom and make a div) 922 const el = window.document.getElementById(lineIds[0]); 923 top = el.offsetTop; 924 height = el.offsetHeight; 925 parent = el.parentElement.parentElement; 926 if (lineIds.length > 1) { 927 const lastEl = window.document.getElementById(lineIds[lineIds.length - 1]); 928 const bottom = lastEl.offsetTop + lastEl.offsetHeight; 929 height = bottom - top; 930 } 931 if (top !== null && height !== null && parent !== null) { 932 // cook up a div (if necessary) and position it 933 let div = window.document.getElementById("code-annotation-line-highlight"); 934 if (div === null) { 935 div = window.document.createElement("div"); 936 div.setAttribute("id", "code-annotation-line-highlight"); 937 div.style.position = 'absolute'; 938 parent.appendChild(div); 939 } 940 div.style.top = top - 2 + "px"; 941 div.style.height = height + 4 + "px"; 942 div.style.left = 0; 943 let gutterDiv = window.document.getElementById("code-annotation-line-highlight-gutter"); 944 if (gutterDiv === null) { 945 gutterDiv = window.document.createElement("div"); 946 gutterDiv.setAttribute("id", "code-annotation-line-highlight-gutter"); 947 gutterDiv.style.position = 'absolute'; 948 const codeCell = window.document.getElementById(targetCell); 949 const gutter = codeCell.querySelector('.code-annotation-gutter'); 950 gutter.appendChild(gutterDiv); 951 } 952 gutterDiv.style.top = top - 2 + "px"; 953 gutterDiv.style.height = height + 4 + "px"; 954 } 955 selectedAnnoteEl = annoteEl; 956 } 957 }; 958 const unselectCodeLines = () => { 959 const elementsIds = ["code-annotation-line-highlight", "code-annotation-line-highlight-gutter"]; 960 elementsIds.forEach((elId) => { 961 const div = window.document.getElementById(elId); 962 if (div) { 963 div.remove(); 964 } 965 }); 966 selectedAnnoteEl = undefined; 967 }; 968 // Handle positioning of the toggle 969 window.addEventListener( 970 "resize", 971 throttle(() => { 972 elRect = undefined; 973 if (selectedAnnoteEl) { 974 selectCodeLines(selectedAnnoteEl); 975 } 976 }, 10) 977 ); 978 function throttle(fn, ms) { 979 let throttle = false; 980 let timer; 981 return (...args) => { 982 if(!throttle) { // first call gets through 983 fn.apply(this, args); 984 throttle = true; 985 } else { // all the others get throttled 986 if(timer) clearTimeout(timer); // cancel #2 987 timer = setTimeout(() => { 988 fn.apply(this, args); 989 timer = throttle = false; 990 }, ms); 991 } 992 }; 993 } 994 // Attach click handler to the DT 995 const annoteDls = window.document.querySelectorAll('dt[data-target-cell]'); 996 for (const annoteDlNode of annoteDls) { 997 annoteDlNode.addEventListener('click', (event) => { 998 const clickedEl = event.target; 999 if (clickedEl !== selectedAnnoteEl) { 1000 unselectCodeLines(); 1001 const activeEl = window.document.querySelector('dt[data-target-cell].code-annotation-active'); 1002 if (activeEl) { 1003 activeEl.classList.remove('code-annotation-active'); 1004 } 1005 selectCodeLines(clickedEl); 1006 clickedEl.classList.add('code-annotation-active'); 1007 } else { 1008 // Unselect the line 1009 unselectCodeLines(); 1010 clickedEl.classList.remove('code-annotation-active'); 1011 } 1012 }); 1013 } 1014 const findCites = (el) => { 1015 const parentEl = el.parentElement; 1016 if (parentEl) { 1017 const cites = parentEl.dataset.cites; 1018 if (cites) { 1019 return { 1020 el, 1021 cites: cites.split(' ') 1022 }; 1023 } else { 1024 return findCites(el.parentElement) 1025 } 1026 } else { 1027 return undefined; 1028 } 1029 }; 1030 var bibliorefs = window.document.querySelectorAll('a[role="doc-biblioref"]'); 1031 for (var i=0; i<bibliorefs.length; i++) { 1032 const ref = bibliorefs[i]; 1033 const citeInfo = findCites(ref); 1034 if (citeInfo) { 1035 tippyHover(citeInfo.el, function() { 1036 var popup = window.document.createElement('div'); 1037 citeInfo.cites.forEach(function(cite) { 1038 var citeDiv = window.document.createElement('div'); 1039 citeDiv.classList.add('hanging-indent'); 1040 citeDiv.classList.add('csl-entry'); 1041 var biblioDiv = window.document.getElementById('ref-' + cite); 1042 if (biblioDiv) { 1043 citeDiv.innerHTML = biblioDiv.innerHTML; 1044 } 1045 popup.appendChild(citeDiv); 1046 }); 1047 return popup.innerHTML; 1048 }); 1049 } 1050 } 1051 }); 1052 </script> 1053</div> <!-- /content --> 1054<footer class="footer"> 1055 <div class="nav-footer"> 1056 <div class="nav-footer-left"> 1057<p>Built with <a href="https://quarto.org/">Quarto</a></p> 1058</div> 1059 <div class="nav-footer-center"> 1060 &nbsp; 1061 <div class="toc-actions d-sm-block d-md-none"><ul><li><a href="https://github.com/your-org/atdata/edit/main/api/BlobSource.qmd" class="toc-action"><i class="bi bi-github"></i>Edit this page</a></li><li><a href="https://github.com/your-org/atdata/issues/new" class="toc-action"><i class="bi empty"></i>Report an issue</a></li></ul></div></div> 1062 <div class="nav-footer-right"> 1063<p>MIT License</p> 1064</div> 1065 </div> 1066</footer> 1067 1068 1069 1070 1071</body></html>