Repository navigation
Conversation
|
I will automatically update this comment whenever this PR is modified
|
|
Not sure I like the TOC toggle. It kinda flashes on the screen and disappears, but that's not my real concern. Is there a way to toggle it back on? I don't see the button I expected from reading the source. My biggest concern is that some pages are very hard to use without a TOC. The API reference is a good example. We made authoring decisions based on the assumption that the TOC would be present. What do you think of making the page wider instead so the TOC and the notebook content both reasonably fit? The margin on the sides is kinda ridiculously huge and we could reclaim some of that space. |
|
The notebook is too long for a how-to. There is also a larger question about whether we even need tutorials as part of the My suggestion is we split out the few lines of code that show how to stream into the how-to section, and then the rest can go into explanation. The tutorial itself can sit on the NSIDC tutorials repo. |
|
Yes to the question of what to do with tutorials! See #1400. I also miss the TOC, as Matt mentioned. Agree with Andy that this is far too long, in current form, for a How-to. The terms you have in the glossary at the end would be great to add to a linkable glossary (see our Reference > Glossary section which currently is very slim and not linkable anywhere). I haven't ran all the code yet, but in reading through it, it does seem like a great candidate for our NSIDC cookbook (if edited to use a NSIDC product) or the tutorials repo, as Andy suggested, if you want to leave the product as is. Wherever it ends up living, it could potentially be linked to in our (maybe) tutorial "directory" in the |
|
I think I can edit the notebook location so it goes to tutorials here and move the glossary to a global glossary, then we can also link the auth section to the howto auth... I can revert the change of the TOC and reduce the margins. Working on that tomorrow! |
|
The Openscapes Earthdata Cloud Cookbook is another good candidate for housing this tutorial. There is so much informative and helpful content about the how and when to cloud. And the information is not specific to NSIDC, so in the context of the hub and spoke model, this makes sense for living in the "hub". |
There was a problem hiding this comment.
Pull request overview
This PR updates the documentation site to replace the “coming soon” cloud how-to with a new tutorial notebook explaining streaming vs downloading data with earthaccess, and adds a small MkDocs Material theme override to make the in-page TOC collapsible to better accommodate rendered notebooks.
Changes:
- Add a new how-to tutorial notebook: streaming data vs downloading (
docs/user/howto/streaming.ipynb) and wire it into the docs nav. - Add MkDocs theme overrides + CSS to provide a collapsible right-hand TOC (floating toggle button).
- Remove the placeholder “Direct S3 access…” page, and adjust repo ignores / link-check settings accordingly.
Reviewed changes
Copilot reviewed 7 out of 8 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
overrides/main.html |
Adds a JS snippet to hide/show the right-hand TOC via a floating toggle button. |
mkdocs.yml |
Enables the custom theme overrides directory. |
docs/user/howto/streaming.ipynb |
New tutorial notebook covering streaming vs downloading, with examples and appendices. |
docs/user/howto/cloud.md |
Removes the placeholder “coming soon” page content. |
docs/css/styles.css |
Styles the TOC toggle button and hides it on smaller viewports. |
docs/.nav.yml |
Updates the docs nav to point to the new streaming tutorial notebook. |
.gitignore |
Adds ignores for .cache and docs/user/howto/data/. |
.github/workflows/check-links.yml |
Minor formatting tweak + adds an allowlist regex for a new docs link. |
Suppressed comments (4)
docs/user/howto/streaming.ipynb:343
- Spelling/wording issues in this comparison table (e.g., "Time to sience" → "Time to science"). Since this is user-facing documentation, these typos should be corrected before publishing.
"* Disk: ~768MB \n",
"* Memory: ? \n",
"* Time to sience (out of region) (good internet): ~1m\n",
"* TTS in-region(): ~ < 1m\n",
"\n",
docs/user/howto/streaming.ipynb:321
- Grammar: "streaming lets we look" should be corrected (e.g., "streaming lets us look" / "streaming lets you look").
"> - **we're running in-region on AWS**, so egress is free/fast and streaming reads are cheap.\n",
"> - **we only need a subset** of each file — a few variables, a spatial subset, a handful of time steps — out of a much larger granule.\n",
"> - **we're doing exploratory analysis** and don't yet know which files/variables we'll actually need; streaming lets we look before committing to a download.\n",
"> - **we don't want to manage storage** — no local disk cleanup, no worrying about running out of space when scaling across hundreds or thousands of granules.\n",
docs/user/howto/streaming.ipynb:509
- Heading capitalization/typo: "## GLossary" should be "## Glossary".
"## GLossary\n",
"\n",
docs/user/howto/streaming.ipynb:392
- This explanation says
earthaccessconfigures fsspec caching at 4 MB by default. Inearthaccess/store.py, the defaultblock_sizeis selected based on file size (4/8/16 MB) andcache_typedefaults to"background"(seeearthaccess/store.py:111-155). The narrative should be updated so readers don’t assume block caching is always 4 MB.
"`fsspec` solves this with **block-based caching (`AbstractBufferedFile`)**: rather than fetching exactly the bytes requested, it fetches in fixed-size blocks — **`earthaccess` configures this at 4 MB by default** — and caches each block in memory. So:\n",
"\n",
"- A small read for, say, 200 bytes of header still triggers a fetch of a full 4 MB block containing those bytes.\n",
"- Any *subsequent* read that falls within that already-cached block is served from memory — **no network request at all**.\n",
"- Reads are effectively pre-fetched in bulk, which amortizes request/connection overhead (and any per-request latency, like S3's or EDL's auth roundtrip) over many logical reads.\n",
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
|
The notebook is ready for a second review
|
saberbrasher
left a comment
There was a problem hiding this comment.
I learned some things myself by going through this! Let me know if you have any questions about my comments, Luis. Also, take or leave what you do/ don't like!
Co-authored-by: Saber Brasher <134096880+saberbrasher@users.noreply.github.com>
There was a problem hiding this comment.
This tutorial and reference material will be such a great resource for data users. I like the amount of technical detail in the explanations - there is enough information to stand alone, and also enough information that if I wanted to do a deeper dive into anything, I have something to start my search on.
I like how the technical reference section is broken out separately. Could stay here, or could be moved to an "explanation" section.
The discussion and explanation around when to stream and when to download is so helpful. It really clarifies some concepts for me. Same with the discussion around why something is streamable vs. not-streamable. I can see this being used over and over in support of workshops and teaching.
| "source": [ | ||
| "## Requirements\n", | ||
| "\n", | ||
| "We need a recent version of `earthaccess` (the API changed a few times as the project matured — this notebook targets the current release, where `earthaccess.login()` is required *before* we can search, download, or open/stream anything).\n", |
There was a problem hiding this comment.
It might be good to give an actual version number here - e.g. v0.15.0 or later.
| "source": [ | ||
| "## 1. Downloading vs. Streaming — what's the actual difference?\n", | ||
| "\n", | ||
| "Both paths start the same way: we search the Common Metadata Repository (CMR) for granules, `earthaccess` resolves the data URLs (increasingly these are direct S3 URLs in the Earthdata Cloud, not just HTTPS), and it opens an authenticated connection. Concretely, that means either exchanging our EDL bearer token for short-lived, temporary AWS credentials via NASA's S3 credential endpoint (for direct `s3://` access from in-region compute), or attaching the bearer token as an `Authorization` header on HTTPS requests (for out-of-region / non-AWS access, redirected through EDL's OAuth flow). `earthaccess` picks whichever path applies automatically based on where our code is running and what the granule's links support.\n", |
There was a problem hiding this comment.
I might replace "paths" with "methods", but take or leave that advice.
| "| **Disk footprint** | One full copy of every granule we touch | None (until/unless we explicitly write something out) |\n", | ||
| "| **Best when...** | We need the raw file for other tools, we'll reuse it repeatedly, or we're outside AWS `us-west-2`, file format does not support streaming* | We're doing an analysis that only touches a slice of the data, we are using cloud compute, or we don't want to manage local storage at all |\n", | ||
| "\n", | ||
| "The key mental shift: **streaming doesn't mean \"no data movement.\"** It still moves bytes over the network — it just moves *only the bytes our analysis actually asks for*, and it does so lazily, mediated by `fsspec` under the hood (more on this in Section 6)." |
There was a problem hiding this comment.
really appreciate this explanation
| "id": "a57d3bee", | ||
| "metadata": {}, | ||
| "source": [ | ||
| "Each item in `results` is an `earthaccess.DataGranule` — it carries the metadata *and* the resolvable data links (both HTTPS and, where available, direct S3 URLs), without moving any of the actual science data yet. Searching CMR is metadata-only regardless of which path we take next.\n" |
There was a problem hiding this comment.
when you mention data links ("both HTTPS and, where available, direct S3 URLs"), do you mean that some data are still on premises and accessible via https, and other data are on AWS and have both https and s3 urls?
There was a problem hiding this comment.
No. When you are out-of-region, access to data in Earthdata Cloud is by HTTPS. When you are in-region, access is by S3.
| "id": "38446391", | ||
| "metadata": {}, | ||
| "source": [ | ||
| "Compare that to the download path: with `xr.open_mfdataset` over local files, the read is fast because the bytes are already on disk, but we paid the download cost earlier, for the *entire* file, whether or not we needed all of it. With streaming, the cost is paid incrementally, only where we touch the data. If all we needed was `T2M`, we never move the bytes for the other ~30 variables in the file at all.\n" |
There was a problem hiding this comment.
Really appreciate this comparison and the explanation.
| "id": "15b35b8b", | ||
| "metadata": {}, | ||
| "source": [ | ||
| "This block-caching behavior is *why* streaming can be competitive with — or faster than — downloading when we only need part of a file: we're not paying for a full sequential transfer, but we're also not paying a network round trip for every single small read either. The 4 MB block size is a sensible default for typical Earth science granule sizes and access patterns, but it's worth knowing it exists if we ever see unexpectedly heavy data transfer for what feels like a \"small\" read — e.g., touching one value from every chunk of a variable can still pull in a lot of 4 MB blocks.\n" |
There was a problem hiding this comment.
such a good explanation.
| "### T2. Streamable Data Formats\n", | ||
| "---\n", | ||
| "\n", | ||
| "Reading remote geospatial data efficiently comes down to one core difference: whether the format's underlying library demands an actual file on a hard drive, or if it can accept a flexible data stream. Formats like Zarr, HDF5, and NetCDF4 (using the h5netcdf engine) are flexible. They allow tools like fsspec to read just the exact bytes we need directly from cloud storage. Other formats achieve similar remote access through pure Python readers (NetCDF3), server-side queries (OPeNDAP), or GDAL's virtual file system (VSI) for Cloud Optimized GeoTIFFs.\n", |
There was a problem hiding this comment.
I might write "one core characteristic" or "one core feature", rather than "one core difference". but take or leave that advice.
| "\n", | ||
| "Reading remote geospatial data efficiently comes down to one core difference: whether the format's underlying library demands an actual file on a hard drive, or if it can accept a flexible data stream. Formats like Zarr, HDF5, and NetCDF4 (using the h5netcdf engine) are flexible. They allow tools like fsspec to read just the exact bytes we need directly from cloud storage. Other formats achieve similar remote access through pure Python readers (NetCDF3), server-side queries (OPeNDAP), or GDAL's virtual file system (VSI) for Cloud Optimized GeoTIFFs.\n", | ||
| "\n", | ||
| "On the flip side, older formats like HDF4, GRIB, and compressed Zip archives are rigid. Because they require a real, local file path to function, we are forced to download or cache the data before we can work with it. This technical divide is exactly why our ITS_LIVE pipeline succeeds with tools like VirtualiZarr and Kerchunk—they thrive on flexible, cloud-ready HDF5 data. If we were forced to incorporate rigid formats like HDF4, that entire remote-reading model would break down.\n", |
There was a problem hiding this comment.
Could you provide a link to ITS_LIVE, or ITS_LIVE documentation here? people could google it, but it might be nice to point them right to where they can learn about that project. It's mentioned a bit "out of the blue" here.
| "\n", | ||
| "| Format | Engine | How | Notes |\n", | ||
| "|---|---|---|---|\n", | ||
| "| **HDF5 / NetCDF4** | `h5netcdf` | `h5py.File(fileobj)` — h5py's core driver accepts any object with `read`/`seek`/`tell` | This is why fsspec/S3 remote reads work at all. Must use `engine=\"h5netcdf\"`, not `engine=\"netcdf4\"` (see below). |\n", |
There was a problem hiding this comment.
These are engines available in xarray.
| "| **Parquet / GeoParquet** | *(not xarray directly, but PyArrow)* | PyArrow accepts fsspec file objects natively, lazy row-group/column reads | Relevant even though xarray doesn't read Parquet itself. |\n", | ||
| "\n", | ||
| "#### Not Streamable\n", | ||
| "> **The C library demands a real path (GDAL VSI, or Virtualization as the only workarounds)**\n", |
There was a problem hiding this comment.
are these workarounds that allow streaming? could you clarify what you mean by workaround here?
|
I'm really struggling with seeing this as what get's presented in the webinar and what is preserved as a stand-alone tutorial. The current tutorial is designed more as a stand alone tutorial rather than something that could be presented in a webinar. At least how I would present it. My comments here relate to a stand-alone tutorial.
Suggested text for section 1. At least something like this.
|
|
Should we merge this as is and work on it later @andypbarrett ? |
|
Long comment incoming! In different meetings we started discussing how this content could be added to the Everything with "Tutorial 1" would be a part of the same tutorial/ live together on one page. Basically, not every TOC item needs a brand new page, but sections of this content could be kept together with a new focus. Everything with "Explanation 1" would be put together on one new page, etc. The "?" means I am not sure if the content makes sense for the
|
andypbarrett
left a comment
There was a problem hiding this comment.
This is great! I've made some suggested edits that I hope improve readbility. Feel free to ignore.
| "source": [ | ||
| "## 1. Requirements\n", | ||
| "\n", | ||
| "We need a recent version of `earthaccess` as the library changed a few times as the project matured, this notebook uses the current release (v0.18.0), where `earthaccess.login()` is required *before* we can search, download, or open/stream anything.\n", |
There was a problem hiding this comment.
Have text about needing to authenticate as separate sentence.
| "\n", | ||
| "We need a recent version of `earthaccess` as the library changed a few times as the project matured, this notebook uses the current release (v0.18.0), where `earthaccess.login()` is required *before* we can search, download, or open/stream anything.\n", | ||
| "\n", | ||
| "We'll also need an Earthdata Login (EDL) account. If you don't have one yet, create one for free at https://urs.earthdata.nasa.gov/users/new.\n" |
There was a problem hiding this comment.
This is required to authenticate so suggest:
We need to run
earthaccess.login()before we can download or open/stream any data, so we do this first. We will need an Earthdata Login (EDL) account to do this.
| "source": [ | ||
| "## 2. Downloading vs. Streaming — what's the actual difference?\n", | ||
| "\n", | ||
| "Both paths start the same way: we search the Common Metadata Repository (CMR) for granules, `earthaccess` resolves the data URLs (increasingly these are direct S3 URLs in the Earthdata Cloud, not just HTTPS), and it opens an authenticated connection. Concretely, that means either exchanging our EDL bearer token for short-lived, temporary AWS credentials via NASA's S3 credential endpoint (for direct `s3://` access from in-region compute), or attaching the bearer token as an `Authorization` header on HTTPS requests (for out-of-region / non-AWS access, redirected through EDL's OAuth flow). `earthaccess` picks whichever path applies automatically based on where our code is running and what the granule's links support.\n", |
There was a problem hiding this comment.
| "Both paths start the same way: we search the Common Metadata Repository (CMR) for granules, `earthaccess` resolves the data URLs (increasingly these are direct S3 URLs in the Earthdata Cloud, not just HTTPS), and it opens an authenticated connection. Concretely, that means either exchanging our EDL bearer token for short-lived, temporary AWS credentials via NASA's S3 credential endpoint (for direct `s3://` access from in-region compute), or attaching the bearer token as an `Authorization` header on HTTPS requests (for out-of-region / non-AWS access, redirected through EDL's OAuth flow). `earthaccess` picks whichever path applies automatically based on where our code is running and what the granule's links support.\n", | |
| "Whether we choose to download or stream data, we start the same way: we search the Common Metadata Repository (CMR) for granules, then `earthaccess` resolves the data URLs and opens an authenticated connection. Authentication and the data URLs resolved depend on whether we are using _in-region_ compute and utilizing direct `s3://` access, or if we are out-of-region using our local machine, HPC or non-AWS compute resources.\n | |
| If we are _in-region_, data URLs resolve to direct `s3://` links in the Earthdata Cloud and authentication is by short-lived, temporary AWS credentials via NASA's S3 credential endpoint. If we are _out-of-region_, URL's resolve to HTTPS links and our EDL bearer-token is attached as an `Authorization` header to our HTTPS request.\n | |
| `earthaccess` automatically picks the authentication method and URL based on where we run our code and what granule links support.\n" |
| "\n", | ||
| "Both paths start the same way: we search the Common Metadata Repository (CMR) for granules, `earthaccess` resolves the data URLs (increasingly these are direct S3 URLs in the Earthdata Cloud, not just HTTPS), and it opens an authenticated connection. Concretely, that means either exchanging our EDL bearer token for short-lived, temporary AWS credentials via NASA's S3 credential endpoint (for direct `s3://` access from in-region compute), or attaching the bearer token as an `Authorization` header on HTTPS requests (for out-of-region / non-AWS access, redirected through EDL's OAuth flow). `earthaccess` picks whichever path applies automatically based on where our code is running and what the granule's links support.\n", | ||
| "\n", | ||
| "The difference is what happens *after* that connection is open:\n", |
There was a problem hiding this comment.
| "The difference is what happens *after* that connection is open:\n", | |
| "The difference between the two access methods is what happens *after* that connection is open:\n", |
| "\n", | ||
| "An important feature is that earthaccess chooses block_size based on file size (4/8/16 MB) via `_optimal_fsspec_block_size()` and passes it to `fsspec.open()` this way block size is adaptive but can be overriden via `open_kwargs`. See the way this works with the NISAR mission: **<a href=\"https://nisar-docs.asf.alaska.edu/earthaccess/\">Using NISAR data with earthaccess</a>.**\n", | ||
| "\n", | ||
| "- A small read for, say, 200 bytes of header still triggers a fetch of a full 4 MB block containing those bytes.\n", |
There was a problem hiding this comment.
See comment about default block size above with regards to this and following paragraph.
| "- Any *subsequent* read that falls within that already-cached block is served from memory — **no network request at all**.\n", | ||
| "- Reads are effectively pre-fetched in bulk, which amortizes request/connection overhead (and any per-request latency, like S3's or EDL's auth roundtrip) over many logical reads.\n", | ||
| "\n", | ||
| "This is exactly the same idea as page caching in an OS, or read-ahead buffering on a local disk — just implemented over HTTP range requests instead of a block device. The 4 MB size is a deliberate tradeoff: large enough to make each network request worthwhile and amortize latency, small enough not to waste bandwidth pulling data we'll never touch when we only need a small slice of a big file." |
There was a problem hiding this comment.
Should we add some wikipedia links for page caching and read-ahead buffering?
| "tags": [] | ||
| }, | ||
| "source": [ | ||
| "This block-caching behavior is *why* streaming can be competitive with — or faster than — downloading when we only need part of a file: we're not paying for a full sequential transfer, but we're also not paying a network round trip for every single small read either. The 4 MB block size is a sensible default for typical Earth science granule sizes and access patterns, but it's worth knowing it exists if we ever see unexpectedly heavy data transfer for what feels like a \"small\" read — e.g., touching one value from every chunk of a variable can still pull in a lot of 4 MB blocks.\n" |
There was a problem hiding this comment.
If we do see heavy data transfer, should a user increase block size? Is it worth adding some heuristics here for users?
| "\n", | ||
| "| Format | Engine | How | Notes |\n", | ||
| "|---|---|---|---|\n", | ||
| "| **HDF5 / NetCDF4** | `h5netcdf` | `h5py.File(fileobj)` — h5py's core driver accepts any object with `read`/`seek`/`tell` | This is why fsspec/S3 remote reads work at all. Must use `engine=\"h5netcdf\"`, not `engine=\"netcdf4\"` (see below). |\n", |
There was a problem hiding this comment.
These are engines available in xarray.
| "| **Kerchunk references** | `zarr` (via `fsspec.filesystem(\"reference\")`) | Wraps byte-range references into a virtual Zarr store | Works *for HDF5-based sources*. Kerchunk has no real HDF4 backend, so this doesn't rescue HDF4. |\n", | ||
| "| **NetCDF3 classic / 64-bit offset** | `scipy` | `scipy.io.netcdf_file` is a pure-Python parser, reads from any file-like object | Older/simpler format; no compression, so this is genuinely lazy-capable. |\n", | ||
| "| **OPeNDAP** | `pydap` or `netcdf4` (via DAP URL) | Not \"file-like\" in the fsspec sense — it's a query protocol, server does the subsetting | Effectively remote-native; different mechanism than byte-range reads. |\n", | ||
| "| **COG / GeoTIFF** | `rasterio`/`rioxarray` | GDAL's own VSI virtual filesystem (`/vsicurl/`, `/vsis3/`, `/vsiaz/`) | Not a Python file-like object, but functionally equivalent — GDAL issues range requests itself. Works well because COGs are internally tiled/overviewed for exactly this. |\n", |
There was a problem hiding this comment.
The COG/GeoTIFF engine in xarray is rasterio (engine="rastereio"). rioxarray is the package that makes this engine available. I suggest deleting rioxarray.
Description
This PR adds a tutorial on what streaming data is, attempting to explain when to use it vs when to download files. It's missing some of the final profiling numbers to have a better idea on memory usage but I think is in good shape to be published. I ran into 2 interesting things when working on it, readthedocs switched environment variables to public (guessing here) and that's the reason we got our CI account "hacked", I deleted the env variables and we are now using a token, is public but has no security implications. Second thing, memray detected a bigger memory peak when we are streaming vs when we download files, an overhead of 100% which is significant. We need to investigate that, apparently coming from AIOHttp allocations, so that and the hypy driver can be doing something funny.
As part of the PR work I did an override on the mkdocs theme to make the page TOC collapsible so we have more space for the rendered notebook. Looks better IMO.
This PR closes #1390
"Ready for review" checklist
Merge checklist
closes #1)CHANGELOG.mdupdatedREADME.mdupdatedpre-commit.ci autofixif pre-commit is failing)📚 Documentation preview 📚: https://earthaccess--1427.org.readthedocs.build/en/1427/