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 1356 lines 57 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>abstractindex – 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.AbstractIndex" id="toc-atdata.AbstractIndex" class="nav-link active" data-scroll-target="#atdata.AbstractIndex">AbstractIndex</a> 404 <ul class="collapse"> 405 <li><a href="#optional-extensions" id="toc-optional-extensions" class="nav-link" data-scroll-target="#optional-extensions">Optional Extensions</a></li> 406 <li><a href="#examples" id="toc-examples" class="nav-link" data-scroll-target="#examples">Examples</a></li> 407 <li><a href="#attributes" id="toc-attributes" class="nav-link" data-scroll-target="#attributes">Attributes</a></li> 408 <li><a href="#methods" id="toc-methods" class="nav-link" data-scroll-target="#methods">Methods</a> 409 <ul class="collapse"> 410 <li><a href="#atdata.AbstractIndex.decode_schema" id="toc-atdata.AbstractIndex.decode_schema" class="nav-link" data-scroll-target="#atdata.AbstractIndex.decode_schema">decode_schema</a></li> 411 <li><a href="#atdata.AbstractIndex.get_dataset" id="toc-atdata.AbstractIndex.get_dataset" class="nav-link" data-scroll-target="#atdata.AbstractIndex.get_dataset">get_dataset</a></li> 412 <li><a href="#atdata.AbstractIndex.get_schema" id="toc-atdata.AbstractIndex.get_schema" class="nav-link" data-scroll-target="#atdata.AbstractIndex.get_schema">get_schema</a></li> 413 <li><a href="#atdata.AbstractIndex.insert_dataset" id="toc-atdata.AbstractIndex.insert_dataset" class="nav-link" data-scroll-target="#atdata.AbstractIndex.insert_dataset">insert_dataset</a></li> 414 <li><a href="#atdata.AbstractIndex.list_datasets" id="toc-atdata.AbstractIndex.list_datasets" class="nav-link" data-scroll-target="#atdata.AbstractIndex.list_datasets">list_datasets</a></li> 415 <li><a href="#atdata.AbstractIndex.list_schemas" id="toc-atdata.AbstractIndex.list_schemas" class="nav-link" data-scroll-target="#atdata.AbstractIndex.list_schemas">list_schemas</a></li> 416 <li><a href="#atdata.AbstractIndex.publish_schema" id="toc-atdata.AbstractIndex.publish_schema" class="nav-link" data-scroll-target="#atdata.AbstractIndex.publish_schema">publish_schema</a></li> 417 </ul></li> 418 </ul></li> 419 </ul> 420<div class="toc-actions"><ul><li><a href="https://github.com/your-org/atdata/edit/main/api/AbstractIndex.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> 421 </div> 422<!-- main --> 423<main class="content" id="quarto-document-content"><header id="title-block-header" class="quarto-title-block"></header> 424 425 426 427 428 429<section id="atdata.AbstractIndex" class="level1"> 430<h1>AbstractIndex</h1> 431<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>AbstractIndex()</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div> 432<p>Protocol for index operations - implemented by LocalIndex and AtmosphereIndex.</p> 433<p>This protocol defines the common interface for managing dataset metadata: - Publishing and retrieving schemas - Inserting and listing datasets - (Future) Publishing and retrieving lenses</p> 434<p>A single index can hold datasets of many different sample types. The sample type is tracked via schema references, not as a generic parameter on the index.</p> 435<section id="optional-extensions" class="level2 doc-section doc-section-optional-extensions"> 436<h2 class="doc-section doc-section-optional-extensions anchored" data-anchor-id="optional-extensions">Optional Extensions</h2> 437<p>Some index implementations support additional features: - <code>data_store</code>: An AbstractDataStore for reading/writing dataset shards. If present, <code>load_dataset</code> will use it for S3 credential resolution.</p> 438</section> 439<section id="examples" class="level2 doc-section doc-section-examples"> 440<h2 class="doc-section doc-section-examples anchored" data-anchor-id="examples">Examples</h2> 441<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> <span class="kw">def</span> publish_and_list(index: AbstractIndex) <span class="op">-&gt;</span> <span class="va">None</span>:</span> 442<span id="cb2-2"><a href="#cb2-2" aria-hidden="true" tabindex="-1"></a>... <span class="co"># Publish schemas for different types</span></span> 443<span id="cb2-3"><a href="#cb2-3" aria-hidden="true" tabindex="-1"></a>... schema1 <span class="op">=</span> index.publish_schema(ImageSample, version<span class="op">=</span><span class="st">"1.0.0"</span>)</span> 444<span id="cb2-4"><a href="#cb2-4" aria-hidden="true" tabindex="-1"></a>... schema2 <span class="op">=</span> index.publish_schema(TextSample, version<span class="op">=</span><span class="st">"1.0.0"</span>)</span> 445<span id="cb2-5"><a href="#cb2-5" aria-hidden="true" tabindex="-1"></a>...</span> 446<span id="cb2-6"><a href="#cb2-6" aria-hidden="true" tabindex="-1"></a>... <span class="co"># Insert datasets of different types</span></span> 447<span id="cb2-7"><a href="#cb2-7" aria-hidden="true" tabindex="-1"></a>... index.insert_dataset(image_ds, name<span class="op">=</span><span class="st">"images"</span>)</span> 448<span id="cb2-8"><a href="#cb2-8" aria-hidden="true" tabindex="-1"></a>... index.insert_dataset(text_ds, name<span class="op">=</span><span class="st">"texts"</span>)</span> 449<span id="cb2-9"><a href="#cb2-9" aria-hidden="true" tabindex="-1"></a>...</span> 450<span id="cb2-10"><a href="#cb2-10" aria-hidden="true" tabindex="-1"></a>... <span class="co"># List all datasets (mixed types)</span></span> 451<span id="cb2-11"><a href="#cb2-11" aria-hidden="true" tabindex="-1"></a>... <span class="cf">for</span> entry <span class="kw">in</span> index.list_datasets():</span> 452<span id="cb2-12"><a href="#cb2-12" aria-hidden="true" tabindex="-1"></a>... <span class="bu">print</span>(<span class="ss">f"</span><span class="sc">{</span>entry<span class="sc">.</span>name<span class="sc">}</span><span class="ss"> -&gt; </span><span class="sc">{</span>entry<span class="sc">.</span>schema_ref<span class="sc">}</span><span class="ss">"</span>)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div> 453</section> 454<section id="attributes" class="level2"> 455<h2 class="anchored" data-anchor-id="attributes">Attributes</h2> 456<table class="caption-top table"> 457<thead> 458<tr class="header"> 459<th>Name</th> 460<th>Description</th> 461</tr> 462</thead> 463<tbody> 464<tr class="odd"> 465<td><a href="#atdata.AbstractIndex.data_store">data_store</a></td> 466<td>Optional data store for reading/writing shards.</td> 467</tr> 468<tr class="even"> 469<td><a href="#atdata.AbstractIndex.datasets">datasets</a></td> 470<td>Lazily iterate over all dataset entries in this index.</td> 471</tr> 472<tr class="odd"> 473<td><a href="#atdata.AbstractIndex.schemas">schemas</a></td> 474<td>Lazily iterate over all schema records in this index.</td> 475</tr> 476</tbody> 477</table> 478</section> 479<section id="methods" class="level2"> 480<h2 class="anchored" data-anchor-id="methods">Methods</h2> 481<table class="caption-top table"> 482<thead> 483<tr class="header"> 484<th>Name</th> 485<th>Description</th> 486</tr> 487</thead> 488<tbody> 489<tr class="odd"> 490<td><a href="#atdata.AbstractIndex.decode_schema">decode_schema</a></td> 491<td>Reconstruct a Python Packable type from a stored schema.</td> 492</tr> 493<tr class="even"> 494<td><a href="#atdata.AbstractIndex.get_dataset">get_dataset</a></td> 495<td>Get a dataset entry by name or reference.</td> 496</tr> 497<tr class="odd"> 498<td><a href="#atdata.AbstractIndex.get_schema">get_schema</a></td> 499<td>Get a schema record by reference.</td> 500</tr> 501<tr class="even"> 502<td><a href="#atdata.AbstractIndex.insert_dataset">insert_dataset</a></td> 503<td>Insert a dataset into the index.</td> 504</tr> 505<tr class="odd"> 506<td><a href="#atdata.AbstractIndex.list_datasets">list_datasets</a></td> 507<td>Get all dataset entries as a materialized list.</td> 508</tr> 509<tr class="even"> 510<td><a href="#atdata.AbstractIndex.list_schemas">list_schemas</a></td> 511<td>Get all schema records as a materialized list.</td> 512</tr> 513<tr class="odd"> 514<td><a href="#atdata.AbstractIndex.publish_schema">publish_schema</a></td> 515<td>Publish a schema for a sample type.</td> 516</tr> 517</tbody> 518</table> 519<section id="atdata.AbstractIndex.decode_schema" class="level3"> 520<h3 class="anchored" data-anchor-id="atdata.AbstractIndex.decode_schema">decode_schema</h3> 521<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>AbstractIndex.decode_schema(ref)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div> 522<p>Reconstruct a Python Packable type from a stored schema.</p> 523<p>This method enables loading datasets without knowing the sample type ahead of time. The index retrieves the schema record and dynamically generates a Packable class matching the schema definition.</p> 524<section id="parameters" class="level4 doc-section doc-section-parameters"> 525<h4 class="doc-section doc-section-parameters anchored" data-anchor-id="parameters">Parameters</h4> 526<table class="caption-top table"> 527<thead> 528<tr class="header"> 529<th>Name</th> 530<th>Type</th> 531<th>Description</th> 532<th>Default</th> 533</tr> 534</thead> 535<tbody> 536<tr class="odd"> 537<td>ref</td> 538<td><a href="`str`">str</a></td> 539<td>Schema reference string (local:// or at://).</td> 540<td><em>required</em></td> 541</tr> 542</tbody> 543</table> 544</section> 545<section id="returns" class="level4 doc-section doc-section-returns"> 546<h4 class="doc-section doc-section-returns anchored" data-anchor-id="returns">Returns</h4> 547<table class="caption-top table"> 548<thead> 549<tr class="header"> 550<th>Name</th> 551<th>Type</th> 552<th>Description</th> 553</tr> 554</thead> 555<tbody> 556<tr class="odd"> 557<td></td> 558<td><a href="`typing.Type`">Type</a>[<a href="`atdata._protocols.Packable`">Packable</a>]</td> 559<td>A dynamically generated Packable class with fields matching</td> 560</tr> 561<tr class="even"> 562<td></td> 563<td><a href="`typing.Type`">Type</a>[<a href="`atdata._protocols.Packable`">Packable</a>]</td> 564<td>the schema definition. The class can be used with</td> 565</tr> 566<tr class="odd"> 567<td></td> 568<td><a href="`typing.Type`">Type</a>[<a href="`atdata._protocols.Packable`">Packable</a>]</td> 569<td><code>Dataset[T]</code> to load and iterate over samples.</td> 570</tr> 571</tbody> 572</table> 573</section> 574<section id="raises" class="level4 doc-section doc-section-raises"> 575<h4 class="doc-section doc-section-raises anchored" data-anchor-id="raises">Raises</h4> 576<table class="caption-top table"> 577<thead> 578<tr class="header"> 579<th>Name</th> 580<th>Type</th> 581<th>Description</th> 582</tr> 583</thead> 584<tbody> 585<tr class="odd"> 586<td></td> 587<td><a href="`KeyError`">KeyError</a></td> 588<td>If schema not found.</td> 589</tr> 590<tr class="even"> 591<td></td> 592<td><a href="`ValueError`">ValueError</a></td> 593<td>If schema cannot be decoded (unsupported field types).</td> 594</tr> 595</tbody> 596</table> 597</section> 598<section id="examples-1" class="level4 doc-section doc-section-examples"> 599<h4 class="doc-section doc-section-examples anchored" data-anchor-id="examples-1">Examples</h4> 600<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><span class="op">&gt;&gt;&gt;</span> entry <span class="op">=</span> index.get_dataset(<span class="st">"my-dataset"</span>)</span> 601<span id="cb4-2"><a href="#cb4-2" aria-hidden="true" tabindex="-1"></a><span class="op">&gt;&gt;&gt;</span> SampleType <span class="op">=</span> index.decode_schema(entry.schema_ref)</span> 602<span id="cb4-3"><a href="#cb4-3" aria-hidden="true" tabindex="-1"></a><span class="op">&gt;&gt;&gt;</span> ds <span class="op">=</span> Dataset[SampleType](entry.data_urls[<span class="dv">0</span>])</span> 603<span id="cb4-4"><a href="#cb4-4" aria-hidden="true" tabindex="-1"></a><span class="op">&gt;&gt;&gt;</span> <span class="cf">for</span> sample <span class="kw">in</span> ds.ordered():</span> 604<span id="cb4-5"><a href="#cb4-5" aria-hidden="true" tabindex="-1"></a>... <span class="bu">print</span>(sample) <span class="co"># sample is instance of SampleType</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div> 605</section> 606</section> 607<section id="atdata.AbstractIndex.get_dataset" class="level3"> 608<h3 class="anchored" data-anchor-id="atdata.AbstractIndex.get_dataset">get_dataset</h3> 609<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>AbstractIndex.get_dataset(ref)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div> 610<p>Get a dataset entry by name or reference.</p> 611<section id="parameters-1" class="level4 doc-section doc-section-parameters"> 612<h4 class="doc-section doc-section-parameters anchored" data-anchor-id="parameters-1">Parameters</h4> 613<table class="caption-top table"> 614<thead> 615<tr class="header"> 616<th>Name</th> 617<th>Type</th> 618<th>Description</th> 619<th>Default</th> 620</tr> 621</thead> 622<tbody> 623<tr class="odd"> 624<td>ref</td> 625<td><a href="`str`">str</a></td> 626<td>Dataset name, path, or full reference string.</td> 627<td><em>required</em></td> 628</tr> 629</tbody> 630</table> 631</section> 632<section id="returns-1" class="level4 doc-section doc-section-returns"> 633<h4 class="doc-section doc-section-returns anchored" data-anchor-id="returns-1">Returns</h4> 634<table class="caption-top table"> 635<thead> 636<tr class="header"> 637<th>Name</th> 638<th>Type</th> 639<th>Description</th> 640</tr> 641</thead> 642<tbody> 643<tr class="odd"> 644<td></td> 645<td><a href="`atdata._protocols.IndexEntry`">IndexEntry</a></td> 646<td>IndexEntry for the dataset.</td> 647</tr> 648</tbody> 649</table> 650</section> 651<section id="raises-1" class="level4 doc-section doc-section-raises"> 652<h4 class="doc-section doc-section-raises anchored" data-anchor-id="raises-1">Raises</h4> 653<table class="caption-top table"> 654<thead> 655<tr class="header"> 656<th>Name</th> 657<th>Type</th> 658<th>Description</th> 659</tr> 660</thead> 661<tbody> 662<tr class="odd"> 663<td></td> 664<td><a href="`KeyError`">KeyError</a></td> 665<td>If dataset not found.</td> 666</tr> 667</tbody> 668</table> 669</section> 670</section> 671<section id="atdata.AbstractIndex.get_schema" class="level3"> 672<h3 class="anchored" data-anchor-id="atdata.AbstractIndex.get_schema">get_schema</h3> 673<div class="sourceCode" id="cb6"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb6-1"><a href="#cb6-1" aria-hidden="true" tabindex="-1"></a>AbstractIndex.get_schema(ref)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div> 674<p>Get a schema record by reference.</p> 675<section id="parameters-2" class="level4 doc-section doc-section-parameters"> 676<h4 class="doc-section doc-section-parameters anchored" data-anchor-id="parameters-2">Parameters</h4> 677<table class="caption-top table"> 678<thead> 679<tr class="header"> 680<th>Name</th> 681<th>Type</th> 682<th>Description</th> 683<th>Default</th> 684</tr> 685</thead> 686<tbody> 687<tr class="odd"> 688<td>ref</td> 689<td><a href="`str`">str</a></td> 690<td>Schema reference string (local:// or at://).</td> 691<td><em>required</em></td> 692</tr> 693</tbody> 694</table> 695</section> 696<section id="returns-2" class="level4 doc-section doc-section-returns"> 697<h4 class="doc-section doc-section-returns anchored" data-anchor-id="returns-2">Returns</h4> 698<table class="caption-top table"> 699<thead> 700<tr class="header"> 701<th>Name</th> 702<th>Type</th> 703<th>Description</th> 704</tr> 705</thead> 706<tbody> 707<tr class="odd"> 708<td></td> 709<td><a href="`dict`">dict</a></td> 710<td>Schema record as a dictionary with fields like ‘name’, ‘version’,</td> 711</tr> 712<tr class="even"> 713<td></td> 714<td><a href="`dict`">dict</a></td> 715<td>‘fields’, etc.</td> 716</tr> 717</tbody> 718</table> 719</section> 720<section id="raises-2" class="level4 doc-section doc-section-raises"> 721<h4 class="doc-section doc-section-raises anchored" data-anchor-id="raises-2">Raises</h4> 722<table class="caption-top table"> 723<thead> 724<tr class="header"> 725<th>Name</th> 726<th>Type</th> 727<th>Description</th> 728</tr> 729</thead> 730<tbody> 731<tr class="odd"> 732<td></td> 733<td><a href="`KeyError`">KeyError</a></td> 734<td>If schema not found.</td> 735</tr> 736</tbody> 737</table> 738</section> 739</section> 740<section id="atdata.AbstractIndex.insert_dataset" class="level3"> 741<h3 class="anchored" data-anchor-id="atdata.AbstractIndex.insert_dataset">insert_dataset</h3> 742<div class="sourceCode" id="cb7"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb7-1"><a href="#cb7-1" aria-hidden="true" tabindex="-1"></a>AbstractIndex.insert_dataset(ds, <span class="op">*</span>, name, schema_ref<span class="op">=</span><span class="va">None</span>, <span class="op">**</span>kwargs)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div> 743<p>Insert a dataset into the index.</p> 744<p>The sample type is inferred from <code>ds.sample_type</code>. If schema_ref is not provided, the schema may be auto-published based on the sample type.</p> 745<section id="parameters-3" class="level4 doc-section doc-section-parameters"> 746<h4 class="doc-section doc-section-parameters anchored" data-anchor-id="parameters-3">Parameters</h4> 747<table class="caption-top table"> 748<thead> 749<tr class="header"> 750<th>Name</th> 751<th>Type</th> 752<th>Description</th> 753<th>Default</th> 754</tr> 755</thead> 756<tbody> 757<tr class="odd"> 758<td>ds</td> 759<td><a href="`atdata.dataset.Dataset`">Dataset</a></td> 760<td>The Dataset to register in the index (any sample type).</td> 761<td><em>required</em></td> 762</tr> 763<tr class="even"> 764<td>name</td> 765<td><a href="`str`">str</a></td> 766<td>Human-readable name for the dataset.</td> 767<td><em>required</em></td> 768</tr> 769<tr class="odd"> 770<td>schema_ref</td> 771<td><a href="`typing.Optional`">Optional</a>[<a href="`str`">str</a>]</td> 772<td>Optional explicit schema reference. If not provided, the schema may be auto-published or inferred from ds.sample_type.</td> 773<td><code>None</code></td> 774</tr> 775<tr class="even"> 776<td>**kwargs</td> 777<td></td> 778<td>Additional backend-specific options.</td> 779<td><code>{}</code></td> 780</tr> 781</tbody> 782</table> 783</section> 784<section id="returns-3" class="level4 doc-section doc-section-returns"> 785<h4 class="doc-section doc-section-returns anchored" data-anchor-id="returns-3">Returns</h4> 786<table class="caption-top table"> 787<thead> 788<tr class="header"> 789<th>Name</th> 790<th>Type</th> 791<th>Description</th> 792</tr> 793</thead> 794<tbody> 795<tr class="odd"> 796<td></td> 797<td><a href="`atdata._protocols.IndexEntry`">IndexEntry</a></td> 798<td>IndexEntry for the inserted dataset.</td> 799</tr> 800</tbody> 801</table> 802</section> 803</section> 804<section id="atdata.AbstractIndex.list_datasets" class="level3"> 805<h3 class="anchored" data-anchor-id="atdata.AbstractIndex.list_datasets">list_datasets</h3> 806<div class="sourceCode" id="cb8"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb8-1"><a href="#cb8-1" aria-hidden="true" tabindex="-1"></a>AbstractIndex.list_datasets()</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div> 807<p>Get all dataset entries as a materialized list.</p> 808<section id="returns-4" class="level4 doc-section doc-section-returns"> 809<h4 class="doc-section doc-section-returns anchored" data-anchor-id="returns-4">Returns</h4> 810<table class="caption-top table"> 811<thead> 812<tr class="header"> 813<th>Name</th> 814<th>Type</th> 815<th>Description</th> 816</tr> 817</thead> 818<tbody> 819<tr class="odd"> 820<td></td> 821<td><a href="`list`">list</a>[<a href="`atdata._protocols.IndexEntry`">IndexEntry</a>]</td> 822<td>List of IndexEntry for each dataset.</td> 823</tr> 824</tbody> 825</table> 826</section> 827</section> 828<section id="atdata.AbstractIndex.list_schemas" class="level3"> 829<h3 class="anchored" data-anchor-id="atdata.AbstractIndex.list_schemas">list_schemas</h3> 830<div class="sourceCode" id="cb9"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb9-1"><a href="#cb9-1" aria-hidden="true" tabindex="-1"></a>AbstractIndex.list_schemas()</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div> 831<p>Get all schema records as a materialized list.</p> 832<section id="returns-5" class="level4 doc-section doc-section-returns"> 833<h4 class="doc-section doc-section-returns anchored" data-anchor-id="returns-5">Returns</h4> 834<table class="caption-top table"> 835<thead> 836<tr class="header"> 837<th>Name</th> 838<th>Type</th> 839<th>Description</th> 840</tr> 841</thead> 842<tbody> 843<tr class="odd"> 844<td></td> 845<td><a href="`list`">list</a>[<a href="`dict`">dict</a>]</td> 846<td>List of schema records as dictionaries.</td> 847</tr> 848</tbody> 849</table> 850</section> 851</section> 852<section id="atdata.AbstractIndex.publish_schema" class="level3"> 853<h3 class="anchored" data-anchor-id="atdata.AbstractIndex.publish_schema">publish_schema</h3> 854<div class="sourceCode" id="cb10"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb10-1"><a href="#cb10-1" aria-hidden="true" tabindex="-1"></a>AbstractIndex.publish_schema(sample_type, <span class="op">*</span>, version<span class="op">=</span><span class="st">'1.0.0'</span>, <span class="op">**</span>kwargs)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div> 855<p>Publish a schema for a sample type.</p> 856<p>The sample_type is accepted as <code>type</code> rather than <code>Type[Packable]</code> to support <code>@packable</code>-decorated classes, which satisfy the Packable protocol at runtime but cannot be statically verified by type checkers.</p> 857<section id="parameters-4" class="level4 doc-section doc-section-parameters"> 858<h4 class="doc-section doc-section-parameters anchored" data-anchor-id="parameters-4">Parameters</h4> 859<table class="caption-top table"> 860<thead> 861<tr class="header"> 862<th>Name</th> 863<th>Type</th> 864<th>Description</th> 865<th>Default</th> 866</tr> 867</thead> 868<tbody> 869<tr class="odd"> 870<td>sample_type</td> 871<td><a href="`type`">type</a></td> 872<td>A Packable type (PackableSample subclass or <span class="citation" data-cites="packable-decorated">@packable-decorated</span>). Validated at runtime via the <span class="citation" data-cites="runtime_checkable">@runtime_checkable</span> Packable protocol.</td> 873<td><em>required</em></td> 874</tr> 875<tr class="even"> 876<td>version</td> 877<td><a href="`str`">str</a></td> 878<td>Semantic version string for the schema.</td> 879<td><code>'1.0.0'</code></td> 880</tr> 881<tr class="odd"> 882<td>**kwargs</td> 883<td></td> 884<td>Additional backend-specific options.</td> 885<td><code>{}</code></td> 886</tr> 887</tbody> 888</table> 889</section> 890<section id="returns-6" class="level4 doc-section doc-section-returns"> 891<h4 class="doc-section doc-section-returns anchored" data-anchor-id="returns-6">Returns</h4> 892<table class="caption-top table"> 893<thead> 894<tr class="header"> 895<th>Name</th> 896<th>Type</th> 897<th>Description</th> 898</tr> 899</thead> 900<tbody> 901<tr class="odd"> 902<td></td> 903<td><a href="`str`">str</a></td> 904<td>Schema reference string:</td> 905</tr> 906<tr class="even"> 907<td></td> 908<td><a href="`str`">str</a></td> 909<td>- Local: ‘local://schemas/{module.Class}<span class="citation" data-cites="version">@version</span></td> 910</tr> 911<tr class="odd"> 912<td></td> 913<td><a href="`str`">str</a></td> 914<td>- Atmosphere: ‘at://did:plc:…/ac.foundation.dataset.sampleSchema/…’</td> 915</tr> 916</tbody> 917</table> 918 919 920</section> 921</section> 922</section> 923</section> 924 925</main> <!-- /main --> 926<script id="quarto-html-after-body" type="application/javascript"> 927 window.document.addEventListener("DOMContentLoaded", function (event) { 928 // Ensure there is a toggle, if there isn't float one in the top right 929 if (window.document.querySelector('.quarto-color-scheme-toggle') === null) { 930 const a = window.document.createElement('a'); 931 a.classList.add('top-right'); 932 a.classList.add('quarto-color-scheme-toggle'); 933 a.href = ""; 934 a.onclick = function() { try { window.quartoToggleColorScheme(); } catch {} return false; }; 935 const i = window.document.createElement("i"); 936 i.classList.add('bi'); 937 a.appendChild(i); 938 window.document.body.appendChild(a); 939 } 940 setColorSchemeToggle(hasAlternateSentinel()) 941 const icon = ""; 942 const anchorJS = new window.AnchorJS(); 943 anchorJS.options = { 944 placement: 'right', 945 icon: icon 946 }; 947 anchorJS.add('.anchored'); 948 const isCodeAnnotation = (el) => { 949 for (const clz of el.classList) { 950 if (clz.startsWith('code-annotation-')) { 951 return true; 952 } 953 } 954 return false; 955 } 956 const onCopySuccess = function(e) { 957 // button target 958 const button = e.trigger; 959 // don't keep focus 960 button.blur(); 961 // flash "checked" 962 button.classList.add('code-copy-button-checked'); 963 var currentTitle = button.getAttribute("title"); 964 button.setAttribute("title", "Copied!"); 965 let tooltip; 966 if (window.bootstrap) { 967 button.setAttribute("data-bs-toggle", "tooltip"); 968 button.setAttribute("data-bs-placement", "left"); 969 button.setAttribute("data-bs-title", "Copied!"); 970 tooltip = new bootstrap.Tooltip(button, 971 { trigger: "manual", 972 customClass: "code-copy-button-tooltip", 973 offset: [0, -8]}); 974 tooltip.show(); 975 } 976 setTimeout(function() { 977 if (tooltip) { 978 tooltip.hide(); 979 button.removeAttribute("data-bs-title"); 980 button.removeAttribute("data-bs-toggle"); 981 button.removeAttribute("data-bs-placement"); 982 } 983 button.setAttribute("title", currentTitle); 984 button.classList.remove('code-copy-button-checked'); 985 }, 1000); 986 // clear code selection 987 e.clearSelection(); 988 } 989 const getTextToCopy = function(trigger) { 990 const codeEl = trigger.previousElementSibling.cloneNode(true); 991 for (const childEl of codeEl.children) { 992 if (isCodeAnnotation(childEl)) { 993 childEl.remove(); 994 } 995 } 996 return codeEl.innerText; 997 } 998 const clipboard = new window.ClipboardJS('.code-copy-button:not([data-in-quarto-modal])', { 999 text: getTextToCopy 1000 }); 1001 clipboard.on('success', onCopySuccess); 1002 if (window.document.getElementById('quarto-embedded-source-code-modal')) { 1003 const clipboardModal = new window.ClipboardJS('.code-copy-button[data-in-quarto-modal]', { 1004 text: getTextToCopy, 1005 container: window.document.getElementById('quarto-embedded-source-code-modal') 1006 }); 1007 clipboardModal.on('success', onCopySuccess); 1008 } 1009 var localhostRegex = new RegExp(/^(?:http|https):\/\/localhost\:?[0-9]*\//); 1010 var mailtoRegex = new RegExp(/^mailto:/); 1011 var filterRegex = new RegExp("https:\/\/github\.com\/your-org\/atdata"); 1012 var isInternal = (href) => { 1013 return filterRegex.test(href) || localhostRegex.test(href) || mailtoRegex.test(href); 1014 } 1015 // Inspect non-navigation links and adorn them if external 1016 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)'); 1017 for (var i=0; i<links.length; i++) { 1018 const link = links[i]; 1019 if (!isInternal(link.href)) { 1020 // undo the damage that might have been done by quarto-nav.js in the case of 1021 // links that we want to consider external 1022 if (link.dataset.originalHref !== undefined) { 1023 link.href = link.dataset.originalHref; 1024 } 1025 } 1026 } 1027 function tippyHover(el, contentFn, onTriggerFn, onUntriggerFn) { 1028 const config = { 1029 allowHTML: true, 1030 maxWidth: 500, 1031 delay: 100, 1032 arrow: false, 1033 appendTo: function(el) { 1034 return el.parentElement; 1035 }, 1036 interactive: true, 1037 interactiveBorder: 10, 1038 theme: 'quarto', 1039 placement: 'bottom-start', 1040 }; 1041 if (contentFn) { 1042 config.content = contentFn; 1043 } 1044 if (onTriggerFn) { 1045 config.onTrigger = onTriggerFn; 1046 } 1047 if (onUntriggerFn) { 1048 config.onUntrigger = onUntriggerFn; 1049 } 1050 window.tippy(el, config); 1051 } 1052 const noterefs = window.document.querySelectorAll('a[role="doc-noteref"]'); 1053 for (var i=0; i<noterefs.length; i++) { 1054 const ref = noterefs[i]; 1055 tippyHover(ref, function() { 1056 // use id or data attribute instead here 1057 let href = ref.getAttribute('data-footnote-href') || ref.getAttribute('href'); 1058 try { href = new URL(href).hash; } catch {} 1059 const id = href.replace(/^#\/?/, ""); 1060 const note = window.document.getElementById(id); 1061 if (note) { 1062 return note.innerHTML; 1063 } else { 1064 return ""; 1065 } 1066 }); 1067 } 1068 const xrefs = window.document.querySelectorAll('a.quarto-xref'); 1069 const processXRef = (id, note) => { 1070 // Strip column container classes 1071 const stripColumnClz = (el) => { 1072 el.classList.remove("page-full", "page-columns"); 1073 if (el.children) { 1074 for (const child of el.children) { 1075 stripColumnClz(child); 1076 } 1077 } 1078 } 1079 stripColumnClz(note) 1080 if (id === null || id.startsWith('sec-')) { 1081 // Special case sections, only their first couple elements 1082 const container = document.createElement("div"); 1083 if (note.children && note.children.length > 2) { 1084 container.appendChild(note.children[0].cloneNode(true)); 1085 for (let i = 1; i < note.children.length; i++) { 1086 const child = note.children[i]; 1087 if (child.tagName === "P" && child.innerText === "") { 1088 continue; 1089 } else { 1090 container.appendChild(child.cloneNode(true)); 1091 break; 1092 } 1093 } 1094 if (window.Quarto?.typesetMath) { 1095 window.Quarto.typesetMath(container); 1096 } 1097 return container.innerHTML 1098 } else { 1099 if (window.Quarto?.typesetMath) { 1100 window.Quarto.typesetMath(note); 1101 } 1102 return note.innerHTML; 1103 } 1104 } else { 1105 // Remove any anchor links if they are present 1106 const anchorLink = note.querySelector('a.anchorjs-link'); 1107 if (anchorLink) { 1108 anchorLink.remove(); 1109 } 1110 if (window.Quarto?.typesetMath) { 1111 window.Quarto.typesetMath(note); 1112 } 1113 if (note.classList.contains("callout")) { 1114 return note.outerHTML; 1115 } else { 1116 return note.innerHTML; 1117 } 1118 } 1119 } 1120 for (var i=0; i<xrefs.length; i++) { 1121 const xref = xrefs[i]; 1122 tippyHover(xref, undefined, function(instance) { 1123 instance.disable(); 1124 let url = xref.getAttribute('href'); 1125 let hash = undefined; 1126 if (url.startsWith('#')) { 1127 hash = url; 1128 } else { 1129 try { hash = new URL(url).hash; } catch {} 1130 } 1131 if (hash) { 1132 const id = hash.replace(/^#\/?/, ""); 1133 const note = window.document.getElementById(id); 1134 if (note !== null) { 1135 try { 1136 const html = processXRef(id, note.cloneNode(true)); 1137 instance.setContent(html); 1138 } finally { 1139 instance.enable(); 1140 instance.show(); 1141 } 1142 } else { 1143 // See if we can fetch this 1144 fetch(url.split('#')[0]) 1145 .then(res => res.text()) 1146 .then(html => { 1147 const parser = new DOMParser(); 1148 const htmlDoc = parser.parseFromString(html, "text/html"); 1149 const note = htmlDoc.getElementById(id); 1150 if (note !== null) { 1151 const html = processXRef(id, note); 1152 instance.setContent(html); 1153 } 1154 }).finally(() => { 1155 instance.enable(); 1156 instance.show(); 1157 }); 1158 } 1159 } else { 1160 // See if we can fetch a full url (with no hash to target) 1161 // This is a special case and we should probably do some content thinning / targeting 1162 fetch(url) 1163 .then(res => res.text()) 1164 .then(html => { 1165 const parser = new DOMParser(); 1166 const htmlDoc = parser.parseFromString(html, "text/html"); 1167 const note = htmlDoc.querySelector('main.content'); 1168 if (note !== null) { 1169 // This should only happen for chapter cross references 1170 // (since there is no id in the URL) 1171 // remove the first header 1172 if (note.children.length > 0 && note.children[0].tagName === "HEADER") { 1173 note.children[0].remove(); 1174 } 1175 const html = processXRef(null, note); 1176 instance.setContent(html); 1177 } 1178 }).finally(() => { 1179 instance.enable(); 1180 instance.show(); 1181 }); 1182 } 1183 }, function(instance) { 1184 }); 1185 } 1186 let selectedAnnoteEl; 1187 const selectorForAnnotation = ( cell, annotation) => { 1188 let cellAttr = 'data-code-cell="' + cell + '"'; 1189 let lineAttr = 'data-code-annotation="' + annotation + '"'; 1190 const selector = 'span[' + cellAttr + '][' + lineAttr + ']'; 1191 return selector; 1192 } 1193 const selectCodeLines = (annoteEl) => { 1194 const doc = window.document; 1195 const targetCell = annoteEl.getAttribute("data-target-cell"); 1196 const targetAnnotation = annoteEl.getAttribute("data-target-annotation"); 1197 const annoteSpan = window.document.querySelector(selectorForAnnotation(targetCell, targetAnnotation)); 1198 const lines = annoteSpan.getAttribute("data-code-lines").split(","); 1199 const lineIds = lines.map((line) => { 1200 return targetCell + "-" + line; 1201 }) 1202 let top = null; 1203 let height = null; 1204 let parent = null; 1205 if (lineIds.length > 0) { 1206 //compute the position of the single el (top and bottom and make a div) 1207 const el = window.document.getElementById(lineIds[0]); 1208 top = el.offsetTop; 1209 height = el.offsetHeight; 1210 parent = el.parentElement.parentElement; 1211 if (lineIds.length > 1) { 1212 const lastEl = window.document.getElementById(lineIds[lineIds.length - 1]); 1213 const bottom = lastEl.offsetTop + lastEl.offsetHeight; 1214 height = bottom - top; 1215 } 1216 if (top !== null && height !== null && parent !== null) { 1217 // cook up a div (if necessary) and position it 1218 let div = window.document.getElementById("code-annotation-line-highlight"); 1219 if (div === null) { 1220 div = window.document.createElement("div"); 1221 div.setAttribute("id", "code-annotation-line-highlight"); 1222 div.style.position = 'absolute'; 1223 parent.appendChild(div); 1224 } 1225 div.style.top = top - 2 + "px"; 1226 div.style.height = height + 4 + "px"; 1227 div.style.left = 0; 1228 let gutterDiv = window.document.getElementById("code-annotation-line-highlight-gutter"); 1229 if (gutterDiv === null) { 1230 gutterDiv = window.document.createElement("div"); 1231 gutterDiv.setAttribute("id", "code-annotation-line-highlight-gutter"); 1232 gutterDiv.style.position = 'absolute'; 1233 const codeCell = window.document.getElementById(targetCell); 1234 const gutter = codeCell.querySelector('.code-annotation-gutter'); 1235 gutter.appendChild(gutterDiv); 1236 } 1237 gutterDiv.style.top = top - 2 + "px"; 1238 gutterDiv.style.height = height + 4 + "px"; 1239 } 1240 selectedAnnoteEl = annoteEl; 1241 } 1242 }; 1243 const unselectCodeLines = () => { 1244 const elementsIds = ["code-annotation-line-highlight", "code-annotation-line-highlight-gutter"]; 1245 elementsIds.forEach((elId) => { 1246 const div = window.document.getElementById(elId); 1247 if (div) { 1248 div.remove(); 1249 } 1250 }); 1251 selectedAnnoteEl = undefined; 1252 }; 1253 // Handle positioning of the toggle 1254 window.addEventListener( 1255 "resize", 1256 throttle(() => { 1257 elRect = undefined; 1258 if (selectedAnnoteEl) { 1259 selectCodeLines(selectedAnnoteEl); 1260 } 1261 }, 10) 1262 ); 1263 function throttle(fn, ms) { 1264 let throttle = false; 1265 let timer; 1266 return (...args) => { 1267 if(!throttle) { // first call gets through 1268 fn.apply(this, args); 1269 throttle = true; 1270 } else { // all the others get throttled 1271 if(timer) clearTimeout(timer); // cancel #2 1272 timer = setTimeout(() => { 1273 fn.apply(this, args); 1274 timer = throttle = false; 1275 }, ms); 1276 } 1277 }; 1278 } 1279 // Attach click handler to the DT 1280 const annoteDls = window.document.querySelectorAll('dt[data-target-cell]'); 1281 for (const annoteDlNode of annoteDls) { 1282 annoteDlNode.addEventListener('click', (event) => { 1283 const clickedEl = event.target; 1284 if (clickedEl !== selectedAnnoteEl) { 1285 unselectCodeLines(); 1286 const activeEl = window.document.querySelector('dt[data-target-cell].code-annotation-active'); 1287 if (activeEl) { 1288 activeEl.classList.remove('code-annotation-active'); 1289 } 1290 selectCodeLines(clickedEl); 1291 clickedEl.classList.add('code-annotation-active'); 1292 } else { 1293 // Unselect the line 1294 unselectCodeLines(); 1295 clickedEl.classList.remove('code-annotation-active'); 1296 } 1297 }); 1298 } 1299 const findCites = (el) => { 1300 const parentEl = el.parentElement; 1301 if (parentEl) { 1302 const cites = parentEl.dataset.cites; 1303 if (cites) { 1304 return { 1305 el, 1306 cites: cites.split(' ') 1307 }; 1308 } else { 1309 return findCites(el.parentElement) 1310 } 1311 } else { 1312 return undefined; 1313 } 1314 }; 1315 var bibliorefs = window.document.querySelectorAll('a[role="doc-biblioref"]'); 1316 for (var i=0; i<bibliorefs.length; i++) { 1317 const ref = bibliorefs[i]; 1318 const citeInfo = findCites(ref); 1319 if (citeInfo) { 1320 tippyHover(citeInfo.el, function() { 1321 var popup = window.document.createElement('div'); 1322 citeInfo.cites.forEach(function(cite) { 1323 var citeDiv = window.document.createElement('div'); 1324 citeDiv.classList.add('hanging-indent'); 1325 citeDiv.classList.add('csl-entry'); 1326 var biblioDiv = window.document.getElementById('ref-' + cite); 1327 if (biblioDiv) { 1328 citeDiv.innerHTML = biblioDiv.innerHTML; 1329 } 1330 popup.appendChild(citeDiv); 1331 }); 1332 return popup.innerHTML; 1333 }); 1334 } 1335 } 1336 }); 1337 </script> 1338</div> <!-- /content --> 1339<footer class="footer"> 1340 <div class="nav-footer"> 1341 <div class="nav-footer-left"> 1342<p>Built with <a href="https://quarto.org/">Quarto</a></p> 1343</div> 1344 <div class="nav-footer-center"> 1345 &nbsp; 1346 <div class="toc-actions d-sm-block d-md-none"><ul><li><a href="https://github.com/your-org/atdata/edit/main/api/AbstractIndex.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> 1347 <div class="nav-footer-right"> 1348<p>MIT License</p> 1349</div> 1350 </div> 1351</footer> 1352 1353 1354 1355 1356</body></html>