Fix ch5 build hang: add network timeouts and reduce memory#51
Merged
Conversation
- Add connect/read timeouts to s3fs.S3FileSystem to prevent indefinite hang on slow S3 responses (root cause of 6-hour nightly build hang) - Add timeout=60 to urllib.request.urlopen(), following the same pattern already used in ch3 - Remove the 2-hour freshness check that left `data` undefined if the most recent file was stale, causing a downstream NameError - Decimate loaded data (data[::4, ::4]) for ~17x memory reduction (~5 GB -> ~300 MB), keeping hvplot interactive and fast - Add clear RuntimeError guard before plotting cell instead of cryptic NameError if data fetch fails Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Contributor
|
👋 Thanks for opening this PR! The Cookbook will be automatically built with GitHub Actions. To see the status of your deployment, click below. |
The previous error handling printed errors and continued, leaving `data` undefined and causing a confusing RuntimeError downstream. Now exceptions propagate from their source with clear messages. Also removes the redundant data-existence guard. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
connect_timeout and read_timeout must be passed via config_kwargs (botocore.config.Config) not client_kwargs, which are passed directly to aiobotocore's create_client() and don't support those args. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Collaborator
Author
|
Note for reviewers: If AWS S3 is temporarily slow at the time of a nightly build, the 60-second timeout on the download will cause the build to fail with a |
The check was removed accidentally — it exists to ensure the notebook displays genuinely real-time data. Restored it with a clear RuntimeError instead of the original silent skip that left `data` undefined. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The nightly build was hanging for 6+ hours (until GitHub cancelled it) due to missing network timeouts in Chapter 5, not memory.
urllib.request.urlopen()had no timeout — if AWS S3 was slow, the build would wait forever.s3fs.S3FileSystemalso had no timeout configured. Ch3 already usestimeout=5on itsurlopen()call; this PR brings ch5 in line.elsebranch, leavingdataundefined if the file was stale →NameErrorin the plotting cell.data[::4, ::4]decimation after loading (~17x reduction, ~5 GB → ~300 MB) to keep hvplot fast. The interactive plot is preserved.Changes to
ch5_realtimeData.ipynbclient_kwargs={'connect_timeout': 30, 'read_timeout': 60}tos3fs.S3FileSystemtimeout=60tourllib.request.urlopen()data = data[::4, ::4]RuntimeErrorguard before the plotting cellTest plan
🤖 Generated with Claude Code