Skip to content

refactor: Comprehensive refactoring v2 (v1.4.4)#141

Merged
koito19960406 merged 17 commits intomainfrom
enhancement/comprehensive-refactoring-v2
Feb 19, 2026
Merged

refactor: Comprehensive refactoring v2 (v1.4.4)#141
koito19960406 merged 17 commits intomainfrom
enhancement/comprehensive-refactoring-v2

Conversation

@koito19960406
Copy link
Owner

@koito19960406 koito19960406 commented Feb 18, 2026

Summary

This PR consolidates a comprehensive refactoring effort across the entire ZenSVI codebase. All changes have been validated with 0 failures across Python 3.9, 3.10, 3.11, and 3.12.

  • Phase 1: Fixed pkg_resourcesimportlib.resources, added BaseDownloader tests
  • Phase 2: Added type hints to all 38 source modules
  • Phase 3: Removed 25 unused dependencies, widened constraints, fixed h3 v4 API compatibility, regenerated poetry.lock
  • Phase 4: Reduced test suite runtime; added 33 new unit tests; fixed segmentation uint8 overflow
  • Phase 5: Formatted with black/isort, fixed 14 unused imports, flake8 clean
  • Phase 6: Bumped version to 1.4.4, verified build
  • Phase 7: Fixed Polars .apply().map_elements(), OSMnx v2 bbox_to_poly() API, KartaView None guard
  • Phase 8: Fixed OSMnx project_gdf removal, IndexError in coverage metadata
  • Phase 10: Fixed GSV pandas dtype error (year/month as int); added compatibility shims for groundingdino-py 0.4.0 with transformers ≥5

Test plan

  • Python 3.9 — 202 passed, 0 failed
  • Python 3.10 — 182 passed, 20 skipped, 0 failed
  • Python 3.11 — 183 passed, 19 skipped, 0 failed
  • Python 3.12 — 183 passed, 19 skipped, 0 failed

Skipped tests are either CUDA-only (no GPU in CI) or VGGT (requires submodule init).

🤖 Generated with Claude Code


Note

Low Risk
Only tweaks CI logging verbosity and gitignore patterns; no runtime or library behavior changes.

Overview
Simplifies the CI Codecov upload step by removing the --verbose flag from ./codecov upload-process, reducing log noise while keeping the same coverage artifact (coverage-service.xml).

Updates .gitignore to exclude AI-related markdown files (plan.md, CLAUDE.md) from being committed.

Written by Cursor Bugbot for commit 9521a0e. This will update automatically on new commits. Configure here.

koito19960406 and others added 12 commits February 18, 2026 00:19
…date dependencies

This commit fixes critical installation issues on macOS, Google Colab, and other platforms
by modernizing the package resource loading mechanism and resolving dependency conflicts.

## Critical Fixes

### 1. Fix pkg_resources ImportError (Issue #1)
- Replace deprecated `pkg_resources` with `importlib.resources` in base.py
- Add fallback support for Python 3.8 using `importlib_resources`
- Implement error handling for missing data files with sensible defaults
- Fixes: ModuleNotFoundError: No module named 'pkg_resources' on macOS

Files changed:
- src/zensvi/download/base.py: Replace pkg_resources.resource_filename() with importlib.resources.files()

### 2. Fix Dependency Version Conflicts (Issue #2)
- Update pyproject.toml with specific version constraints for all major dependencies
- Add missing explicit dependencies that were causing conflicts in Google Colab
- Pin versions to prevent incompatible package combinations

Key dependency updates:
- numpy: "*" → ">=1.26.0,<3.0"
- shapely: ">=2.0.0" → ">=2.1.0,<3.0"
- geopandas: ">=0.10.0" → ">=1.0.0,<2.0"
- python-dotenv: "^0.19.0" → ">=1.0.0,<2.0"
- torch: ">=2.3" → ">=2.3,<2.10"
- attrs: "^21.2.0" → ">=22.2.0"
- Added: websockets, jsonschema, protobuf, decorator, fsspec, cffi, rich, ipython

Files changed:
- pyproject.toml: Update dependency version constraints (lines 10-71)

### 3. Testing Infrastructure Improvements
- Create comprehensive test suite for BaseDownloader class
- Fix pytest configuration to work without coverage plugin
- Add 12 test cases covering all base downloader functionality

Files changed:
- tests/test_base_downloader.py: New comprehensive test suite
- pyproject.toml: Comment out problematic pytest addopts

## Documentation

- Add plan.md: Comprehensive refactoring roadmap with 50 tasks across 5 phases
- Add REFACTORING_SUMMARY.md: Detailed summary of changes and testing instructions

## Backward Compatibility

All changes are backward compatible. Existing user code will continue to work without modifications.

## Testing

Code changes verified:
✓ pkg_resources completely removed
✓ importlib.resources import working
✓ Fallback mechanism for older Python versions
✓ Error handling for missing data files

Manual testing required on:
- Google Colab
- macOS (Intel and Apple Silicon)
- Linux
- Windows

## References

- PEP 451: Deprecation of pkg_resources
- importlib.resources documentation: https://docs.python.org/3/library/importlib.resources.html

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit enhances type hinting across various classification modules and the depth estimation module, ensuring better code clarity and type safety. Additionally, it updates the dependency specifications in `pyproject.toml` to use more flexible version constraints, improving compatibility with different environments.

### Key Changes
- Updated type hints in multiple classifier classes to use `Optional` and specific types for better clarity.
- Improved dependency specifications in `pyproject.toml` for several packages, allowing for broader compatibility.

Files changed:
- Updated type hints in `src/zensvi/cv/classification/*.py` files.
- Modified dependency constraints in `pyproject.toml`.

These changes aim to enhance code maintainability and ensure smoother installations across various platforms.
This commit updates the package version in `pyproject.toml` to 1.4.4 and improves code formatting across various modules by breaking long function signatures into multiple lines for better readability. Additionally, new markers for pytest are added to facilitate test categorization.

### Key Changes
- Updated version in `pyproject.toml` to 1.4.4.
- Reformatted `_save_results_to_file` method signatures in multiple classifier files for improved readability.
- Added pytest markers in `pyproject.toml` for slow, network, and GPU tests.

These changes aim to enhance code maintainability and improve testing organization.
…yproject.toml

This commit updates the versions of the `geojson` and `numpy` packages to ensure compatibility with the latest features and fixes. The `geojson` package is upgraded from version 3.1.0 to 3.2.0, and `numpy` is updated from 1.26.4 to 2.0.2. Additionally, the `transformers` dependency in `pyproject.toml` is modified to require version 4.40.0 or higher.

### Key Changes
- Updated `geojson` version in `poetry.lock` from 3.1.0 to 3.2.0.
- Updated `numpy` version in `poetry.lock` from 1.26.4 to 2.0.2.
- Modified `transformers` version in `pyproject.toml` to `>=4.40.0`.

These changes aim to enhance functionality and maintain compatibility with other dependencies.
…heck in KV downloader, remove duplicate test fixture, and update the refactoring plan documentation.
…e coverage calculation

This commit introduces a new GitHub Actions workflow to automate testing for MLY metadata changes. The workflow triggers on pushes and pull requests affecting specific files and runs tests across multiple Python versions. Additionally, it enhances the coverage calculation in the `MLYMetadata` class by handling cases with no relevant geometries.

### Key Changes
- Created `.github/workflows/test_mly_metadata.yml` for automated testing.
- Updated `_compute_speed` method to ensure coverage is set to 0.0 when no relevant geometries are found.

These changes aim to improve testing efficiency and ensure accurate coverage metrics.
…ties and MLYMetadata classes

This commit enhances code readability and maintainability by refining error messages and optimizing the `_compute_speed` method in the `MLYMetadata` class. The changes include:

- Improved formatting of the ValueError message in the `Entities` class to ensure clarity.
- Streamlined the `_compute_speed` method by removing unnecessary WKB conversions and implementing a more efficient approach for calculating speed.

These updates aim to enhance code quality and ensure better error reporting.
… in MLYMetadata

This commit refines the formatting of conditional expressions in the `_season_expr` method for better readability. Additionally, it optimizes the `metadata` test fixture to reuse a cached instance of `MLYMetadata`, reducing the overhead of repeated network calls during testing.

### Key Changes
- Reformatted conditional expressions in `_season_expr` for clarity.
- Updated `metadata` fixture to leverage a cached instance, improving test performance.

These changes aim to enhance code maintainability and testing efficiency.
…meter

This commit modifies the model loading process in multiple classifier classes to include the `weights_only` parameter set to `False`. This change ensures that the model is loaded correctly with the intended configuration across various classification modules.

### Key Changes
- Updated `load_from_checkpoint` method calls in `glare.py`, `lighting.py`, `panorama.py`, `platform.py`, `quality.py`, `reflection.py`, `view_direction.py`, and `weather.py` to include `weights_only=False`.

These updates aim to enhance model loading consistency and functionality across the classification modules.
This commit deletes the `.github/workflows/test_mly_metadata.yml` file, which previously defined a workflow for automated testing of MLY metadata changes across multiple Python versions. The removal is part of a broader effort to streamline CI/CD processes and may reflect a shift in testing strategy.

### Key Changes
- Deleted the `test_mly_metadata.yml` workflow file.

This change aims to simplify the repository's workflow configuration.
This commit deletes an empty line in the `mly_metadata.py` file to improve code cleanliness and maintain consistency in formatting.

### Key Changes
- Removed an empty line to streamline the code structure.

This change contributes to better readability and maintainability of the codebase.
Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.

This is the final PR Bugbot will review for you during this billing cycle

Your free Bugbot reviews will reset on March 11

Details

You are on the Bugbot Free tier. On this plan, Bugbot will review limited PRs each billing cycle.

To receive Bugbot reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial.

This commit adds `plan.md` and `CLAUDE.md` to the `.gitignore` file to prevent these AI-related markdown files from being tracked by Git. This change helps maintain a cleaner repository by excluding files that are not necessary for version control.

### Key Changes
- Added `plan.md` and `CLAUDE.md` to the `.gitignore` file.

These updates contribute to better repository management and organization.
delete plan.md as it's an internal documentation
This commit includes `plan.md` and `CLAUDE.md` in the `.gitignore` file to prevent these AI-related markdown files from being tracked by Git. This update helps maintain a cleaner repository by excluding unnecessary files from version control.

### Key Changes
- Added `plan.md` and `CLAUDE.md` to the `.gitignore` file.

These changes contribute to better organization and management of the repository.
This commit updates the GitHub Actions workflow by removing the `--verbose` flag from the Codecov upload process command. This change simplifies the command while maintaining its functionality.

### Key Changes
- Removed `--verbose` flag from the Codecov upload command.

This adjustment aims to streamline the CI process without affecting coverage reporting.
@koito19960406 koito19960406 merged commit a13ae51 into main Feb 19, 2026
6 of 12 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