Skip to content

refactor: use config constants for retry attempts and time rounding#36

Merged
SBFRF merged 9 commits into
mainfrom
refactor/use-config-constants
Feb 2, 2026
Merged

refactor: use config constants for retry attempts and time rounding#36
SBFRF merged 9 commits into
mainfrom
refactor/use-config-constants

Conversation

@SBFRF

@SBFRF SBFRF commented Feb 2, 2026

Copy link
Copy Markdown
Owner

Description

Implements the unused config constants from PR #23 by actually using them in the codebase.

Changes

  • Replace hard-coded MAX_RETRY_ATTEMPTS = 3 with config.MAX_RETRY_ATTEMPTS in getDataFRF.py
  • Replace hard-coded DEFAULT_TIME_ROUND_SECONDS = 60 with config.DEFAULT_TIME_ROUND_SECONDS in getDataFRF.py
  • Update getnc() function to accept None for dtRound parameter and apply config default when not explicitly provided
  • Add detailed documentation comments to both constants in config.py explaining their usage

Resolves

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)

- 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.
Copilot AI review requested due to automatic review settings February 2, 2026 02:10

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.py module with centralized configuration constants for THREDDS servers, imagery URLs, network settings, and time configuration
  • Creates new exceptions.py module with custom exception hierarchy for better error handling
  • Refactors getDataFRF.py to 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.

Comment thread murgtools/getdata/getDataFRF.py
Comment thread murgtools/getdata/getDataFRF.py Outdated
Comment thread tests/test_getDataFRF.py Outdated
Comment thread tests/test_getDataFRF.py Outdated
Comment thread tests/test_getDataFRF.py Outdated
Comment thread tests/test_getDataFRF.py
Comment thread tests/test_ncml_indexing_regression.py Outdated
Comment thread tests/test_ncml_indexing_regression.py Outdated
Comment thread murgtools/getdata/getDataFRF.py Outdated
SBFRF and others added 3 commits February 1, 2026 21:24
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

Copilot AI commented Feb 2, 2026

Copy link
Copy Markdown
Contributor

@SBFRF I've opened a new pull request, #41, to work on those changes. Once the pull request is ready, I'll request review from you.

Copilot AI and others added 5 commits February 2, 2026 02:38
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.
@SBFRF
SBFRF merged commit 2b660b2 into main Feb 2, 2026
4 checks passed
@SBFRF
SBFRF deleted the refactor/use-config-constants branch February 2, 2026 03:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants