Skip to content

feat: major refactor#242

Closed
martjanz wants to merge 53 commits into
devfrom
feat/refactor-clean-merge-vv-improv
Closed

feat: major refactor#242
martjanz wants to merge 53 commits into
devfrom
feat/refactor-clean-merge-vv-improv

Conversation

@martjanz

@martjanz martjanz commented Jun 1, 2026

Copy link
Copy Markdown
Collaborator

This pull request restructures and modernizes the project's CI/CD and configuration setup, introduces a new dependency management system, and finalizes a complex merge of two major development branches. The most significant changes are the refactoring and separation of GitHub Actions workflows, integration of Pipenv for dependency management, updates to configuration and data files, and a detailed merge of architectural and algorithmic improvements from two diverged branches.

CI/CD and Dependency Management Improvements:

  • Separated GitHub Actions workflows into three distinct files: build.yml (now only for publishing on tag), docs.yml (for documentation builds), and tests.yml (for linting, unit, integration, and packaging), providing clearer, more maintainable automation. The test workflow now uses Python 3.12 and the Ruff linter, and coverage reports are uploaded as artifacts.
  • Introduced a Pipfile for dependency management with Pipenv, specifying all core dependencies and Python 3.12 compatibility.

Configuration and Data Updates:

  • Updated configs/configuraciones_generales.yaml to rename keys (e.g., alias_dbalias_db_insumos), add new GPS-related columns, and introduce new batch processing and documentation for GPS fields.
  • Modified data/data_ciudad/stops.csv to update the stop data schema and values, reflecting a new format and presumably new data.

Merge and Refactor of Major Feature Branches:

  • Merged validar_velocidad into feat/refactor-clean, blending architectural changes (new storage context, DuckDB, CLI, logging) with algorithmic improvements (GPS-based distance/speed, new travel time tables, vectorized KPI helpers, and comprehensive column renames). The merge strategy prioritized the refactored architecture while integrating new logic and discarding obsolete code.
    • Key functional changes include a new assign_time_distances function, reordering of processing steps, improved dashboard data loading, KPI calculation enhancements, and consistent column renames throughout the codebase and documentation.
    • Notable decision: legacy KPI computation was retained for compatibility, with a note to update in the future.

Documentation Updates:

  • Updated documentation (resultados.rst) to reflect new column names (e.g., speed_kmhkmh_route, distance_osm_drivedistance_od) for consistency with the merged codebase.
  • Added a merge report documenting the resolution process and decisions for the major branch merge.

Miscellaneous:

  • Added a Windows batch file dashboard.bat for launching the dashboard via Streamlit.

Most Important Changes:

1. CI/CD and Dependency Management

  • Split CI workflows into build.yml (publishing only), docs.yml (documentation), and tests.yml (lint/unit/integration/package build), modernizing the automation pipeline and improving maintainability.
  • Added a Pipfile for dependency management, specifying all required packages and Python version.

2. Major Feature Branch Merge and Refactor

  • Merged validar_velocidad into feat/refactor-clean, integrating architectural refactor (storage context, DuckDB, CLI, logging) with new GPS-based distance/speed logic, new travel time tables, and consistent column renames.

3. Configuration and Data File Updates

  • Updated general configuration YAML to use new keys, add GPS columns, and document new settings; updated stops CSV schema and data.

4. Documentation Consistency

  • Updated documentation to match new column names and data structures, ensuring alignment between code and docs.

5. Developer Experience

  • Added a batch script for launching the dashboard, improving ease of use for Windows users.

martjanz added 30 commits May 27, 2026 10:55
Add unit tests for DuckDB Arrow-registration memory safety,
verifying every register call is balanced by unregister and
that save_legs uses zero Arrow registrations via parquet staging.
Replace stale `h3_o` column references with `h3` in geo equivalence
and desire-line helpers. Compute polygon centroid from geometry
instead of relying on dropped `polygon_lat/lon` mean columns.
Resolves 18 files with conflict markers. Strategy: keep HEAD's StorageContext/
DuckDB architecture throughout, integrate VV's functional improvements:

- Rename assign_gps_destination → assign_time_distances; now computes
  distance_od, distance_route, distance_route_gps and saves to
  travel_times_legs/trips tables
- preparo_dashboard: query etapas/viajes with LEFT JOIN to travel_times_*
  to pull pre-computed distance and speed columns
- kpi.py: read_data_for_daily_kpi joins travel_times_legs; add inf cleanup
  and rounding to compute_kpi_by_line_day; add pd.set_option for pandas
- misc.py: persist_indicators queries use distance_od from travel_times_trips
- run_process.py: procesar_transacciones uses assign_time_distances, moves
  rearrange_trip_id_same_od before it, removes redundant add_distance calls
- routes.py: improved assert error message from VV
- kpi_lineas.py: column renames (distance_km→distance_route, distancia→
  distance_od, travel_speed→kmh_od) and vehiculos_operativos logic
- configs: alias_db_insumos key, new GPS column names preserved from VV
… fo_mean) to VV names throughout dashboard and schema
martjanz added 7 commits May 31, 2026 21:25
… aliases centrally

- Add `--config` CLI flag support in dashboard.py; propagates
  path via URBANTRIPS_CONFIG env var so all modules pick it up
- Extract `_get_base_config_path()` and `get_project_root()` to
  honour URBANTRIPS_CONFIG when locating configs and DB files
- Add `resolve_db_aliases()` to centralise alias_db priority
  logic (alias_db_insumos > alias_db, per-corrida overrides)
- Simplify `leer_alias()` using the new helper; fix multi-corrida
  path to only bypass aliases when no shared alias_db key exists
- Rename `traigo_db_path` → `get_db_path`; prepend project-root
  candidates so absolute paths resolve correctly
- Fall back to config file corridas list in
  `traer_dias_disponibles()` when DB query fails or returns empty
@martjanz martjanz self-assigned this Jun 1, 2026
@martjanz martjanz added the enhancement New feature or request label Jun 1, 2026
@martjanz martjanz closed this Jun 18, 2026
@martjanz martjanz deleted the feat/refactor-clean-merge-vv-improv branch June 18, 2026 21:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants