Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BREAKING CHANGE: Redesing Parameters module #136

Merged
merged 34 commits into from
Jan 9, 2025
Merged

Conversation

MAfarrag
Copy link
Member

@MAfarrag MAfarrag commented Jan 3, 2025

New Parameter design

This pull request introduces a redesign of the parameters module in the Hapi project. The key changes include:

New Classes and Methods

  • FigshareAPIClient: A client for interacting with the Figshare API, including methods for sending requests, retrieving article versions, and listing article versions.
  • FileManager: Handles file operations such as downloading and clearing directories.
  • ParameterManager: Manages hydrological parameters, including methods for retrieving article details, listing files, downloading files, and mapping user-friendly IDs to article IDs.
  • Parameter: A simplified interface for handling hydrological parameters, including methods for downloading all parameter sets, downloading specific parameter sets, and listing parameter names.

Docstrings and Examples

  • Detailed docstrings with parameters, return types, examples, and exceptions for each method.
  • Examples provided for using the classes and methods.

CLI Integration

A command-line interface (CLI) for managing hydrological parameters, including commands for downloading all parameter sets, downloading specific parameter sets, and listing parameter names.

Logging

Use of the loguru library for logging debug information, such as file downloads and directory clearing.

Environment Variable

Use of the HAPI_DATA_DIR environment variable to specify the default directory for saving downloaded parameters.

Overall, this pull request enhances the functionality and usability of the parameters module by providing a more structured and documented approach to managing hydrological parameters.

  • Fixes # (issue)

Breaking the API

Check relevant points.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

Unit Tests (test_parameters.py):

  • Added comprehensive unit and integration tests for:
    • FigshareAPIClient: Testing API calls, version retrieval, and error handling.
    • FileManager: Testing directory creation, file downloading, and clearing operations.
    • ParameterManager: Mock and integration tests for parameter management, including fetching, listing, and downloading parameters.
    • Parameter: Mock and integration tests for its methods like get_parameters and get_parameter_set.

CLI Integration (test_parameters_cli.py):

  • Added tests for CLI commands to:

    • Download all parameters (download-parameters).
    • Download a specific parameter set (download-parameter-set).
    • List parameter names (list-parameter-names).
    • Used pytest and unittest.mock for testing CLI interactions.
  • tests/rrm/parameters/test_parameters.py

  • tests/rrm/parameters/test_parameters_cli.py

Checklist:

  • updated version number in pyproject.toml
  • updated environment.yml and the lock file
  • added changes to History.rst
  • updated the latest version in README file
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

@MAfarrag MAfarrag changed the title Redesing Parameters module BREAKING CHANGE: Redesing Parameters module Jan 9, 2025
Copy link

codecov bot commented Jan 9, 2025

Codecov Report

Attention: Patch coverage is 0% with 26 lines in your changes missing coverage. Please review.

Project coverage is 0.00%. Comparing base (d06f980) to head (3e73c7f).

Files with missing lines Patch % Lines
src/Hapi/inputs.py 0.00% 26 Missing ⚠️
Additional details and impacted files
@@          Coverage Diff          @@
##            main    #136   +/-   ##
=====================================
  Coverage   0.00%   0.00%           
=====================================
  Files         16      16           
  Lines       2273    2288   +15     
=====================================
- Misses      2273    2288   +15     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@MAfarrag MAfarrag merged commit 03aad86 into main Jan 9, 2025
6 of 7 checks passed
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.

1 participant