Conversation
sc0tts
reviewed
Sep 10, 2025
noaa_metrics/aggregate_logs.py
Outdated
| def get_file_size_mb(filepath: Path) -> float: | ||
| """Get file size in MB.""" | ||
| try: | ||
| return os.path.getsize(filepath) / (1024 * 1024) |
Collaborator
There was a problem hiding this comment.
In get_available_memory_gb(), the denominator is 1024^3.
For "similarity", I'd suggest either making this denominator 1024^2 or the other 102410241024.
sc0tts
reviewed
Sep 10, 2025
sc0tts
reviewed
Sep 10, 2025
sc0tts
reviewed
Sep 10, 2025
| """Safely read a JSON file and return DataFrame.""" | ||
| try: | ||
| if os.path.getsize(filepath) > 2: | ||
| return pd.read_json(filepath) |
Collaborator
There was a problem hiding this comment.
Is there a reason not to use read_json_file_safe() here?
sc0tts
reviewed
Sep 10, 2025
sc0tts
reviewed
Sep 10, 2025
| continue | ||
|
|
||
| try: | ||
| df = pd.read_json(filepath) |
Collaborator
There was a problem hiding this comment.
use safe read method from above?
sc0tts
reviewed
Sep 10, 2025
sc0tts
reviewed
Sep 10, 2025
sc0tts
reviewed
Sep 10, 2025
| print(f" {filepath.name} ({size_mb:.1f}MB, {available_gb:.1f}GB available)") | ||
|
|
||
| # Skip files that are too large for current memory | ||
| if size_mb > available_gb * 300: # Conservative threshold |
Collaborator
There was a problem hiding this comment.
Maybe define 300 as a constant.
And then in the print statement, include the size_mb and the 300*available_gb to give an indication of the "scale" of the issue that occurred here.
sc0tts
approved these changes
Sep 10, 2025
Collaborator
sc0tts
left a comment
There was a problem hiding this comment.
Made lots of small suggestions, but they are not blocking.
Very nice summary stats!
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.
This dynamically reads in the ingest files to prevent job failure through running out of memory. Here is an example output from the march month