refactor: use config constants for retry attempts and time rounding#36
Merged
Conversation
- Replace hard-coded MAX_RETRY_ATTEMPTS (3) with config.MAX_RETRY_ATTEMPTS - Replace hard-coded DEFAULT_TIME_ROUND_SECONDS (60) with config.DEFAULT_TIME_ROUND_SECONDS - Change getnc() dtRound parameter default from 60 to None to allow config-based defaults - Add logic to apply config default when dtRound is not explicitly provided Resolves PR #23 comment about unused constants in config.py by implementing their usage in the network request retry logic and time rounding functionality.
Contributor
There was a problem hiding this comment.
Pull request overview
This pull request refactors the codebase to use centralized configuration constants that were previously defined but unused. The changes consolidate hardcoded URLs, timeouts, and other configuration values into a centralized config.py module, improving maintainability and consistency.
Changes:
- Creates new
config.pymodule with centralized configuration constants for THREDDS servers, imagery URLs, network settings, and time configuration - Creates new
exceptions.pymodule with custom exception hierarchy for better error handling - Refactors
getDataFRF.pyto use config constants and fix NCML indexing bug where negative indices caused incorrect data retrieval - Adds comprehensive test coverage including regression tests for NCML indexing, config validation, and integration tests
- Updates multiple modules (
getOutsideData.py,gridTools.py,Thredds_checker.py) to use centralized config values
Reviewed changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 9 comments.
Show a summary per file
| File | Description |
|---|---|
| murgtools/config.py | New file defining all configuration constants with helper functions for server selection |
| murgtools/exceptions.py | New file defining custom exception hierarchy (InvalidGaugeError, DataNotFoundError, etc.) |
| murgtools/getdata/getDataFRF.py | Major refactoring to use config constants, fix NCML indexing bug, add new gauges, improve error handling |
| murgtools/getdata/getOutsideData.py | Updated to use config constants for STAC URLs and added GeoTIFF coordinate extraction |
| murgtools/utils/gridTools.py | Updated to use config constants for survey and wave array URLs |
| murgtools/utils/sblib.py | Added roundDatetimeToInterval() utility function for time rounding |
| murgtools/utils/Thredds_checker.py | Updated to use config constants |
| tests/test_config.py | Comprehensive tests for config module (373 lines) |
| tests/test_getDataFRF.py | Added 556 lines of tests for getObs methods and gauge lookups |
| tests/test_ncml_indexing_regression.py | New regression tests for NCML indexing bug fix (398 lines) |
| tests/test_integration.py | Minor update removing redundant skip decorator |
| examples/test_wave_and_imagery.py | Minor cleanup removing redundant xlabel |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Contributor
Co-authored-by: SBFRF <8375832+SBFRF@users.noreply.github.com>
Co-authored-by: SBFRF <8375832+SBFRF@users.noreply.github.com>
Fix ValueError from getnc() returning 3 values but call sites unpacking 2
…nges - Update test_getWind_returns_expected_keys mock to return 3 values from getnc() - Fix undefined indexRef variable in getWaveHeightValues method - Add noqa comments to long URLs in config.py to pass flake8 All tests now pass (137 passed, 1 skipped) and flake8 linting passes.
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.
Description
Implements the unused config constants from PR #23 by actually using them in the codebase.
Changes
MAX_RETRY_ATTEMPTS = 3withconfig.MAX_RETRY_ATTEMPTSin getDataFRF.pyDEFAULT_TIME_ROUND_SECONDS = 60withconfig.DEFAULT_TIME_ROUND_SECONDSin getDataFRF.pyResolves
PR #23 comment: "The constants MAX_RETRY_ATTEMPTS and DEFAULT_TIME_ROUND_SECONDS are defined in config.py but are not used anywhere in the codebase."
Testing
All existing tests pass (27/27 in test_config.py)