A loose federation of distributed, typed datasets
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<meta name="description" content="Store and manage datasets with Redis + S3">
10
11<title>Local Workflow – atdata</title>
12<style>
13code{white-space: pre-wrap;}
14span.smallcaps{font-variant: small-caps;}
15div.columns{display: flex; gap: min(4vw, 1.5em);}
16div.column{flex: auto; overflow-x: auto;}
17div.hanging-indent{margin-left: 1.5em; text-indent: -1.5em;}
18ul.task-list{list-style: none;}
19ul.task-list li input[type="checkbox"] {
20 width: 0.8em;
21 margin: 0 0.8em 0.2em -1em; /* quarto-specific, see https://github.com/quarto-dev/quarto-cli/issues/4556 */
22 vertical-align: middle;
23}
24/* CSS for syntax highlighting */
25html { -webkit-text-size-adjust: 100%; }
26pre > code.sourceCode { white-space: pre; position: relative; }
27pre > code.sourceCode > span { display: inline-block; line-height: 1.25; }
28pre > code.sourceCode > span:empty { height: 1.2em; }
29.sourceCode { overflow: visible; }
30code.sourceCode > span { color: inherit; text-decoration: inherit; }
31div.sourceCode { margin: 1em 0; }
32pre.sourceCode { margin: 0; }
33@media screen {
34div.sourceCode { overflow: auto; }
35}
36@media print {
37pre > code.sourceCode { white-space: pre-wrap; }
38pre > code.sourceCode > span { text-indent: -5em; padding-left: 5em; }
39}
40pre.numberSource code
41 { counter-reset: source-line 0; }
42pre.numberSource code > span
43 { position: relative; left: -4em; counter-increment: source-line; }
44pre.numberSource code > span > a:first-child::before
45 { content: counter(source-line);
46 position: relative; left: -1em; text-align: right; vertical-align: baseline;
47 border: none; display: inline-block;
48 -webkit-touch-callout: none; -webkit-user-select: none;
49 -khtml-user-select: none; -moz-user-select: none;
50 -ms-user-select: none; user-select: none;
51 padding: 0 4px; width: 4em;
52 }
53pre.numberSource { margin-left: 3em; padding-left: 4px; }
54div.sourceCode
55 { }
56@media screen {
57pre > code.sourceCode > span > a:first-child::before { text-decoration: underline; }
58}
59</style>
60
61
62<script src="../site_libs/quarto-nav/quarto-nav.js"></script>
63<script src="../site_libs/quarto-nav/headroom.min.js"></script>
64<script src="../site_libs/clipboard/clipboard.min.js"></script>
65<script src="../site_libs/quarto-search/autocomplete.umd.js"></script>
66<script src="../site_libs/quarto-search/fuse.min.js"></script>
67<script src="../site_libs/quarto-search/quarto-search.js"></script>
68<meta name="quarto:offset" content="../">
69<script src="../site_libs/quarto-html/quarto.js" type="module"></script>
70<script src="../site_libs/quarto-html/tabsets/tabsets.js" type="module"></script>
71<script src="../site_libs/quarto-html/popper.min.js"></script>
72<script src="../site_libs/quarto-html/tippy.umd.min.js"></script>
73<script src="../site_libs/quarto-html/anchor.min.js"></script>
74<link href="../site_libs/quarto-html/tippy.css" rel="stylesheet">
75<link href="../site_libs/quarto-html/quarto-syntax-highlighting-9582434199d49cc9e91654cdeeb4866b.css" rel="stylesheet" class="quarto-color-scheme" id="quarto-text-highlighting-styles">
76<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">
77<link href="../site_libs/quarto-html/quarto-syntax-highlighting-9582434199d49cc9e91654cdeeb4866b.css" rel="stylesheet" class="quarto-color-scheme-extra" id="quarto-text-highlighting-styles">
78<script src="../site_libs/bootstrap/bootstrap.min.js"></script>
79<link href="../site_libs/bootstrap/bootstrap-icons.css" rel="stylesheet">
80<link href="../site_libs/bootstrap/bootstrap-62bce24ca844314e7bb1a34dbdfe05cc.min.css" rel="stylesheet" append-hash="true" class="quarto-color-scheme" id="quarto-bootstrap" data-mode="light">
81<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">
82<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">
83<script id="quarto-search-options" type="application/json">{
84 "location": "navbar",
85 "copy-button": false,
86 "collapse-after": 3,
87 "panel-placement": "end",
88 "type": "overlay",
89 "limit": 50,
90 "keyboard-shortcut": [
91 "f",
92 "/",
93 "s"
94 ],
95 "show-item-context": false,
96 "language": {
97 "search-no-results-text": "No results",
98 "search-matching-documents-text": "matching documents",
99 "search-copy-link-title": "Copy link to search",
100 "search-hide-matches-text": "Hide additional matches",
101 "search-more-match-text": "more match in this document",
102 "search-more-matches-text": "more matches in this document",
103 "search-clear-button-title": "Clear",
104 "search-text-placeholder": "",
105 "search-detached-cancel-button-title": "Cancel",
106 "search-submit-button-title": "Submit",
107 "search-label": "Search"
108 }
109}</script>
110
111
112<link rel="stylesheet" href="../assets/styles.css">
113</head>
114
115<body class="nav-sidebar docked nav-fixed quarto-light"><script id="quarto-html-before-body" type="application/javascript">
116 const toggleBodyColorMode = (bsSheetEl) => {
117 const mode = bsSheetEl.getAttribute("data-mode");
118 const bodyEl = window.document.querySelector("body");
119 if (mode === "dark") {
120 bodyEl.classList.add("quarto-dark");
121 bodyEl.classList.remove("quarto-light");
122 } else {
123 bodyEl.classList.add("quarto-light");
124 bodyEl.classList.remove("quarto-dark");
125 }
126 }
127 const toggleBodyColorPrimary = () => {
128 const bsSheetEl = window.document.querySelector("link#quarto-bootstrap:not([rel=disabled-stylesheet])");
129 if (bsSheetEl) {
130 toggleBodyColorMode(bsSheetEl);
131 }
132 }
133 const setColorSchemeToggle = (alternate) => {
134 const toggles = window.document.querySelectorAll('.quarto-color-scheme-toggle');
135 for (let i=0; i < toggles.length; i++) {
136 const toggle = toggles[i];
137 if (toggle) {
138 if (alternate) {
139 toggle.classList.add("alternate");
140 } else {
141 toggle.classList.remove("alternate");
142 }
143 }
144 }
145 };
146 const toggleColorMode = (alternate) => {
147 // Switch the stylesheets
148 const primaryStylesheets = window.document.querySelectorAll('link.quarto-color-scheme:not(.quarto-color-alternate)');
149 const alternateStylesheets = window.document.querySelectorAll('link.quarto-color-scheme.quarto-color-alternate');
150 manageTransitions('#quarto-margin-sidebar .nav-link', false);
151 if (alternate) {
152 // note: dark is layered on light, we don't disable primary!
153 enableStylesheet(alternateStylesheets);
154 for (const sheetNode of alternateStylesheets) {
155 if (sheetNode.id === "quarto-bootstrap") {
156 toggleBodyColorMode(sheetNode);
157 }
158 }
159 } else {
160 disableStylesheet(alternateStylesheets);
161 enableStylesheet(primaryStylesheets)
162 toggleBodyColorPrimary();
163 }
164 manageTransitions('#quarto-margin-sidebar .nav-link', true);
165 // Switch the toggles
166 setColorSchemeToggle(alternate)
167 // Hack to workaround the fact that safari doesn't
168 // properly recolor the scrollbar when toggling (#1455)
169 if (navigator.userAgent.indexOf('Safari') > 0 && navigator.userAgent.indexOf('Chrome') == -1) {
170 manageTransitions("body", false);
171 window.scrollTo(0, 1);
172 setTimeout(() => {
173 window.scrollTo(0, 0);
174 manageTransitions("body", true);
175 }, 40);
176 }
177 }
178 const disableStylesheet = (stylesheets) => {
179 for (let i=0; i < stylesheets.length; i++) {
180 const stylesheet = stylesheets[i];
181 stylesheet.rel = 'disabled-stylesheet';
182 }
183 }
184 const enableStylesheet = (stylesheets) => {
185 for (let i=0; i < stylesheets.length; i++) {
186 const stylesheet = stylesheets[i];
187 if(stylesheet.rel !== 'stylesheet') { // for Chrome, which will still FOUC without this check
188 stylesheet.rel = 'stylesheet';
189 }
190 }
191 }
192 const manageTransitions = (selector, allowTransitions) => {
193 const els = window.document.querySelectorAll(selector);
194 for (let i=0; i < els.length; i++) {
195 const el = els[i];
196 if (allowTransitions) {
197 el.classList.remove('notransition');
198 } else {
199 el.classList.add('notransition');
200 }
201 }
202 }
203 const isFileUrl = () => {
204 return window.location.protocol === 'file:';
205 }
206 const hasAlternateSentinel = () => {
207 let styleSentinel = getColorSchemeSentinel();
208 if (styleSentinel !== null) {
209 return styleSentinel === "alternate";
210 } else {
211 return false;
212 }
213 }
214 const setStyleSentinel = (alternate) => {
215 const value = alternate ? "alternate" : "default";
216 if (!isFileUrl()) {
217 window.localStorage.setItem("quarto-color-scheme", value);
218 } else {
219 localAlternateSentinel = value;
220 }
221 }
222 const getColorSchemeSentinel = () => {
223 if (!isFileUrl()) {
224 const storageValue = window.localStorage.getItem("quarto-color-scheme");
225 return storageValue != null ? storageValue : localAlternateSentinel;
226 } else {
227 return localAlternateSentinel;
228 }
229 }
230 const toggleGiscusIfUsed = (isAlternate, darkModeDefault) => {
231 const baseTheme = document.querySelector('#giscus-base-theme')?.value ?? 'light';
232 const alternateTheme = document.querySelector('#giscus-alt-theme')?.value ?? 'dark';
233 let newTheme = '';
234 if(authorPrefersDark) {
235 newTheme = isAlternate ? baseTheme : alternateTheme;
236 } else {
237 newTheme = isAlternate ? alternateTheme : baseTheme;
238 }
239 const changeGiscusTheme = () => {
240 // From: https://github.com/giscus/giscus/issues/336
241 const sendMessage = (message) => {
242 const iframe = document.querySelector('iframe.giscus-frame');
243 if (!iframe) return;
244 iframe.contentWindow.postMessage({ giscus: message }, 'https://giscus.app');
245 }
246 sendMessage({
247 setConfig: {
248 theme: newTheme
249 }
250 });
251 }
252 const isGiscussLoaded = window.document.querySelector('iframe.giscus-frame') !== null;
253 if (isGiscussLoaded) {
254 changeGiscusTheme();
255 }
256 };
257 const authorPrefersDark = false;
258 const darkModeDefault = authorPrefersDark;
259 document.querySelector('link#quarto-text-highlighting-styles.quarto-color-scheme-extra').rel = 'disabled-stylesheet';
260 document.querySelector('link#quarto-bootstrap.quarto-color-scheme-extra').rel = 'disabled-stylesheet';
261 let localAlternateSentinel = darkModeDefault ? 'alternate' : 'default';
262 // Dark / light mode switch
263 window.quartoToggleColorScheme = () => {
264 // Read the current dark / light value
265 let toAlternate = !hasAlternateSentinel();
266 toggleColorMode(toAlternate);
267 setStyleSentinel(toAlternate);
268 toggleGiscusIfUsed(toAlternate, darkModeDefault);
269 window.dispatchEvent(new Event('resize'));
270 };
271 // Switch to dark mode if need be
272 if (hasAlternateSentinel()) {
273 toggleColorMode(true);
274 } else {
275 toggleColorMode(false);
276 }
277 </script>
278
279<div id="quarto-search-results"></div>
280 <header id="quarto-header" class="headroom fixed-top">
281 <nav class="navbar navbar-expand-lg " data-bs-theme="dark">
282 <div class="navbar-container container-fluid">
283 <div class="navbar-brand-container mx-auto">
284 <a class="navbar-brand" href="../index.html">
285 <span class="navbar-title">atdata</span>
286 </a>
287 </div>
288 <div id="quarto-search" class="" title="Search"></div>
289 <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(); }">
290 <span class="navbar-toggler-icon"></span>
291</button>
292 <div class="collapse navbar-collapse" id="navbarCollapse">
293 <ul class="navbar-nav navbar-nav-scroll me-auto">
294 <li class="nav-item">
295 <a class="nav-link active" href="../index.html" aria-current="page">
296<span class="menu-text">Guide</span></a>
297 </li>
298 <li class="nav-item dropdown ">
299 <a class="nav-link dropdown-toggle" href="#" id="nav-menu-tutorials" role="link" data-bs-toggle="dropdown" aria-expanded="false">
300 <span class="menu-text">Tutorials</span>
301 </a>
302 <ul class="dropdown-menu" aria-labelledby="nav-menu-tutorials">
303 <li>
304 <a class="dropdown-item" href="../tutorials/quickstart.html">
305 <span class="dropdown-text">Quick Start</span></a>
306 </li>
307 <li>
308 <a class="dropdown-item" href="../tutorials/local-workflow.html">
309 <span class="dropdown-text">Local Workflow</span></a>
310 </li>
311 <li>
312 <a class="dropdown-item" href="../tutorials/atmosphere.html">
313 <span class="dropdown-text">Atmosphere Publishing</span></a>
314 </li>
315 <li>
316 <a class="dropdown-item" href="../tutorials/promotion.html">
317 <span class="dropdown-text">Promotion Workflow</span></a>
318 </li>
319 </ul>
320 </li>
321 <li class="nav-item dropdown ">
322 <a class="nav-link dropdown-toggle" href="#" id="nav-menu-reference" role="link" data-bs-toggle="dropdown" aria-expanded="false">
323 <span class="menu-text">Reference</span>
324 </a>
325 <ul class="dropdown-menu" aria-labelledby="nav-menu-reference">
326 <li>
327 <a class="dropdown-item" href="../reference/architecture.html">
328 <span class="dropdown-text">Architecture Overview</span></a>
329 </li>
330 <li>
331 <a class="dropdown-item" href="../reference/packable-samples.html">
332 <span class="dropdown-text">Packable Samples</span></a>
333 </li>
334 <li>
335 <a class="dropdown-item" href="../reference/datasets.html">
336 <span class="dropdown-text">Datasets</span></a>
337 </li>
338 <li>
339 <a class="dropdown-item" href="../reference/lenses.html">
340 <span class="dropdown-text">Lenses</span></a>
341 </li>
342 <li>
343 <a class="dropdown-item" href="../reference/local-storage.html">
344 <span class="dropdown-text">Local Storage</span></a>
345 </li>
346 <li>
347 <a class="dropdown-item" href="../reference/atmosphere.html">
348 <span class="dropdown-text">Atmosphere</span></a>
349 </li>
350 <li>
351 <a class="dropdown-item" href="../reference/promotion.html">
352 <span class="dropdown-text">Promotion</span></a>
353 </li>
354 <li>
355 <a class="dropdown-item" href="../reference/load-dataset.html">
356 <span class="dropdown-text">load_dataset API</span></a>
357 </li>
358 <li>
359 <a class="dropdown-item" href="../reference/protocols.html">
360 <span class="dropdown-text">Protocols</span></a>
361 </li>
362 <li>
363 <a class="dropdown-item" href="../reference/uri-spec.html">
364 <span class="dropdown-text">URI Specification</span></a>
365 </li>
366 <li>
367 <a class="dropdown-item" href="../reference/troubleshooting.html">
368 <span class="dropdown-text">Troubleshooting & FAQ</span></a>
369 </li>
370 <li>
371 <a class="dropdown-item" href="../reference/deployment.html">
372 <span class="dropdown-text">Deployment Guide</span></a>
373 </li>
374 </ul>
375 </li>
376 <li class="nav-item">
377 <a class="nav-link" href="../api/index.html">
378<span class="menu-text">API</span></a>
379 </li>
380</ul>
381 <ul class="navbar-nav navbar-nav-scroll ms-auto">
382 <li class="nav-item compact">
383 <a class="nav-link" href="https://github.com/your-org/atdata"> <i class="bi bi-github" role="img">
384</i>
385<span class="menu-text"></span></a>
386 </li>
387</ul>
388 </div> <!-- /navcollapse -->
389 <div class="quarto-navbar-tools">
390 <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>
391</div>
392 </div> <!-- /container-fluid -->
393 </nav>
394 <nav class="quarto-secondary-nav">
395 <div class="container-fluid d-flex">
396 <button type="button" class="quarto-btn-toggle btn" data-bs-toggle="collapse" role="button" data-bs-target=".quarto-sidebar-collapse-item" aria-controls="quarto-sidebar" aria-expanded="false" aria-label="Toggle sidebar navigation" onclick="if (window.quartoToggleHeadroom) { window.quartoToggleHeadroom(); }">
397 <i class="bi bi-layout-text-sidebar-reverse"></i>
398 </button>
399 <nav class="quarto-page-breadcrumbs" aria-label="breadcrumb"><ol class="breadcrumb"><li class="breadcrumb-item"><a href="../tutorials/quickstart.html">Getting Started</a></li><li class="breadcrumb-item"><a href="../tutorials/local-workflow.html">Local Workflow</a></li></ol></nav>
400 <a class="flex-grow-1" role="navigation" data-bs-toggle="collapse" data-bs-target=".quarto-sidebar-collapse-item" aria-controls="quarto-sidebar" aria-expanded="false" aria-label="Toggle sidebar navigation" onclick="if (window.quartoToggleHeadroom) { window.quartoToggleHeadroom(); }">
401 </a>
402 </div>
403 </nav>
404</header>
405<!-- content -->
406<div id="quarto-content" class="quarto-container page-columns page-rows-contents page-layout-article page-navbar">
407<!-- sidebar -->
408 <nav id="quarto-sidebar" class="sidebar collapse collapse-horizontal quarto-sidebar-collapse-item sidebar-navigation docked overflow-auto">
409 <div class="sidebar-menu-container">
410 <ul class="list-unstyled mt-1">
411 <li class="sidebar-item">
412 <div class="sidebar-item-container">
413 <a href="../index.html" class="sidebar-item-text sidebar-link">
414 <span class="menu-text">atdata</span></a>
415 </div>
416</li>
417 <li class="sidebar-item sidebar-item-section">
418 <div class="sidebar-item-container">
419 <a class="sidebar-item-text sidebar-link text-start" data-bs-toggle="collapse" data-bs-target="#quarto-sidebar-section-1" role="navigation" aria-expanded="true">
420 <span class="menu-text">Getting Started</span></a>
421 <a class="sidebar-item-toggle text-start" data-bs-toggle="collapse" data-bs-target="#quarto-sidebar-section-1" role="navigation" aria-expanded="true" aria-label="Toggle section">
422 <i class="bi bi-chevron-right ms-2"></i>
423 </a>
424 </div>
425 <ul id="quarto-sidebar-section-1" class="collapse list-unstyled sidebar-section depth1 show">
426 <li class="sidebar-item">
427 <div class="sidebar-item-container">
428 <a href="../tutorials/quickstart.html" class="sidebar-item-text sidebar-link">
429 <span class="menu-text">Quick Start</span></a>
430 </div>
431</li>
432 <li class="sidebar-item">
433 <div class="sidebar-item-container">
434 <a href="../tutorials/local-workflow.html" class="sidebar-item-text sidebar-link active">
435 <span class="menu-text">Local Workflow</span></a>
436 </div>
437</li>
438 <li class="sidebar-item">
439 <div class="sidebar-item-container">
440 <a href="../tutorials/atmosphere.html" class="sidebar-item-text sidebar-link">
441 <span class="menu-text">Atmosphere Publishing</span></a>
442 </div>
443</li>
444 <li class="sidebar-item">
445 <div class="sidebar-item-container">
446 <a href="../tutorials/promotion.html" class="sidebar-item-text sidebar-link">
447 <span class="menu-text">Promotion Workflow</span></a>
448 </div>
449</li>
450 </ul>
451 </li>
452 <li class="sidebar-item sidebar-item-section">
453 <div class="sidebar-item-container">
454 <a class="sidebar-item-text sidebar-link text-start" data-bs-toggle="collapse" data-bs-target="#quarto-sidebar-section-2" role="navigation" aria-expanded="true">
455 <span class="menu-text">Reference</span></a>
456 <a class="sidebar-item-toggle text-start" data-bs-toggle="collapse" data-bs-target="#quarto-sidebar-section-2" role="navigation" aria-expanded="true" aria-label="Toggle section">
457 <i class="bi bi-chevron-right ms-2"></i>
458 </a>
459 </div>
460 <ul id="quarto-sidebar-section-2" class="collapse list-unstyled sidebar-section depth1 show">
461 <li class="sidebar-item">
462 <div class="sidebar-item-container">
463 <a href="../reference/architecture.html" class="sidebar-item-text sidebar-link">
464 <span class="menu-text">Architecture Overview</span></a>
465 </div>
466</li>
467 <li class="sidebar-item">
468 <div class="sidebar-item-container">
469 <a href="../reference/packable-samples.html" class="sidebar-item-text sidebar-link">
470 <span class="menu-text">Packable Samples</span></a>
471 </div>
472</li>
473 <li class="sidebar-item">
474 <div class="sidebar-item-container">
475 <a href="../reference/datasets.html" class="sidebar-item-text sidebar-link">
476 <span class="menu-text">Datasets</span></a>
477 </div>
478</li>
479 <li class="sidebar-item">
480 <div class="sidebar-item-container">
481 <a href="../reference/lenses.html" class="sidebar-item-text sidebar-link">
482 <span class="menu-text">Lenses</span></a>
483 </div>
484</li>
485 <li class="sidebar-item">
486 <div class="sidebar-item-container">
487 <a href="../reference/local-storage.html" class="sidebar-item-text sidebar-link">
488 <span class="menu-text">Local Storage</span></a>
489 </div>
490</li>
491 <li class="sidebar-item">
492 <div class="sidebar-item-container">
493 <a href="../reference/atmosphere.html" class="sidebar-item-text sidebar-link">
494 <span class="menu-text">Atmosphere (ATProto Integration)</span></a>
495 </div>
496</li>
497 <li class="sidebar-item">
498 <div class="sidebar-item-container">
499 <a href="../reference/promotion.html" class="sidebar-item-text sidebar-link">
500 <span class="menu-text">Promotion Workflow</span></a>
501 </div>
502</li>
503 <li class="sidebar-item">
504 <div class="sidebar-item-container">
505 <a href="../reference/load-dataset.html" class="sidebar-item-text sidebar-link">
506 <span class="menu-text">load_dataset API</span></a>
507 </div>
508</li>
509 <li class="sidebar-item">
510 <div class="sidebar-item-container">
511 <a href="../reference/protocols.html" class="sidebar-item-text sidebar-link">
512 <span class="menu-text">Protocols</span></a>
513 </div>
514</li>
515 <li class="sidebar-item">
516 <div class="sidebar-item-container">
517 <a href="../reference/uri-spec.html" class="sidebar-item-text sidebar-link">
518 <span class="menu-text">URI Specification</span></a>
519 </div>
520</li>
521 <li class="sidebar-item">
522 <div class="sidebar-item-container">
523 <a href="../reference/troubleshooting.html" class="sidebar-item-text sidebar-link">
524 <span class="menu-text">Troubleshooting & FAQ</span></a>
525 </div>
526</li>
527 <li class="sidebar-item">
528 <div class="sidebar-item-container">
529 <a href="../reference/deployment.html" class="sidebar-item-text sidebar-link">
530 <span class="menu-text">Deployment Guide</span></a>
531 </div>
532</li>
533 </ul>
534 </li>
535 </ul>
536 </div>
537</nav>
538<div id="quarto-sidebar-glass" class="quarto-sidebar-collapse-item" data-bs-toggle="collapse" data-bs-target=".quarto-sidebar-collapse-item"></div>
539<!-- margin-sidebar -->
540 <div id="quarto-margin-sidebar" class="sidebar margin-sidebar">
541 <nav id="TOC" role="doc-toc" class="toc-active">
542 <h2 id="toc-title">On this page</h2>
543
544 <ul>
545 <li><a href="#why-team-storage" id="toc-why-team-storage" class="nav-link active" data-scroll-target="#why-team-storage">Why Team Storage?</a></li>
546 <li><a href="#prerequisites" id="toc-prerequisites" class="nav-link" data-scroll-target="#prerequisites">Prerequisites</a></li>
547 <li><a href="#setup" id="toc-setup" class="nav-link" data-scroll-target="#setup">Setup</a></li>
548 <li><a href="#define-sample-types" id="toc-define-sample-types" class="nav-link" data-scroll-target="#define-sample-types">Define Sample Types</a></li>
549 <li><a href="#localdatasetentry" id="toc-localdatasetentry" class="nav-link" data-scroll-target="#localdatasetentry">LocalDatasetEntry</a></li>
550 <li><a href="#localindex" id="toc-localindex" class="nav-link" data-scroll-target="#localindex">LocalIndex</a>
551 <ul class="collapse">
552 <li><a href="#schema-management" id="toc-schema-management" class="nav-link" data-scroll-target="#schema-management">Schema Management</a></li>
553 </ul></li>
554 <li><a href="#s3datastore" id="toc-s3datastore" class="nav-link" data-scroll-target="#s3datastore">S3DataStore</a></li>
555 <li><a href="#complete-index-workflow" id="toc-complete-index-workflow" class="nav-link" data-scroll-target="#complete-index-workflow">Complete Index Workflow</a></li>
556 <li><a href="#using-load_dataset-with-index" id="toc-using-load_dataset-with-index" class="nav-link" data-scroll-target="#using-load_dataset-with-index">Using load_dataset with Index</a></li>
557 <li><a href="#what-youve-learned" id="toc-what-youve-learned" class="nav-link" data-scroll-target="#what-youve-learned">What You’ve Learned</a></li>
558 <li><a href="#next-steps" id="toc-next-steps" class="nav-link" data-scroll-target="#next-steps">Next Steps</a></li>
559 </ul>
560<div class="toc-actions"><ul><li><a href="https://github.com/your-org/atdata/edit/main/tutorials/local-workflow.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>
561 </div>
562<!-- main -->
563<main class="content" id="quarto-document-content">
564
565
566<header id="title-block-header" class="quarto-title-block default"><nav class="quarto-page-breadcrumbs quarto-title-breadcrumbs d-none d-lg-block" aria-label="breadcrumb"><ol class="breadcrumb"><li class="breadcrumb-item"><a href="../tutorials/quickstart.html">Getting Started</a></li><li class="breadcrumb-item"><a href="../tutorials/local-workflow.html">Local Workflow</a></li></ol></nav>
567<div class="quarto-title">
568<h1 class="title">Local Workflow</h1>
569</div>
570
571<div>
572 <div class="description">
573 Store and manage datasets with Redis + S3
574 </div>
575</div>
576
577
578<div class="quarto-title-meta">
579
580
581
582
583 </div>
584
585
586
587</header>
588
589
590<p>This tutorial demonstrates how to use the local storage module to store and index datasets using Redis and S3-compatible storage. This is <strong>Layer 2</strong> of atdata’s architecture—team-scale storage that bridges local development and federated sharing.</p>
591<section id="why-team-storage" class="level2">
592<h2 class="anchored" data-anchor-id="why-team-storage">Why Team Storage?</h2>
593<p>Local tar files work well for individual experiments, but teams need:</p>
594<ul>
595<li><strong>Discovery</strong>: “What datasets do we have? What schema does this one use?”</li>
596<li><strong>Consistency</strong>: “Is everyone using the same version of this dataset?”</li>
597<li><strong>Durability</strong>: “Where’s the canonical copy of our training data?”</li>
598</ul>
599<p>atdata’s local storage module addresses these needs with a two-component architecture:</p>
600<table class="caption-top table">
601<colgroup>
602<col style="width: 55%">
603<col style="width: 45%">
604</colgroup>
605<thead>
606<tr class="header">
607<th>Component</th>
608<th>Purpose</th>
609</tr>
610</thead>
611<tbody>
612<tr class="odd">
613<td><strong>Redis Index</strong></td>
614<td>Fast metadata queries, schema registry, dataset discovery</td>
615</tr>
616<tr class="even">
617<td><strong>S3 DataStore</strong></td>
618<td>Scalable object storage for actual data files</td>
619</tr>
620</tbody>
621</table>
622<p>This separation means metadata operations (listing datasets, resolving schemas) are fast and don’t touch large data files, while the data itself lives in battle-tested object storage.</p>
623</section>
624<section id="prerequisites" class="level2">
625<h2 class="anchored" data-anchor-id="prerequisites">Prerequisites</h2>
626<ul>
627<li>Redis server running (default: <code>localhost:6379</code>)</li>
628<li>S3-compatible storage (MinIO, AWS S3, etc.)</li>
629</ul>
630<div class="callout callout-style-default callout-tip callout-titled">
631<div class="callout-header d-flex align-content-center">
632<div class="callout-icon-container">
633<i class="callout-icon"></i>
634</div>
635<div class="callout-title-container flex-fill">
636Tip
637</div>
638</div>
639<div class="callout-body-container callout-body">
640<p>For local development, you can use MinIO:</p>
641<div class="sourceCode" id="cb1"><pre class="sourceCode bash code-with-copy"><code class="sourceCode bash"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a><span class="ex">docker</span> run <span class="at">-p</span> 9000:9000 minio/minio server /data</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
642</div>
643</div>
644</section>
645<section id="setup" class="level2">
646<h2 class="anchored" data-anchor-id="setup">Setup</h2>
647<div id="0a2f50ff" class="cell">
648<div class="sourceCode cell-code" 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="im">import</span> numpy <span class="im">as</span> np</span>
649<span id="cb2-2"><a href="#cb2-2" aria-hidden="true" tabindex="-1"></a><span class="im">from</span> numpy.typing <span class="im">import</span> NDArray</span>
650<span id="cb2-3"><a href="#cb2-3" aria-hidden="true" tabindex="-1"></a><span class="im">import</span> atdata</span>
651<span id="cb2-4"><a href="#cb2-4" aria-hidden="true" tabindex="-1"></a><span class="im">from</span> atdata.local <span class="im">import</span> LocalIndex, LocalDatasetEntry, S3DataStore</span>
652<span id="cb2-5"><a href="#cb2-5" aria-hidden="true" tabindex="-1"></a><span class="im">import</span> webdataset <span class="im">as</span> wds</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
653</div>
654</section>
655<section id="define-sample-types" class="level2">
656<h2 class="anchored" data-anchor-id="define-sample-types">Define Sample Types</h2>
657<div id="cd43e33f" class="cell">
658<div class="sourceCode cell-code" 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><span class="at">@atdata.packable</span></span>
659<span id="cb3-2"><a href="#cb3-2" aria-hidden="true" tabindex="-1"></a><span class="kw">class</span> TrainingSample:</span>
660<span id="cb3-3"><a href="#cb3-3" aria-hidden="true" tabindex="-1"></a> <span class="co">"""A sample containing features and label for training."""</span></span>
661<span id="cb3-4"><a href="#cb3-4" aria-hidden="true" tabindex="-1"></a> features: NDArray</span>
662<span id="cb3-5"><a href="#cb3-5" aria-hidden="true" tabindex="-1"></a> label: <span class="bu">int</span></span>
663<span id="cb3-6"><a href="#cb3-6" aria-hidden="true" tabindex="-1"></a></span>
664<span id="cb3-7"><a href="#cb3-7" aria-hidden="true" tabindex="-1"></a><span class="at">@atdata.packable</span></span>
665<span id="cb3-8"><a href="#cb3-8" aria-hidden="true" tabindex="-1"></a><span class="kw">class</span> TextSample:</span>
666<span id="cb3-9"><a href="#cb3-9" aria-hidden="true" tabindex="-1"></a> <span class="co">"""A sample containing text data."""</span></span>
667<span id="cb3-10"><a href="#cb3-10" aria-hidden="true" tabindex="-1"></a> text: <span class="bu">str</span></span>
668<span id="cb3-11"><a href="#cb3-11" aria-hidden="true" tabindex="-1"></a> category: <span class="bu">str</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
669</div>
670</section>
671<section id="localdatasetentry" class="level2">
672<h2 class="anchored" data-anchor-id="localdatasetentry">LocalDatasetEntry</h2>
673<p>Every dataset in the index is represented by a <code>LocalDatasetEntry</code>. A key design decision: entries use <strong>content-addressable CIDs</strong> (Content Identifiers) as their identity. This means:</p>
674<ul>
675<li>Identical content always has the same CID</li>
676<li>You can verify data integrity by checking the CID</li>
677<li>Deduplication happens automatically</li>
678</ul>
679<p>CIDs are computed from the entry’s schema reference and data URLs, so the same logical dataset will have the same CID regardless of where it’s stored.</p>
680<p>Create entries with content-addressable CIDs:</p>
681<div id="6e2dd5de" class="cell">
682<div class="sourceCode cell-code" 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="co"># Create an entry manually</span></span>
683<span id="cb4-2"><a href="#cb4-2" aria-hidden="true" tabindex="-1"></a>entry <span class="op">=</span> LocalDatasetEntry(</span>
684<span id="cb4-3"><a href="#cb4-3" aria-hidden="true" tabindex="-1"></a> _name<span class="op">=</span><span class="st">"my-dataset"</span>,</span>
685<span id="cb4-4"><a href="#cb4-4" aria-hidden="true" tabindex="-1"></a> _schema_ref<span class="op">=</span><span class="st">"local://schemas/examples.TrainingSample@1.0.0"</span>,</span>
686<span id="cb4-5"><a href="#cb4-5" aria-hidden="true" tabindex="-1"></a> _data_urls<span class="op">=</span>[<span class="st">"s3://bucket/data-000000.tar"</span>, <span class="st">"s3://bucket/data-000001.tar"</span>],</span>
687<span id="cb4-6"><a href="#cb4-6" aria-hidden="true" tabindex="-1"></a> _metadata<span class="op">=</span>{<span class="st">"source"</span>: <span class="st">"example"</span>, <span class="st">"samples"</span>: <span class="dv">10000</span>},</span>
688<span id="cb4-7"><a href="#cb4-7" aria-hidden="true" tabindex="-1"></a>)</span>
689<span id="cb4-8"><a href="#cb4-8" aria-hidden="true" tabindex="-1"></a></span>
690<span id="cb4-9"><a href="#cb4-9" aria-hidden="true" tabindex="-1"></a><span class="bu">print</span>(<span class="ss">f"Entry name: </span><span class="sc">{</span>entry<span class="sc">.</span>name<span class="sc">}</span><span class="ss">"</span>)</span>
691<span id="cb4-10"><a href="#cb4-10" aria-hidden="true" tabindex="-1"></a><span class="bu">print</span>(<span class="ss">f"Schema ref: </span><span class="sc">{</span>entry<span class="sc">.</span>schema_ref<span class="sc">}</span><span class="ss">"</span>)</span>
692<span id="cb4-11"><a href="#cb4-11" aria-hidden="true" tabindex="-1"></a><span class="bu">print</span>(<span class="ss">f"Data URLs: </span><span class="sc">{</span>entry<span class="sc">.</span>data_urls<span class="sc">}</span><span class="ss">"</span>)</span>
693<span id="cb4-12"><a href="#cb4-12" aria-hidden="true" tabindex="-1"></a><span class="bu">print</span>(<span class="ss">f"Metadata: </span><span class="sc">{</span>entry<span class="sc">.</span>metadata<span class="sc">}</span><span class="ss">"</span>)</span>
694<span id="cb4-13"><a href="#cb4-13" aria-hidden="true" tabindex="-1"></a><span class="bu">print</span>(<span class="ss">f"CID: </span><span class="sc">{</span>entry<span class="sc">.</span>cid<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>
695</div>
696<div class="callout callout-style-default callout-note callout-titled">
697<div class="callout-header d-flex align-content-center">
698<div class="callout-icon-container">
699<i class="callout-icon"></i>
700</div>
701<div class="callout-title-container flex-fill">
702Note
703</div>
704</div>
705<div class="callout-body-container callout-body">
706<p>CIDs are generated from content (schema_ref + data_urls), so identical data produces identical CIDs.</p>
707</div>
708</div>
709</section>
710<section id="localindex" class="level2">
711<h2 class="anchored" data-anchor-id="localindex">LocalIndex</h2>
712<p>The <code>LocalIndex</code> is your team’s dataset registry. It implements the <code>AbstractIndex</code> protocol, meaning code written against <code>LocalIndex</code> will also work with <code>AtmosphereIndex</code> when you’re ready for federated sharing.</p>
713<p>The index tracks datasets in Redis:</p>
714<div id="a315adcf" class="cell">
715<div class="sourceCode cell-code" 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><span class="im">from</span> redis <span class="im">import</span> Redis</span>
716<span id="cb5-2"><a href="#cb5-2" aria-hidden="true" tabindex="-1"></a></span>
717<span id="cb5-3"><a href="#cb5-3" aria-hidden="true" tabindex="-1"></a><span class="co"># Connect to Redis</span></span>
718<span id="cb5-4"><a href="#cb5-4" aria-hidden="true" tabindex="-1"></a>redis <span class="op">=</span> Redis(host<span class="op">=</span><span class="st">"localhost"</span>, port<span class="op">=</span><span class="dv">6379</span>)</span>
719<span id="cb5-5"><a href="#cb5-5" aria-hidden="true" tabindex="-1"></a>index <span class="op">=</span> LocalIndex(redis<span class="op">=</span>redis)</span>
720<span id="cb5-6"><a href="#cb5-6" aria-hidden="true" tabindex="-1"></a></span>
721<span id="cb5-7"><a href="#cb5-7" aria-hidden="true" tabindex="-1"></a><span class="bu">print</span>(<span class="st">"LocalIndex connected"</span>)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
722</div>
723<section id="schema-management" class="level3">
724<h3 class="anchored" data-anchor-id="schema-management">Schema Management</h3>
725<p><strong>Schema publishing</strong> is how you ensure type consistency across your team. When you publish a schema, atdata stores the complete type definition (field names, types, metadata) so anyone can reconstruct the Python class from just the schema reference.</p>
726<p>This enables a powerful workflow: share a dataset by sharing its name, and consumers can dynamically reconstruct the sample type without having the original Python code.</p>
727<div id="45693810" class="cell">
728<div class="sourceCode cell-code" 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><span class="co"># Publish a schema</span></span>
729<span id="cb6-2"><a href="#cb6-2" aria-hidden="true" tabindex="-1"></a>schema_ref <span class="op">=</span> index.publish_schema(TrainingSample, version<span class="op">=</span><span class="st">"1.0.0"</span>)</span>
730<span id="cb6-3"><a href="#cb6-3" aria-hidden="true" tabindex="-1"></a><span class="bu">print</span>(<span class="ss">f"Published schema: </span><span class="sc">{</span>schema_ref<span class="sc">}</span><span class="ss">"</span>)</span>
731<span id="cb6-4"><a href="#cb6-4" aria-hidden="true" tabindex="-1"></a></span>
732<span id="cb6-5"><a href="#cb6-5" aria-hidden="true" tabindex="-1"></a><span class="co"># List all schemas</span></span>
733<span id="cb6-6"><a href="#cb6-6" aria-hidden="true" tabindex="-1"></a><span class="cf">for</span> schema <span class="kw">in</span> index.list_schemas():</span>
734<span id="cb6-7"><a href="#cb6-7" aria-hidden="true" tabindex="-1"></a> <span class="bu">print</span>(<span class="ss">f" - </span><span class="sc">{</span>schema<span class="sc">.</span>get(<span class="st">'name'</span>, <span class="st">'Unknown'</span>)<span class="sc">}</span><span class="ss"> v</span><span class="sc">{</span>schema<span class="sc">.</span>get(<span class="st">'version'</span>, <span class="st">'?'</span>)<span class="sc">}</span><span class="ss">"</span>)</span>
735<span id="cb6-8"><a href="#cb6-8" aria-hidden="true" tabindex="-1"></a></span>
736<span id="cb6-9"><a href="#cb6-9" aria-hidden="true" tabindex="-1"></a><span class="co"># Get schema record</span></span>
737<span id="cb6-10"><a href="#cb6-10" aria-hidden="true" tabindex="-1"></a>schema_record <span class="op">=</span> index.get_schema(schema_ref)</span>
738<span id="cb6-11"><a href="#cb6-11" aria-hidden="true" tabindex="-1"></a><span class="bu">print</span>(<span class="ss">f"Schema fields: </span><span class="sc">{</span>[f[<span class="st">'name'</span>] <span class="cf">for</span> f <span class="kw">in</span> schema_record.get(<span class="st">'fields'</span>, [])]<span class="sc">}</span><span class="ss">"</span>)</span>
739<span id="cb6-12"><a href="#cb6-12" aria-hidden="true" tabindex="-1"></a></span>
740<span id="cb6-13"><a href="#cb6-13" aria-hidden="true" tabindex="-1"></a><span class="co"># Decode schema back to a PackableSample class</span></span>
741<span id="cb6-14"><a href="#cb6-14" aria-hidden="true" tabindex="-1"></a>decoded_type <span class="op">=</span> index.decode_schema(schema_ref)</span>
742<span id="cb6-15"><a href="#cb6-15" aria-hidden="true" tabindex="-1"></a><span class="bu">print</span>(<span class="ss">f"Decoded type: </span><span class="sc">{</span>decoded_type<span class="sc">.</span><span class="va">__name__</span><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>
743</div>
744</section>
745</section>
746<section id="s3datastore" class="level2">
747<h2 class="anchored" data-anchor-id="s3datastore">S3DataStore</h2>
748<p>The <code>S3DataStore</code> implements the <code>AbstractDataStore</code> protocol for S3-compatible object storage. It works with:</p>
749<ul>
750<li><strong>AWS S3</strong>: Production-scale cloud storage</li>
751<li><strong>MinIO</strong>: Self-hosted S3-compatible storage (great for development)</li>
752<li><strong>Cloudflare R2</strong>: Cost-effective S3-compatible storage</li>
753</ul>
754<p>The data store handles uploading tar shards and creating signed URLs for streaming access.</p>
755<p>For direct S3 operations:</p>
756<div id="fdea4349" class="cell">
757<div class="sourceCode cell-code" 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>creds <span class="op">=</span> {</span>
758<span id="cb7-2"><a href="#cb7-2" aria-hidden="true" tabindex="-1"></a> <span class="st">"AWS_ENDPOINT"</span>: <span class="st">"http://localhost:9000"</span>,</span>
759<span id="cb7-3"><a href="#cb7-3" aria-hidden="true" tabindex="-1"></a> <span class="st">"AWS_ACCESS_KEY_ID"</span>: <span class="st">"minioadmin"</span>,</span>
760<span id="cb7-4"><a href="#cb7-4" aria-hidden="true" tabindex="-1"></a> <span class="st">"AWS_SECRET_ACCESS_KEY"</span>: <span class="st">"minioadmin"</span>,</span>
761<span id="cb7-5"><a href="#cb7-5" aria-hidden="true" tabindex="-1"></a>}</span>
762<span id="cb7-6"><a href="#cb7-6" aria-hidden="true" tabindex="-1"></a></span>
763<span id="cb7-7"><a href="#cb7-7" aria-hidden="true" tabindex="-1"></a>store <span class="op">=</span> S3DataStore(creds, bucket<span class="op">=</span><span class="st">"my-bucket"</span>)</span>
764<span id="cb7-8"><a href="#cb7-8" aria-hidden="true" tabindex="-1"></a></span>
765<span id="cb7-9"><a href="#cb7-9" aria-hidden="true" tabindex="-1"></a><span class="bu">print</span>(<span class="ss">f"Bucket: </span><span class="sc">{</span>store<span class="sc">.</span>bucket<span class="sc">}</span><span class="ss">"</span>)</span>
766<span id="cb7-10"><a href="#cb7-10" aria-hidden="true" tabindex="-1"></a><span class="bu">print</span>(<span class="ss">f"Supports streaming: </span><span class="sc">{</span>store<span class="sc">.</span>supports_streaming()<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>
767</div>
768</section>
769<section id="complete-index-workflow" class="level2">
770<h2 class="anchored" data-anchor-id="complete-index-workflow">Complete Index Workflow</h2>
771<p>Here’s the typical workflow for publishing a dataset to your team:</p>
772<ol type="1">
773<li><strong>Create samples</strong> using your <code>@packable</code> type</li>
774<li><strong>Write to local tar</strong> for staging</li>
775<li><strong>Create a Dataset</strong> wrapper</li>
776<li><strong>Connect to index with data store</strong></li>
777<li><strong>Publish schema</strong> for type consistency</li>
778<li><strong>Insert dataset</strong> (uploads to S3, indexes in Redis)</li>
779</ol>
780<p>The index composition pattern (<code>LocalIndex(data_store=S3DataStore(...))</code>) is deliberate—it separates the concern of “where is metadata?” from “where is data?”, making it easy to swap storage backends.</p>
781<p>Use <code>LocalIndex</code> with <code>S3DataStore</code> to store datasets with S3 storage and Redis indexing:</p>
782<div id="f7933f51" class="cell">
783<div class="sourceCode cell-code" 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><span class="co"># 1. Create sample data</span></span>
784<span id="cb8-2"><a href="#cb8-2" aria-hidden="true" tabindex="-1"></a>samples <span class="op">=</span> [</span>
785<span id="cb8-3"><a href="#cb8-3" aria-hidden="true" tabindex="-1"></a> TrainingSample(</span>
786<span id="cb8-4"><a href="#cb8-4" aria-hidden="true" tabindex="-1"></a> features<span class="op">=</span>np.random.randn(<span class="dv">128</span>).astype(np.float32),</span>
787<span id="cb8-5"><a href="#cb8-5" aria-hidden="true" tabindex="-1"></a> label<span class="op">=</span>i <span class="op">%</span> <span class="dv">10</span></span>
788<span id="cb8-6"><a href="#cb8-6" aria-hidden="true" tabindex="-1"></a> )</span>
789<span id="cb8-7"><a href="#cb8-7" aria-hidden="true" tabindex="-1"></a> <span class="cf">for</span> i <span class="kw">in</span> <span class="bu">range</span>(<span class="dv">1000</span>)</span>
790<span id="cb8-8"><a href="#cb8-8" aria-hidden="true" tabindex="-1"></a>]</span>
791<span id="cb8-9"><a href="#cb8-9" aria-hidden="true" tabindex="-1"></a><span class="bu">print</span>(<span class="ss">f"Created </span><span class="sc">{</span><span class="bu">len</span>(samples)<span class="sc">}</span><span class="ss"> training samples"</span>)</span>
792<span id="cb8-10"><a href="#cb8-10" aria-hidden="true" tabindex="-1"></a></span>
793<span id="cb8-11"><a href="#cb8-11" aria-hidden="true" tabindex="-1"></a><span class="co"># 2. Write to local tar file</span></span>
794<span id="cb8-12"><a href="#cb8-12" aria-hidden="true" tabindex="-1"></a><span class="cf">with</span> wds.writer.TarWriter(<span class="st">"local-data-000000.tar"</span>) <span class="im">as</span> sink:</span>
795<span id="cb8-13"><a href="#cb8-13" aria-hidden="true" tabindex="-1"></a> <span class="cf">for</span> i, sample <span class="kw">in</span> <span class="bu">enumerate</span>(samples):</span>
796<span id="cb8-14"><a href="#cb8-14" aria-hidden="true" tabindex="-1"></a> sink.write({<span class="op">**</span>sample.as_wds, <span class="st">"__key__"</span>: <span class="ss">f"sample_</span><span class="sc">{</span>i<span class="sc">:06d}</span><span class="ss">"</span>})</span>
797<span id="cb8-15"><a href="#cb8-15" aria-hidden="true" tabindex="-1"></a><span class="bu">print</span>(<span class="st">"Wrote samples to local tar file"</span>)</span>
798<span id="cb8-16"><a href="#cb8-16" aria-hidden="true" tabindex="-1"></a></span>
799<span id="cb8-17"><a href="#cb8-17" aria-hidden="true" tabindex="-1"></a><span class="co"># 3. Create Dataset</span></span>
800<span id="cb8-18"><a href="#cb8-18" aria-hidden="true" tabindex="-1"></a>ds <span class="op">=</span> atdata.Dataset[TrainingSample](<span class="st">"local-data-000000.tar"</span>)</span>
801<span id="cb8-19"><a href="#cb8-19" aria-hidden="true" tabindex="-1"></a></span>
802<span id="cb8-20"><a href="#cb8-20" aria-hidden="true" tabindex="-1"></a><span class="co"># 4. Set up index with S3 data store and insert</span></span>
803<span id="cb8-21"><a href="#cb8-21" aria-hidden="true" tabindex="-1"></a>store <span class="op">=</span> S3DataStore(</span>
804<span id="cb8-22"><a href="#cb8-22" aria-hidden="true" tabindex="-1"></a> credentials<span class="op">=</span>{</span>
805<span id="cb8-23"><a href="#cb8-23" aria-hidden="true" tabindex="-1"></a> <span class="st">"AWS_ENDPOINT"</span>: <span class="st">"http://localhost:9000"</span>,</span>
806<span id="cb8-24"><a href="#cb8-24" aria-hidden="true" tabindex="-1"></a> <span class="st">"AWS_ACCESS_KEY_ID"</span>: <span class="st">"minioadmin"</span>,</span>
807<span id="cb8-25"><a href="#cb8-25" aria-hidden="true" tabindex="-1"></a> <span class="st">"AWS_SECRET_ACCESS_KEY"</span>: <span class="st">"minioadmin"</span>,</span>
808<span id="cb8-26"><a href="#cb8-26" aria-hidden="true" tabindex="-1"></a> },</span>
809<span id="cb8-27"><a href="#cb8-27" aria-hidden="true" tabindex="-1"></a> bucket<span class="op">=</span><span class="st">"my-bucket"</span>,</span>
810<span id="cb8-28"><a href="#cb8-28" aria-hidden="true" tabindex="-1"></a>)</span>
811<span id="cb8-29"><a href="#cb8-29" aria-hidden="true" tabindex="-1"></a>index <span class="op">=</span> LocalIndex(redis<span class="op">=</span>redis, data_store<span class="op">=</span>store)</span>
812<span id="cb8-30"><a href="#cb8-30" aria-hidden="true" tabindex="-1"></a></span>
813<span id="cb8-31"><a href="#cb8-31" aria-hidden="true" tabindex="-1"></a><span class="co"># Publish schema and insert dataset</span></span>
814<span id="cb8-32"><a href="#cb8-32" aria-hidden="true" tabindex="-1"></a>index.publish_schema(TrainingSample, version<span class="op">=</span><span class="st">"1.0.0"</span>)</span>
815<span id="cb8-33"><a href="#cb8-33" aria-hidden="true" tabindex="-1"></a>entry <span class="op">=</span> index.insert_dataset(ds, name<span class="op">=</span><span class="st">"training-v1"</span>, prefix<span class="op">=</span><span class="st">"datasets"</span>)</span>
816<span id="cb8-34"><a href="#cb8-34" aria-hidden="true" tabindex="-1"></a><span class="bu">print</span>(<span class="ss">f"Stored at: </span><span class="sc">{</span>entry<span class="sc">.</span>data_urls<span class="sc">}</span><span class="ss">"</span>)</span>
817<span id="cb8-35"><a href="#cb8-35" aria-hidden="true" tabindex="-1"></a><span class="bu">print</span>(<span class="ss">f"CID: </span><span class="sc">{</span>entry<span class="sc">.</span>cid<span class="sc">}</span><span class="ss">"</span>)</span>
818<span id="cb8-36"><a href="#cb8-36" aria-hidden="true" tabindex="-1"></a></span>
819<span id="cb8-37"><a href="#cb8-37" aria-hidden="true" tabindex="-1"></a><span class="co"># 5. Retrieve later</span></span>
820<span id="cb8-38"><a href="#cb8-38" aria-hidden="true" tabindex="-1"></a>retrieved_entry <span class="op">=</span> index.get_entry_by_name(<span class="st">"training-v1"</span>)</span>
821<span id="cb8-39"><a href="#cb8-39" aria-hidden="true" tabindex="-1"></a>dataset <span class="op">=</span> atdata.Dataset[TrainingSample](retrieved_entry.data_urls[<span class="dv">0</span>])</span>
822<span id="cb8-40"><a href="#cb8-40" aria-hidden="true" tabindex="-1"></a></span>
823<span id="cb8-41"><a href="#cb8-41" aria-hidden="true" tabindex="-1"></a><span class="cf">for</span> batch <span class="kw">in</span> dataset.ordered(batch_size<span class="op">=</span><span class="dv">32</span>):</span>
824<span id="cb8-42"><a href="#cb8-42" aria-hidden="true" tabindex="-1"></a> <span class="bu">print</span>(<span class="ss">f"Batch features shape: </span><span class="sc">{</span>batch<span class="sc">.</span>features<span class="sc">.</span>shape<span class="sc">}</span><span class="ss">"</span>)</span>
825<span id="cb8-43"><a href="#cb8-43" aria-hidden="true" tabindex="-1"></a> <span class="cf">break</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
826</div>
827</section>
828<section id="using-load_dataset-with-index" class="level2">
829<h2 class="anchored" data-anchor-id="using-load_dataset-with-index">Using load_dataset with Index</h2>
830<p>The <code>load_dataset()</code> function provides a HuggingFace-style API that abstracts away the details of where data lives. When you pass an index, it can resolve <code>@local/</code> prefixed paths to the actual data URLs and apply the correct credentials automatically.</p>
831<p>The <code>load_dataset()</code> function supports index lookup:</p>
832<div id="71d86430" class="cell">
833<div class="sourceCode cell-code" 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><span class="im">from</span> atdata <span class="im">import</span> load_dataset</span>
834<span id="cb9-2"><a href="#cb9-2" aria-hidden="true" tabindex="-1"></a></span>
835<span id="cb9-3"><a href="#cb9-3" aria-hidden="true" tabindex="-1"></a><span class="co"># Load from local index</span></span>
836<span id="cb9-4"><a href="#cb9-4" aria-hidden="true" tabindex="-1"></a>ds <span class="op">=</span> load_dataset(<span class="st">"@local/my-dataset"</span>, index<span class="op">=</span>index, split<span class="op">=</span><span class="st">"train"</span>)</span>
837<span id="cb9-5"><a href="#cb9-5" aria-hidden="true" tabindex="-1"></a></span>
838<span id="cb9-6"><a href="#cb9-6" aria-hidden="true" tabindex="-1"></a><span class="co"># The index resolves the dataset name to URLs and schema</span></span>
839<span id="cb9-7"><a href="#cb9-7" aria-hidden="true" tabindex="-1"></a><span class="cf">for</span> batch <span class="kw">in</span> ds.shuffled(batch_size<span class="op">=</span><span class="dv">32</span>):</span>
840<span id="cb9-8"><a href="#cb9-8" aria-hidden="true" tabindex="-1"></a> process(batch)</span>
841<span id="cb9-9"><a href="#cb9-9" aria-hidden="true" tabindex="-1"></a> <span class="cf">break</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
842</div>
843</section>
844<section id="what-youve-learned" class="level2">
845<h2 class="anchored" data-anchor-id="what-youve-learned">What You’ve Learned</h2>
846<p>You now understand team-scale storage in atdata:</p>
847<table class="caption-top table">
848<colgroup>
849<col style="width: 50%">
850<col style="width: 50%">
851</colgroup>
852<thead>
853<tr class="header">
854<th>Concept</th>
855<th>Purpose</th>
856</tr>
857</thead>
858<tbody>
859<tr class="odd">
860<td><code>LocalIndex</code></td>
861<td>Redis-backed dataset registry implementing <code>AbstractIndex</code></td>
862</tr>
863<tr class="even">
864<td><code>S3DataStore</code></td>
865<td>S3-compatible object storage implementing <code>AbstractDataStore</code></td>
866</tr>
867<tr class="odd">
868<td><code>LocalDatasetEntry</code></td>
869<td>Content-addressed dataset entries with CIDs</td>
870</tr>
871<tr class="even">
872<td>Schema publishing</td>
873<td>Shared type definitions for team consistency</td>
874</tr>
875</tbody>
876</table>
877<p>The same sample types you defined in the Quick Start work seamlessly here—the only change is where the data lives.</p>
878</section>
879<section id="next-steps" class="level2">
880<h2 class="anchored" data-anchor-id="next-steps">Next Steps</h2>
881<div class="callout callout-style-default callout-tip callout-titled">
882<div class="callout-header d-flex align-content-center">
883<div class="callout-icon-container">
884<i class="callout-icon"></i>
885</div>
886<div class="callout-title-container flex-fill">
887Ready for Public Sharing?
888</div>
889</div>
890<div class="callout-body-container callout-body">
891<p>The <a href="../tutorials/atmosphere.html">Atmosphere Publishing</a> tutorial shows how to publish datasets to the ATProto network for decentralized, cross-organization discovery.</p>
892</div>
893</div>
894<ul>
895<li><strong><a href="../tutorials/atmosphere.html">Atmosphere Publishing</a></strong> - Publish to ATProto federation</li>
896<li><strong><a href="../tutorials/promotion.html">Promotion Workflow</a></strong> - Migrate from local to atmosphere</li>
897<li><strong><a href="../reference/local-storage.html">Local Storage Reference</a></strong> - Complete API reference</li>
898</ul>
899
900
901</section>
902
903</main> <!-- /main -->
904<script id="quarto-html-after-body" type="application/javascript">
905 window.document.addEventListener("DOMContentLoaded", function (event) {
906 // Ensure there is a toggle, if there isn't float one in the top right
907 if (window.document.querySelector('.quarto-color-scheme-toggle') === null) {
908 const a = window.document.createElement('a');
909 a.classList.add('top-right');
910 a.classList.add('quarto-color-scheme-toggle');
911 a.href = "";
912 a.onclick = function() { try { window.quartoToggleColorScheme(); } catch {} return false; };
913 const i = window.document.createElement("i");
914 i.classList.add('bi');
915 a.appendChild(i);
916 window.document.body.appendChild(a);
917 }
918 setColorSchemeToggle(hasAlternateSentinel())
919 const icon = "";
920 const anchorJS = new window.AnchorJS();
921 anchorJS.options = {
922 placement: 'right',
923 icon: icon
924 };
925 anchorJS.add('.anchored');
926 const isCodeAnnotation = (el) => {
927 for (const clz of el.classList) {
928 if (clz.startsWith('code-annotation-')) {
929 return true;
930 }
931 }
932 return false;
933 }
934 const onCopySuccess = function(e) {
935 // button target
936 const button = e.trigger;
937 // don't keep focus
938 button.blur();
939 // flash "checked"
940 button.classList.add('code-copy-button-checked');
941 var currentTitle = button.getAttribute("title");
942 button.setAttribute("title", "Copied!");
943 let tooltip;
944 if (window.bootstrap) {
945 button.setAttribute("data-bs-toggle", "tooltip");
946 button.setAttribute("data-bs-placement", "left");
947 button.setAttribute("data-bs-title", "Copied!");
948 tooltip = new bootstrap.Tooltip(button,
949 { trigger: "manual",
950 customClass: "code-copy-button-tooltip",
951 offset: [0, -8]});
952 tooltip.show();
953 }
954 setTimeout(function() {
955 if (tooltip) {
956 tooltip.hide();
957 button.removeAttribute("data-bs-title");
958 button.removeAttribute("data-bs-toggle");
959 button.removeAttribute("data-bs-placement");
960 }
961 button.setAttribute("title", currentTitle);
962 button.classList.remove('code-copy-button-checked');
963 }, 1000);
964 // clear code selection
965 e.clearSelection();
966 }
967 const getTextToCopy = function(trigger) {
968 const codeEl = trigger.previousElementSibling.cloneNode(true);
969 for (const childEl of codeEl.children) {
970 if (isCodeAnnotation(childEl)) {
971 childEl.remove();
972 }
973 }
974 return codeEl.innerText;
975 }
976 const clipboard = new window.ClipboardJS('.code-copy-button:not([data-in-quarto-modal])', {
977 text: getTextToCopy
978 });
979 clipboard.on('success', onCopySuccess);
980 if (window.document.getElementById('quarto-embedded-source-code-modal')) {
981 const clipboardModal = new window.ClipboardJS('.code-copy-button[data-in-quarto-modal]', {
982 text: getTextToCopy,
983 container: window.document.getElementById('quarto-embedded-source-code-modal')
984 });
985 clipboardModal.on('success', onCopySuccess);
986 }
987 var localhostRegex = new RegExp(/^(?:http|https):\/\/localhost\:?[0-9]*\//);
988 var mailtoRegex = new RegExp(/^mailto:/);
989 var filterRegex = new RegExp("https:\/\/github\.com\/your-org\/atdata");
990 var isInternal = (href) => {
991 return filterRegex.test(href) || localhostRegex.test(href) || mailtoRegex.test(href);
992 }
993 // Inspect non-navigation links and adorn them if external
994 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)');
995 for (var i=0; i<links.length; i++) {
996 const link = links[i];
997 if (!isInternal(link.href)) {
998 // undo the damage that might have been done by quarto-nav.js in the case of
999 // links that we want to consider external
1000 if (link.dataset.originalHref !== undefined) {
1001 link.href = link.dataset.originalHref;
1002 }
1003 }
1004 }
1005 function tippyHover(el, contentFn, onTriggerFn, onUntriggerFn) {
1006 const config = {
1007 allowHTML: true,
1008 maxWidth: 500,
1009 delay: 100,
1010 arrow: false,
1011 appendTo: function(el) {
1012 return el.parentElement;
1013 },
1014 interactive: true,
1015 interactiveBorder: 10,
1016 theme: 'quarto',
1017 placement: 'bottom-start',
1018 };
1019 if (contentFn) {
1020 config.content = contentFn;
1021 }
1022 if (onTriggerFn) {
1023 config.onTrigger = onTriggerFn;
1024 }
1025 if (onUntriggerFn) {
1026 config.onUntrigger = onUntriggerFn;
1027 }
1028 window.tippy(el, config);
1029 }
1030 const noterefs = window.document.querySelectorAll('a[role="doc-noteref"]');
1031 for (var i=0; i<noterefs.length; i++) {
1032 const ref = noterefs[i];
1033 tippyHover(ref, function() {
1034 // use id or data attribute instead here
1035 let href = ref.getAttribute('data-footnote-href') || ref.getAttribute('href');
1036 try { href = new URL(href).hash; } catch {}
1037 const id = href.replace(/^#\/?/, "");
1038 const note = window.document.getElementById(id);
1039 if (note) {
1040 return note.innerHTML;
1041 } else {
1042 return "";
1043 }
1044 });
1045 }
1046 const xrefs = window.document.querySelectorAll('a.quarto-xref');
1047 const processXRef = (id, note) => {
1048 // Strip column container classes
1049 const stripColumnClz = (el) => {
1050 el.classList.remove("page-full", "page-columns");
1051 if (el.children) {
1052 for (const child of el.children) {
1053 stripColumnClz(child);
1054 }
1055 }
1056 }
1057 stripColumnClz(note)
1058 if (id === null || id.startsWith('sec-')) {
1059 // Special case sections, only their first couple elements
1060 const container = document.createElement("div");
1061 if (note.children && note.children.length > 2) {
1062 container.appendChild(note.children[0].cloneNode(true));
1063 for (let i = 1; i < note.children.length; i++) {
1064 const child = note.children[i];
1065 if (child.tagName === "P" && child.innerText === "") {
1066 continue;
1067 } else {
1068 container.appendChild(child.cloneNode(true));
1069 break;
1070 }
1071 }
1072 if (window.Quarto?.typesetMath) {
1073 window.Quarto.typesetMath(container);
1074 }
1075 return container.innerHTML
1076 } else {
1077 if (window.Quarto?.typesetMath) {
1078 window.Quarto.typesetMath(note);
1079 }
1080 return note.innerHTML;
1081 }
1082 } else {
1083 // Remove any anchor links if they are present
1084 const anchorLink = note.querySelector('a.anchorjs-link');
1085 if (anchorLink) {
1086 anchorLink.remove();
1087 }
1088 if (window.Quarto?.typesetMath) {
1089 window.Quarto.typesetMath(note);
1090 }
1091 if (note.classList.contains("callout")) {
1092 return note.outerHTML;
1093 } else {
1094 return note.innerHTML;
1095 }
1096 }
1097 }
1098 for (var i=0; i<xrefs.length; i++) {
1099 const xref = xrefs[i];
1100 tippyHover(xref, undefined, function(instance) {
1101 instance.disable();
1102 let url = xref.getAttribute('href');
1103 let hash = undefined;
1104 if (url.startsWith('#')) {
1105 hash = url;
1106 } else {
1107 try { hash = new URL(url).hash; } catch {}
1108 }
1109 if (hash) {
1110 const id = hash.replace(/^#\/?/, "");
1111 const note = window.document.getElementById(id);
1112 if (note !== null) {
1113 try {
1114 const html = processXRef(id, note.cloneNode(true));
1115 instance.setContent(html);
1116 } finally {
1117 instance.enable();
1118 instance.show();
1119 }
1120 } else {
1121 // See if we can fetch this
1122 fetch(url.split('#')[0])
1123 .then(res => res.text())
1124 .then(html => {
1125 const parser = new DOMParser();
1126 const htmlDoc = parser.parseFromString(html, "text/html");
1127 const note = htmlDoc.getElementById(id);
1128 if (note !== null) {
1129 const html = processXRef(id, note);
1130 instance.setContent(html);
1131 }
1132 }).finally(() => {
1133 instance.enable();
1134 instance.show();
1135 });
1136 }
1137 } else {
1138 // See if we can fetch a full url (with no hash to target)
1139 // This is a special case and we should probably do some content thinning / targeting
1140 fetch(url)
1141 .then(res => res.text())
1142 .then(html => {
1143 const parser = new DOMParser();
1144 const htmlDoc = parser.parseFromString(html, "text/html");
1145 const note = htmlDoc.querySelector('main.content');
1146 if (note !== null) {
1147 // This should only happen for chapter cross references
1148 // (since there is no id in the URL)
1149 // remove the first header
1150 if (note.children.length > 0 && note.children[0].tagName === "HEADER") {
1151 note.children[0].remove();
1152 }
1153 const html = processXRef(null, note);
1154 instance.setContent(html);
1155 }
1156 }).finally(() => {
1157 instance.enable();
1158 instance.show();
1159 });
1160 }
1161 }, function(instance) {
1162 });
1163 }
1164 let selectedAnnoteEl;
1165 const selectorForAnnotation = ( cell, annotation) => {
1166 let cellAttr = 'data-code-cell="' + cell + '"';
1167 let lineAttr = 'data-code-annotation="' + annotation + '"';
1168 const selector = 'span[' + cellAttr + '][' + lineAttr + ']';
1169 return selector;
1170 }
1171 const selectCodeLines = (annoteEl) => {
1172 const doc = window.document;
1173 const targetCell = annoteEl.getAttribute("data-target-cell");
1174 const targetAnnotation = annoteEl.getAttribute("data-target-annotation");
1175 const annoteSpan = window.document.querySelector(selectorForAnnotation(targetCell, targetAnnotation));
1176 const lines = annoteSpan.getAttribute("data-code-lines").split(",");
1177 const lineIds = lines.map((line) => {
1178 return targetCell + "-" + line;
1179 })
1180 let top = null;
1181 let height = null;
1182 let parent = null;
1183 if (lineIds.length > 0) {
1184 //compute the position of the single el (top and bottom and make a div)
1185 const el = window.document.getElementById(lineIds[0]);
1186 top = el.offsetTop;
1187 height = el.offsetHeight;
1188 parent = el.parentElement.parentElement;
1189 if (lineIds.length > 1) {
1190 const lastEl = window.document.getElementById(lineIds[lineIds.length - 1]);
1191 const bottom = lastEl.offsetTop + lastEl.offsetHeight;
1192 height = bottom - top;
1193 }
1194 if (top !== null && height !== null && parent !== null) {
1195 // cook up a div (if necessary) and position it
1196 let div = window.document.getElementById("code-annotation-line-highlight");
1197 if (div === null) {
1198 div = window.document.createElement("div");
1199 div.setAttribute("id", "code-annotation-line-highlight");
1200 div.style.position = 'absolute';
1201 parent.appendChild(div);
1202 }
1203 div.style.top = top - 2 + "px";
1204 div.style.height = height + 4 + "px";
1205 div.style.left = 0;
1206 let gutterDiv = window.document.getElementById("code-annotation-line-highlight-gutter");
1207 if (gutterDiv === null) {
1208 gutterDiv = window.document.createElement("div");
1209 gutterDiv.setAttribute("id", "code-annotation-line-highlight-gutter");
1210 gutterDiv.style.position = 'absolute';
1211 const codeCell = window.document.getElementById(targetCell);
1212 const gutter = codeCell.querySelector('.code-annotation-gutter');
1213 gutter.appendChild(gutterDiv);
1214 }
1215 gutterDiv.style.top = top - 2 + "px";
1216 gutterDiv.style.height = height + 4 + "px";
1217 }
1218 selectedAnnoteEl = annoteEl;
1219 }
1220 };
1221 const unselectCodeLines = () => {
1222 const elementsIds = ["code-annotation-line-highlight", "code-annotation-line-highlight-gutter"];
1223 elementsIds.forEach((elId) => {
1224 const div = window.document.getElementById(elId);
1225 if (div) {
1226 div.remove();
1227 }
1228 });
1229 selectedAnnoteEl = undefined;
1230 };
1231 // Handle positioning of the toggle
1232 window.addEventListener(
1233 "resize",
1234 throttle(() => {
1235 elRect = undefined;
1236 if (selectedAnnoteEl) {
1237 selectCodeLines(selectedAnnoteEl);
1238 }
1239 }, 10)
1240 );
1241 function throttle(fn, ms) {
1242 let throttle = false;
1243 let timer;
1244 return (...args) => {
1245 if(!throttle) { // first call gets through
1246 fn.apply(this, args);
1247 throttle = true;
1248 } else { // all the others get throttled
1249 if(timer) clearTimeout(timer); // cancel #2
1250 timer = setTimeout(() => {
1251 fn.apply(this, args);
1252 timer = throttle = false;
1253 }, ms);
1254 }
1255 };
1256 }
1257 // Attach click handler to the DT
1258 const annoteDls = window.document.querySelectorAll('dt[data-target-cell]');
1259 for (const annoteDlNode of annoteDls) {
1260 annoteDlNode.addEventListener('click', (event) => {
1261 const clickedEl = event.target;
1262 if (clickedEl !== selectedAnnoteEl) {
1263 unselectCodeLines();
1264 const activeEl = window.document.querySelector('dt[data-target-cell].code-annotation-active');
1265 if (activeEl) {
1266 activeEl.classList.remove('code-annotation-active');
1267 }
1268 selectCodeLines(clickedEl);
1269 clickedEl.classList.add('code-annotation-active');
1270 } else {
1271 // Unselect the line
1272 unselectCodeLines();
1273 clickedEl.classList.remove('code-annotation-active');
1274 }
1275 });
1276 }
1277 const findCites = (el) => {
1278 const parentEl = el.parentElement;
1279 if (parentEl) {
1280 const cites = parentEl.dataset.cites;
1281 if (cites) {
1282 return {
1283 el,
1284 cites: cites.split(' ')
1285 };
1286 } else {
1287 return findCites(el.parentElement)
1288 }
1289 } else {
1290 return undefined;
1291 }
1292 };
1293 var bibliorefs = window.document.querySelectorAll('a[role="doc-biblioref"]');
1294 for (var i=0; i<bibliorefs.length; i++) {
1295 const ref = bibliorefs[i];
1296 const citeInfo = findCites(ref);
1297 if (citeInfo) {
1298 tippyHover(citeInfo.el, function() {
1299 var popup = window.document.createElement('div');
1300 citeInfo.cites.forEach(function(cite) {
1301 var citeDiv = window.document.createElement('div');
1302 citeDiv.classList.add('hanging-indent');
1303 citeDiv.classList.add('csl-entry');
1304 var biblioDiv = window.document.getElementById('ref-' + cite);
1305 if (biblioDiv) {
1306 citeDiv.innerHTML = biblioDiv.innerHTML;
1307 }
1308 popup.appendChild(citeDiv);
1309 });
1310 return popup.innerHTML;
1311 });
1312 }
1313 }
1314 });
1315 </script>
1316</div> <!-- /content -->
1317<footer class="footer">
1318 <div class="nav-footer">
1319 <div class="nav-footer-left">
1320<p>Built with <a href="https://quarto.org/">Quarto</a></p>
1321</div>
1322 <div class="nav-footer-center">
1323
1324 <div class="toc-actions d-sm-block d-md-none"><ul><li><a href="https://github.com/your-org/atdata/edit/main/tutorials/local-workflow.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>
1325 <div class="nav-footer-right">
1326<p>MIT License</p>
1327</div>
1328 </div>
1329</footer>
1330
1331
1332
1333
1334</body></html>