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
10<title>local.s3datastore – 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 & 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.local.S3DataStore" id="toc-atdata.local.S3DataStore" class="nav-link active" data-scroll-target="#atdata.local.S3DataStore">local.S3DataStore</a>
404 <ul class="collapse">
405 <li><a href="#attributes" id="toc-attributes" class="nav-link" data-scroll-target="#attributes">Attributes</a></li>
406 <li><a href="#methods" id="toc-methods" class="nav-link" data-scroll-target="#methods">Methods</a>
407 <ul class="collapse">
408 <li><a href="#atdata.local.S3DataStore.read_url" id="toc-atdata.local.S3DataStore.read_url" class="nav-link" data-scroll-target="#atdata.local.S3DataStore.read_url">read_url</a></li>
409 <li><a href="#atdata.local.S3DataStore.supports_streaming" id="toc-atdata.local.S3DataStore.supports_streaming" class="nav-link" data-scroll-target="#atdata.local.S3DataStore.supports_streaming">supports_streaming</a></li>
410 <li><a href="#atdata.local.S3DataStore.write_shards" id="toc-atdata.local.S3DataStore.write_shards" class="nav-link" data-scroll-target="#atdata.local.S3DataStore.write_shards">write_shards</a></li>
411 </ul></li>
412 </ul></li>
413 </ul>
414<div class="toc-actions"><ul><li><a href="https://github.com/your-org/atdata/edit/main/api/local.S3DataStore.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>
415 </div>
416<!-- main -->
417<main class="content" id="quarto-document-content"><header id="title-block-header" class="quarto-title-block"></header>
418
419
420
421
422
423<section id="atdata.local.S3DataStore" class="level1">
424<h1>local.S3DataStore</h1>
425<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>local.S3DataStore(credentials, <span class="op">*</span>, bucket)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
426<p>S3-compatible data store implementing AbstractDataStore protocol.</p>
427<p>Handles writing dataset shards to S3-compatible object storage and resolving URLs for reading.</p>
428<section id="attributes" class="level2 doc-section doc-section-attributes">
429<h2 class="doc-section doc-section-attributes anchored" data-anchor-id="attributes">Attributes</h2>
430<table class="caption-top table">
431<thead>
432<tr class="header">
433<th>Name</th>
434<th>Type</th>
435<th>Description</th>
436</tr>
437</thead>
438<tbody>
439<tr class="odd">
440<td>credentials</td>
441<td></td>
442<td>S3 credentials dictionary.</td>
443</tr>
444<tr class="even">
445<td>bucket</td>
446<td></td>
447<td>Target bucket name.</td>
448</tr>
449<tr class="odd">
450<td>_fs</td>
451<td></td>
452<td>S3FileSystem instance.</td>
453</tr>
454</tbody>
455</table>
456</section>
457<section id="methods" class="level2">
458<h2 class="anchored" data-anchor-id="methods">Methods</h2>
459<table class="caption-top table">
460<thead>
461<tr class="header">
462<th>Name</th>
463<th>Description</th>
464</tr>
465</thead>
466<tbody>
467<tr class="odd">
468<td><a href="#atdata.local.S3DataStore.read_url">read_url</a></td>
469<td>Resolve an S3 URL for reading/streaming.</td>
470</tr>
471<tr class="even">
472<td><a href="#atdata.local.S3DataStore.supports_streaming">supports_streaming</a></td>
473<td>S3 supports streaming reads.</td>
474</tr>
475<tr class="odd">
476<td><a href="#atdata.local.S3DataStore.write_shards">write_shards</a></td>
477<td>Write dataset shards to S3.</td>
478</tr>
479</tbody>
480</table>
481<section id="atdata.local.S3DataStore.read_url" class="level3">
482<h3 class="anchored" data-anchor-id="atdata.local.S3DataStore.read_url">read_url</h3>
483<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>local.S3DataStore.read_url(url)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
484<p>Resolve an S3 URL for reading/streaming.</p>
485<p>For S3-compatible stores with custom endpoints (like Cloudflare R2, MinIO, etc.), converts s3:// URLs to HTTPS URLs that WebDataset can stream directly.</p>
486<p>For standard AWS S3 (no custom endpoint), URLs are returned unchanged since WebDataset’s built-in s3fs integration handles them.</p>
487<section id="parameters" class="level4 doc-section doc-section-parameters">
488<h4 class="doc-section doc-section-parameters anchored" data-anchor-id="parameters">Parameters</h4>
489<table class="caption-top table">
490<thead>
491<tr class="header">
492<th>Name</th>
493<th>Type</th>
494<th>Description</th>
495<th>Default</th>
496</tr>
497</thead>
498<tbody>
499<tr class="odd">
500<td>url</td>
501<td><a href="`str`">str</a></td>
502<td>S3 URL to resolve (e.g., ‘s3://bucket/path/file.tar’).</td>
503<td><em>required</em></td>
504</tr>
505</tbody>
506</table>
507</section>
508<section id="returns" class="level4 doc-section doc-section-returns">
509<h4 class="doc-section doc-section-returns anchored" data-anchor-id="returns">Returns</h4>
510<table class="caption-top table">
511<thead>
512<tr class="header">
513<th>Name</th>
514<th>Type</th>
515<th>Description</th>
516</tr>
517</thead>
518<tbody>
519<tr class="odd">
520<td></td>
521<td><a href="`str`">str</a></td>
522<td>HTTPS URL if custom endpoint is configured, otherwise unchanged.</td>
523</tr>
524<tr class="even">
525<td>Example</td>
526<td><a href="`str`">str</a></td>
527<td>‘s3://bucket/path’ -> ‘https://endpoint.com/bucket/path’</td>
528</tr>
529</tbody>
530</table>
531</section>
532</section>
533<section id="atdata.local.S3DataStore.supports_streaming" class="level3">
534<h3 class="anchored" data-anchor-id="atdata.local.S3DataStore.supports_streaming">supports_streaming</h3>
535<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>local.S3DataStore.supports_streaming()</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
536<p>S3 supports streaming reads.</p>
537<section id="returns-1" class="level4 doc-section doc-section-returns">
538<h4 class="doc-section doc-section-returns anchored" data-anchor-id="returns-1">Returns</h4>
539<table class="caption-top table">
540<thead>
541<tr class="header">
542<th>Name</th>
543<th>Type</th>
544<th>Description</th>
545</tr>
546</thead>
547<tbody>
548<tr class="odd">
549<td></td>
550<td><a href="`bool`">bool</a></td>
551<td>True.</td>
552</tr>
553</tbody>
554</table>
555</section>
556</section>
557<section id="atdata.local.S3DataStore.write_shards" class="level3">
558<h3 class="anchored" data-anchor-id="atdata.local.S3DataStore.write_shards">write_shards</h3>
559<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>local.S3DataStore.write_shards(ds, <span class="op">*</span>, prefix, cache_local<span class="op">=</span><span class="va">False</span>, <span class="op">**</span>kwargs)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
560<p>Write dataset shards to S3.</p>
561<section id="parameters-1" class="level4 doc-section doc-section-parameters">
562<h4 class="doc-section doc-section-parameters anchored" data-anchor-id="parameters-1">Parameters</h4>
563<table class="caption-top table">
564<thead>
565<tr class="header">
566<th>Name</th>
567<th>Type</th>
568<th>Description</th>
569<th>Default</th>
570</tr>
571</thead>
572<tbody>
573<tr class="odd">
574<td>ds</td>
575<td><a href="`atdata.Dataset`">Dataset</a></td>
576<td>The Dataset to write.</td>
577<td><em>required</em></td>
578</tr>
579<tr class="even">
580<td>prefix</td>
581<td><a href="`str`">str</a></td>
582<td>Path prefix within bucket (e.g., ‘datasets/mnist/v1’).</td>
583<td><em>required</em></td>
584</tr>
585<tr class="odd">
586<td>cache_local</td>
587<td><a href="`bool`">bool</a></td>
588<td>If True, write locally first then copy to S3.</td>
589<td><code>False</code></td>
590</tr>
591<tr class="even">
592<td>**kwargs</td>
593<td></td>
594<td>Additional args passed to wds.ShardWriter (e.g., maxcount).</td>
595<td><code>{}</code></td>
596</tr>
597</tbody>
598</table>
599</section>
600<section id="returns-2" class="level4 doc-section doc-section-returns">
601<h4 class="doc-section doc-section-returns anchored" data-anchor-id="returns-2">Returns</h4>
602<table class="caption-top table">
603<thead>
604<tr class="header">
605<th>Name</th>
606<th>Type</th>
607<th>Description</th>
608</tr>
609</thead>
610<tbody>
611<tr class="odd">
612<td></td>
613<td><a href="`list`">list</a>[<a href="`str`">str</a>]</td>
614<td>List of S3 URLs for the written shards.</td>
615</tr>
616</tbody>
617</table>
618</section>
619<section id="raises" class="level4 doc-section doc-section-raises">
620<h4 class="doc-section doc-section-raises anchored" data-anchor-id="raises">Raises</h4>
621<table class="caption-top table">
622<thead>
623<tr class="header">
624<th>Name</th>
625<th>Type</th>
626<th>Description</th>
627</tr>
628</thead>
629<tbody>
630<tr class="odd">
631<td></td>
632<td><a href="`RuntimeError`">RuntimeError</a></td>
633<td>If no shards were written.</td>
634</tr>
635</tbody>
636</table>
637
638
639</section>
640</section>
641</section>
642</section>
643
644</main> <!-- /main -->
645<script id="quarto-html-after-body" type="application/javascript">
646 window.document.addEventListener("DOMContentLoaded", function (event) {
647 // Ensure there is a toggle, if there isn't float one in the top right
648 if (window.document.querySelector('.quarto-color-scheme-toggle') === null) {
649 const a = window.document.createElement('a');
650 a.classList.add('top-right');
651 a.classList.add('quarto-color-scheme-toggle');
652 a.href = "";
653 a.onclick = function() { try { window.quartoToggleColorScheme(); } catch {} return false; };
654 const i = window.document.createElement("i");
655 i.classList.add('bi');
656 a.appendChild(i);
657 window.document.body.appendChild(a);
658 }
659 setColorSchemeToggle(hasAlternateSentinel())
660 const icon = "";
661 const anchorJS = new window.AnchorJS();
662 anchorJS.options = {
663 placement: 'right',
664 icon: icon
665 };
666 anchorJS.add('.anchored');
667 const isCodeAnnotation = (el) => {
668 for (const clz of el.classList) {
669 if (clz.startsWith('code-annotation-')) {
670 return true;
671 }
672 }
673 return false;
674 }
675 const onCopySuccess = function(e) {
676 // button target
677 const button = e.trigger;
678 // don't keep focus
679 button.blur();
680 // flash "checked"
681 button.classList.add('code-copy-button-checked');
682 var currentTitle = button.getAttribute("title");
683 button.setAttribute("title", "Copied!");
684 let tooltip;
685 if (window.bootstrap) {
686 button.setAttribute("data-bs-toggle", "tooltip");
687 button.setAttribute("data-bs-placement", "left");
688 button.setAttribute("data-bs-title", "Copied!");
689 tooltip = new bootstrap.Tooltip(button,
690 { trigger: "manual",
691 customClass: "code-copy-button-tooltip",
692 offset: [0, -8]});
693 tooltip.show();
694 }
695 setTimeout(function() {
696 if (tooltip) {
697 tooltip.hide();
698 button.removeAttribute("data-bs-title");
699 button.removeAttribute("data-bs-toggle");
700 button.removeAttribute("data-bs-placement");
701 }
702 button.setAttribute("title", currentTitle);
703 button.classList.remove('code-copy-button-checked');
704 }, 1000);
705 // clear code selection
706 e.clearSelection();
707 }
708 const getTextToCopy = function(trigger) {
709 const codeEl = trigger.previousElementSibling.cloneNode(true);
710 for (const childEl of codeEl.children) {
711 if (isCodeAnnotation(childEl)) {
712 childEl.remove();
713 }
714 }
715 return codeEl.innerText;
716 }
717 const clipboard = new window.ClipboardJS('.code-copy-button:not([data-in-quarto-modal])', {
718 text: getTextToCopy
719 });
720 clipboard.on('success', onCopySuccess);
721 if (window.document.getElementById('quarto-embedded-source-code-modal')) {
722 const clipboardModal = new window.ClipboardJS('.code-copy-button[data-in-quarto-modal]', {
723 text: getTextToCopy,
724 container: window.document.getElementById('quarto-embedded-source-code-modal')
725 });
726 clipboardModal.on('success', onCopySuccess);
727 }
728 var localhostRegex = new RegExp(/^(?:http|https):\/\/localhost\:?[0-9]*\//);
729 var mailtoRegex = new RegExp(/^mailto:/);
730 var filterRegex = new RegExp("https:\/\/github\.com\/your-org\/atdata");
731 var isInternal = (href) => {
732 return filterRegex.test(href) || localhostRegex.test(href) || mailtoRegex.test(href);
733 }
734 // Inspect non-navigation links and adorn them if external
735 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)');
736 for (var i=0; i<links.length; i++) {
737 const link = links[i];
738 if (!isInternal(link.href)) {
739 // undo the damage that might have been done by quarto-nav.js in the case of
740 // links that we want to consider external
741 if (link.dataset.originalHref !== undefined) {
742 link.href = link.dataset.originalHref;
743 }
744 }
745 }
746 function tippyHover(el, contentFn, onTriggerFn, onUntriggerFn) {
747 const config = {
748 allowHTML: true,
749 maxWidth: 500,
750 delay: 100,
751 arrow: false,
752 appendTo: function(el) {
753 return el.parentElement;
754 },
755 interactive: true,
756 interactiveBorder: 10,
757 theme: 'quarto',
758 placement: 'bottom-start',
759 };
760 if (contentFn) {
761 config.content = contentFn;
762 }
763 if (onTriggerFn) {
764 config.onTrigger = onTriggerFn;
765 }
766 if (onUntriggerFn) {
767 config.onUntrigger = onUntriggerFn;
768 }
769 window.tippy(el, config);
770 }
771 const noterefs = window.document.querySelectorAll('a[role="doc-noteref"]');
772 for (var i=0; i<noterefs.length; i++) {
773 const ref = noterefs[i];
774 tippyHover(ref, function() {
775 // use id or data attribute instead here
776 let href = ref.getAttribute('data-footnote-href') || ref.getAttribute('href');
777 try { href = new URL(href).hash; } catch {}
778 const id = href.replace(/^#\/?/, "");
779 const note = window.document.getElementById(id);
780 if (note) {
781 return note.innerHTML;
782 } else {
783 return "";
784 }
785 });
786 }
787 const xrefs = window.document.querySelectorAll('a.quarto-xref');
788 const processXRef = (id, note) => {
789 // Strip column container classes
790 const stripColumnClz = (el) => {
791 el.classList.remove("page-full", "page-columns");
792 if (el.children) {
793 for (const child of el.children) {
794 stripColumnClz(child);
795 }
796 }
797 }
798 stripColumnClz(note)
799 if (id === null || id.startsWith('sec-')) {
800 // Special case sections, only their first couple elements
801 const container = document.createElement("div");
802 if (note.children && note.children.length > 2) {
803 container.appendChild(note.children[0].cloneNode(true));
804 for (let i = 1; i < note.children.length; i++) {
805 const child = note.children[i];
806 if (child.tagName === "P" && child.innerText === "") {
807 continue;
808 } else {
809 container.appendChild(child.cloneNode(true));
810 break;
811 }
812 }
813 if (window.Quarto?.typesetMath) {
814 window.Quarto.typesetMath(container);
815 }
816 return container.innerHTML
817 } else {
818 if (window.Quarto?.typesetMath) {
819 window.Quarto.typesetMath(note);
820 }
821 return note.innerHTML;
822 }
823 } else {
824 // Remove any anchor links if they are present
825 const anchorLink = note.querySelector('a.anchorjs-link');
826 if (anchorLink) {
827 anchorLink.remove();
828 }
829 if (window.Quarto?.typesetMath) {
830 window.Quarto.typesetMath(note);
831 }
832 if (note.classList.contains("callout")) {
833 return note.outerHTML;
834 } else {
835 return note.innerHTML;
836 }
837 }
838 }
839 for (var i=0; i<xrefs.length; i++) {
840 const xref = xrefs[i];
841 tippyHover(xref, undefined, function(instance) {
842 instance.disable();
843 let url = xref.getAttribute('href');
844 let hash = undefined;
845 if (url.startsWith('#')) {
846 hash = url;
847 } else {
848 try { hash = new URL(url).hash; } catch {}
849 }
850 if (hash) {
851 const id = hash.replace(/^#\/?/, "");
852 const note = window.document.getElementById(id);
853 if (note !== null) {
854 try {
855 const html = processXRef(id, note.cloneNode(true));
856 instance.setContent(html);
857 } finally {
858 instance.enable();
859 instance.show();
860 }
861 } else {
862 // See if we can fetch this
863 fetch(url.split('#')[0])
864 .then(res => res.text())
865 .then(html => {
866 const parser = new DOMParser();
867 const htmlDoc = parser.parseFromString(html, "text/html");
868 const note = htmlDoc.getElementById(id);
869 if (note !== null) {
870 const html = processXRef(id, note);
871 instance.setContent(html);
872 }
873 }).finally(() => {
874 instance.enable();
875 instance.show();
876 });
877 }
878 } else {
879 // See if we can fetch a full url (with no hash to target)
880 // This is a special case and we should probably do some content thinning / targeting
881 fetch(url)
882 .then(res => res.text())
883 .then(html => {
884 const parser = new DOMParser();
885 const htmlDoc = parser.parseFromString(html, "text/html");
886 const note = htmlDoc.querySelector('main.content');
887 if (note !== null) {
888 // This should only happen for chapter cross references
889 // (since there is no id in the URL)
890 // remove the first header
891 if (note.children.length > 0 && note.children[0].tagName === "HEADER") {
892 note.children[0].remove();
893 }
894 const html = processXRef(null, note);
895 instance.setContent(html);
896 }
897 }).finally(() => {
898 instance.enable();
899 instance.show();
900 });
901 }
902 }, function(instance) {
903 });
904 }
905 let selectedAnnoteEl;
906 const selectorForAnnotation = ( cell, annotation) => {
907 let cellAttr = 'data-code-cell="' + cell + '"';
908 let lineAttr = 'data-code-annotation="' + annotation + '"';
909 const selector = 'span[' + cellAttr + '][' + lineAttr + ']';
910 return selector;
911 }
912 const selectCodeLines = (annoteEl) => {
913 const doc = window.document;
914 const targetCell = annoteEl.getAttribute("data-target-cell");
915 const targetAnnotation = annoteEl.getAttribute("data-target-annotation");
916 const annoteSpan = window.document.querySelector(selectorForAnnotation(targetCell, targetAnnotation));
917 const lines = annoteSpan.getAttribute("data-code-lines").split(",");
918 const lineIds = lines.map((line) => {
919 return targetCell + "-" + line;
920 })
921 let top = null;
922 let height = null;
923 let parent = null;
924 if (lineIds.length > 0) {
925 //compute the position of the single el (top and bottom and make a div)
926 const el = window.document.getElementById(lineIds[0]);
927 top = el.offsetTop;
928 height = el.offsetHeight;
929 parent = el.parentElement.parentElement;
930 if (lineIds.length > 1) {
931 const lastEl = window.document.getElementById(lineIds[lineIds.length - 1]);
932 const bottom = lastEl.offsetTop + lastEl.offsetHeight;
933 height = bottom - top;
934 }
935 if (top !== null && height !== null && parent !== null) {
936 // cook up a div (if necessary) and position it
937 let div = window.document.getElementById("code-annotation-line-highlight");
938 if (div === null) {
939 div = window.document.createElement("div");
940 div.setAttribute("id", "code-annotation-line-highlight");
941 div.style.position = 'absolute';
942 parent.appendChild(div);
943 }
944 div.style.top = top - 2 + "px";
945 div.style.height = height + 4 + "px";
946 div.style.left = 0;
947 let gutterDiv = window.document.getElementById("code-annotation-line-highlight-gutter");
948 if (gutterDiv === null) {
949 gutterDiv = window.document.createElement("div");
950 gutterDiv.setAttribute("id", "code-annotation-line-highlight-gutter");
951 gutterDiv.style.position = 'absolute';
952 const codeCell = window.document.getElementById(targetCell);
953 const gutter = codeCell.querySelector('.code-annotation-gutter');
954 gutter.appendChild(gutterDiv);
955 }
956 gutterDiv.style.top = top - 2 + "px";
957 gutterDiv.style.height = height + 4 + "px";
958 }
959 selectedAnnoteEl = annoteEl;
960 }
961 };
962 const unselectCodeLines = () => {
963 const elementsIds = ["code-annotation-line-highlight", "code-annotation-line-highlight-gutter"];
964 elementsIds.forEach((elId) => {
965 const div = window.document.getElementById(elId);
966 if (div) {
967 div.remove();
968 }
969 });
970 selectedAnnoteEl = undefined;
971 };
972 // Handle positioning of the toggle
973 window.addEventListener(
974 "resize",
975 throttle(() => {
976 elRect = undefined;
977 if (selectedAnnoteEl) {
978 selectCodeLines(selectedAnnoteEl);
979 }
980 }, 10)
981 );
982 function throttle(fn, ms) {
983 let throttle = false;
984 let timer;
985 return (...args) => {
986 if(!throttle) { // first call gets through
987 fn.apply(this, args);
988 throttle = true;
989 } else { // all the others get throttled
990 if(timer) clearTimeout(timer); // cancel #2
991 timer = setTimeout(() => {
992 fn.apply(this, args);
993 timer = throttle = false;
994 }, ms);
995 }
996 };
997 }
998 // Attach click handler to the DT
999 const annoteDls = window.document.querySelectorAll('dt[data-target-cell]');
1000 for (const annoteDlNode of annoteDls) {
1001 annoteDlNode.addEventListener('click', (event) => {
1002 const clickedEl = event.target;
1003 if (clickedEl !== selectedAnnoteEl) {
1004 unselectCodeLines();
1005 const activeEl = window.document.querySelector('dt[data-target-cell].code-annotation-active');
1006 if (activeEl) {
1007 activeEl.classList.remove('code-annotation-active');
1008 }
1009 selectCodeLines(clickedEl);
1010 clickedEl.classList.add('code-annotation-active');
1011 } else {
1012 // Unselect the line
1013 unselectCodeLines();
1014 clickedEl.classList.remove('code-annotation-active');
1015 }
1016 });
1017 }
1018 const findCites = (el) => {
1019 const parentEl = el.parentElement;
1020 if (parentEl) {
1021 const cites = parentEl.dataset.cites;
1022 if (cites) {
1023 return {
1024 el,
1025 cites: cites.split(' ')
1026 };
1027 } else {
1028 return findCites(el.parentElement)
1029 }
1030 } else {
1031 return undefined;
1032 }
1033 };
1034 var bibliorefs = window.document.querySelectorAll('a[role="doc-biblioref"]');
1035 for (var i=0; i<bibliorefs.length; i++) {
1036 const ref = bibliorefs[i];
1037 const citeInfo = findCites(ref);
1038 if (citeInfo) {
1039 tippyHover(citeInfo.el, function() {
1040 var popup = window.document.createElement('div');
1041 citeInfo.cites.forEach(function(cite) {
1042 var citeDiv = window.document.createElement('div');
1043 citeDiv.classList.add('hanging-indent');
1044 citeDiv.classList.add('csl-entry');
1045 var biblioDiv = window.document.getElementById('ref-' + cite);
1046 if (biblioDiv) {
1047 citeDiv.innerHTML = biblioDiv.innerHTML;
1048 }
1049 popup.appendChild(citeDiv);
1050 });
1051 return popup.innerHTML;
1052 });
1053 }
1054 }
1055 });
1056 </script>
1057</div> <!-- /content -->
1058<footer class="footer">
1059 <div class="nav-footer">
1060 <div class="nav-footer-left">
1061<p>Built with <a href="https://quarto.org/">Quarto</a></p>
1062</div>
1063 <div class="nav-footer-center">
1064
1065 <div class="toc-actions d-sm-block d-md-none"><ul><li><a href="https://github.com/your-org/atdata/edit/main/api/local.S3DataStore.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>
1066 <div class="nav-footer-right">
1067<p>MIT License</p>
1068</div>
1069 </div>
1070</footer>
1071
1072
1073
1074
1075</body></html>