From 4bfc8205a6f7f2b907c3cf1f7f66a4ea7666b47e Mon Sep 17 00:00:00 2001 From: Sherley-Sonali Date: Mon, 8 Jun 2026 16:47:53 +0530 Subject: [PATCH 1/5] add GHA skeleton for routing regression pipeline --- .github/workflows/routing_regression.yml | 158 +++++++++++++++++++++++ 1 file changed, 158 insertions(+) create mode 100644 .github/workflows/routing_regression.yml diff --git a/.github/workflows/routing_regression.yml b/.github/workflows/routing_regression.yml new file mode 100644 index 0000000..d9747e7 --- /dev/null +++ b/.github/workflows/routing_regression.yml @@ -0,0 +1,158 @@ +name: Routing Regression + +on: + workflow_dispatch: + +jobs: + build-valhalla: + runs-on: ubuntu-24.04 + steps: + - name: Checkout Valhalla + uses: actions/checkout@v4 + with: + repository: valhalla/valhalla + ref: 3.7.0 + submodules: recursive + + - name: Restore ccache + uses: tespkg/actions-cache/restore@v1 + with: + endpoint: ${{ secrets.HETZNER_S3_ENDPOINT }} + accessKey: ${{ secrets.HETZNER_S3_ACCESS_KEY }} + secretKey: ${{ secrets.HETZNER_S3_ACCESS_SECRET }} + bucket: rad-cache + path: ~/.cache/ccache + key: ccache-valhalla-${{ github.ref_name }} + restore-keys: | + ccache-valhalla-main + ccache-valhalla + + - name: Install dependencies + # TODO: replace with targeted dep install once GHA base image is confirmed + run: bash scripts/install-linux-deps.sh + + - name: Build Valhalla + run: | + cmake -B build \ + -DCMAKE_BUILD_TYPE=Release \ + -DENABLE_PYTHON_BINDINGS=ON \ + -DENABLE_SERVICES=OFF \ + -DENABLE_TESTS=OFF \ + -DENABLE_BENCHMARKS=OFF \ + -DENABLE_CCACHE=ON + make -C build -j$(nproc) + sudo make -C build install + + - name: Save ccache + if: always() + uses: tespkg/actions-cache/save@v1 + with: + endpoint: ${{ secrets.HETZNER_S3_ENDPOINT }} + accessKey: ${{ secrets.HETZNER_S3_ACCESS_KEY }} + secretKey: ${{ secrets.HETZNER_S3_ACCESS_SECRET }} + bucket: rad-cache + path: ~/.cache/ccache + key: ccache-valhalla-${{ github.ref_name }} + + # TODO: package installed valhalla binaries + python wheel as artifact + # so build-tiles and run-routes can use the built code without rebuilding + + build-tiles: + runs-on: ubuntu-24.04 + needs: build-valhalla + steps: + - name: Checkout RAD + uses: actions/checkout@v4 + with: + lfs: true + + # TODO: download last successful tiles artifact here first; + # only run build-tiles if no valid artifact exists (cache miss logic) + - name: Build graph tiles + # TODO: replace inline shell with scripts/build_tiles.py once implemented + # TODO: admins.sqlite (500MB) is not in the repo — needs a download step or separate artifact + run: | + python3 -m valhalla valhalla_build_config \ + --mjolnir-tile-dir valhalla_tiles \ + --mjolnir-admin admins.sqlite > valhalla.json + python3 -m valhalla valhalla_build_tiles -c valhalla.json data/liechtenstein_graph.osm.pbf + + - name: Upload tiles artifact + uses: actions/upload-artifact@v4 + with: + name: valhalla-tiles + path: valhalla_tiles/ + retention-days: 90 + + run-routes: + runs-on: ubuntu-24.04 + needs: build-tiles + strategy: + matrix: + router: [old, new] + steps: + - name: Checkout RAD + uses: actions/checkout@v4 + + - name: Checkout RAD-data + uses: actions/checkout@v4 + with: + repository: valhalla/RAD-data + path: RAD-data + token: ${{ secrets.RAD_DATA_TOKEN }} + + - name: Download tiles artifact + uses: actions/download-artifact@v4 + with: + name: valhalla-tiles + path: valhalla_tiles/ + + - name: Install pyvalhalla + # TODO: replace with wheel built from source in build-valhalla job + # so routing uses the actual PR branch code, not a fixed PyPI release + run: pip install pyvalhalla + + - name: Run route requests + # TODO: implement scripts/run_routes.py + # reads RAD-data/requests/requests.jsonl + # uses pyvalhalla Actor to send each request + # writes responses to RAD-data/responses/${{ matrix.router }}.jsonl + run: | + echo "TODO: python3 scripts/run_routes.py \ + --requests RAD-data/requests/requests.jsonl \ + --tiles valhalla_tiles/ \ + --output RAD-data/responses/${{ matrix.router }}.jsonl" + + - name: Push responses to RAD-data + # TODO: implement scripts/push_results.py + # responses must be pushed here before diff-and-store runs, + # since each matrix runner is a separate machine + run: | + echo "TODO: python3 scripts/push_results.py --repo RAD-data --stage responses" + + diff-and-store: + runs-on: ubuntu-24.04 + needs: run-routes + steps: + - name: Checkout RAD-data + uses: actions/checkout@v4 + with: + repository: valhalla/RAD-data + path: RAD-data + token: ${{ secrets.RAD_DATA_TOKEN }} + + - name: Compute diff + # TODO: implement scripts/diff_responses.py + # reads RAD-data/responses/old.jsonl and new.jsonl + # writes RAD-data/diffs/.json + run: | + echo "TODO: python3 scripts/diff_responses.py \ + --old RAD-data/responses/old.jsonl \ + --new RAD-data/responses/new.jsonl \ + --output RAD-data/diffs/${{ github.run_id }}.json" + + - name: Push results to RAD-data + # TODO: implement scripts/push_results.py + # git add + commit + push to RAD-data + run: | + echo "TODO: python3 scripts/push_results.py --repo RAD-data" From 9cbc9b8d1f8392c97eb5f29bf77a402d9ccb960e Mon Sep 17 00:00:00 2001 From: Sherley-Sonali Date: Wed, 10 Jun 2026 13:19:17 +0530 Subject: [PATCH 2/5] update GHA skeleton: merged build jobs, ccache via S3, matrix for 4 permutations --- .github/workflows/routing_regression.yml | 114 ++++++++++++++++------- 1 file changed, 78 insertions(+), 36 deletions(-) diff --git a/.github/workflows/routing_regression.yml b/.github/workflows/routing_regression.yml index d9747e7..c02db4c 100644 --- a/.github/workflows/routing_regression.yml +++ b/.github/workflows/routing_regression.yml @@ -2,16 +2,34 @@ name: Routing Regression on: workflow_dispatch: + inputs: + valhalla_ref_old: + description: "Valhalla ref for old router (e.g. master)" + default: master + valhalla_ref_new: + description: "Valhalla ref for new router (e.g. PR branch or commit SHA)" + required: true + tiles_artifact: + description: "Name of tiles artifact to use (e.g. valhalla-tiles-master)" + default: valhalla-tiles-master + rebuild_tiles: + description: "Build new graph tiles instead of using existing artifact" + type: boolean + default: false + tiles_valhalla_ref: + description: "Valhalla ref to build tiles from (only used if rebuild_tiles=true)" + default: master jobs: - build-valhalla: + build-and-tile: runs-on: ubuntu-24.04 + if: ${{ inputs.rebuild_tiles }} steps: - name: Checkout Valhalla uses: actions/checkout@v4 with: repository: valhalla/valhalla - ref: 3.7.0 + ref: ${{ inputs.tiles_valhalla_ref }} submodules: recursive - name: Restore ccache @@ -22,10 +40,8 @@ jobs: secretKey: ${{ secrets.HETZNER_S3_ACCESS_SECRET }} bucket: rad-cache path: ~/.cache/ccache - key: ccache-valhalla-${{ github.ref_name }} - restore-keys: | - ccache-valhalla-main - ccache-valhalla + key: ccache-valhalla-${{ inputs.tiles_valhalla_ref }} + restore-keys: ccache-valhalla-master - name: Install dependencies # TODO: replace with targeted dep install once GHA base image is confirmed @@ -52,44 +68,40 @@ jobs: secretKey: ${{ secrets.HETZNER_S3_ACCESS_SECRET }} bucket: rad-cache path: ~/.cache/ccache - key: ccache-valhalla-${{ github.ref_name }} + key: ccache-valhalla-${{ inputs.tiles_valhalla_ref }} - # TODO: package installed valhalla binaries + python wheel as artifact - # so build-tiles and run-routes can use the built code without rebuilding - - build-tiles: - runs-on: ubuntu-24.04 - needs: build-valhalla - steps: - name: Checkout RAD uses: actions/checkout@v4 with: lfs: true - # TODO: download last successful tiles artifact here first; - # only run build-tiles if no valid artifact exists (cache miss logic) - name: Build graph tiles - # TODO: replace inline shell with scripts/build_tiles.py once implemented - # TODO: admins.sqlite (500MB) is not in the repo — needs a download step or separate artifact + # TODO: admins.sqlite (500MB) not in repo — needs separate solution + # TODO: replace inline shell with scripts/build_tiles.py run: | - python3 -m valhalla valhalla_build_config \ + valhalla_build_config \ --mjolnir-tile-dir valhalla_tiles \ --mjolnir-admin admins.sqlite > valhalla.json - python3 -m valhalla valhalla_build_tiles -c valhalla.json data/liechtenstein_graph.osm.pbf + valhalla_build_tiles -c valhalla.json data/liechtenstein_graph.osm.pbf - name: Upload tiles artifact uses: actions/upload-artifact@v4 with: - name: valhalla-tiles + name: valhalla-tiles-${{ inputs.tiles_valhalla_ref }} path: valhalla_tiles/ retention-days: 90 run-routes: runs-on: ubuntu-24.04 - needs: build-tiles + needs: build-and-tile + if: always() strategy: matrix: - router: [old, new] + router: + - ref: ${{ inputs.valhalla_ref_old }} + name: old + - ref: ${{ inputs.valhalla_ref_new }} + name: new steps: - name: Checkout RAD uses: actions/checkout@v4 @@ -104,35 +116,66 @@ jobs: - name: Download tiles artifact uses: actions/download-artifact@v4 with: - name: valhalla-tiles + name: ${{ inputs.tiles_artifact }} path: valhalla_tiles/ - - name: Install pyvalhalla - # TODO: replace with wheel built from source in build-valhalla job - # so routing uses the actual PR branch code, not a fixed PyPI release - run: pip install pyvalhalla + - name: Restore ccache + uses: tespkg/actions-cache/restore@v1 + with: + endpoint: ${{ secrets.HETZNER_S3_ENDPOINT }} + accessKey: ${{ secrets.HETZNER_S3_ACCESS_KEY }} + secretKey: ${{ secrets.HETZNER_S3_ACCESS_SECRET }} + bucket: rad-cache + path: ~/.cache/ccache + key: ccache-valhalla-${{ matrix.router.ref }} + restore-keys: ccache-valhalla-master + + - name: Install dependencies + run: bash scripts/install-linux-deps.sh + + - name: Checkout Valhalla at router ref + uses: actions/checkout@v4 + with: + repository: valhalla/valhalla + ref: ${{ matrix.router.ref }} + submodules: recursive + path: valhalla-src + + - name: Build Valhalla at router ref + # fast on cache hit — ccache returns cached objects if source unchanged + run: | + cmake -B valhalla-src/build \ + -S valhalla-src \ + -DCMAKE_BUILD_TYPE=Release \ + -DENABLE_PYTHON_BINDINGS=ON \ + -DENABLE_SERVICES=OFF \ + -DENABLE_TESTS=OFF \ + -DENABLE_BENCHMARKS=OFF \ + -DENABLE_CCACHE=ON + make -C valhalla-src/build -j$(nproc) + sudo make -C valhalla-src/build install - name: Run route requests # TODO: implement scripts/run_routes.py # reads RAD-data/requests/requests.jsonl - # uses pyvalhalla Actor to send each request - # writes responses to RAD-data/responses/${{ matrix.router }}.jsonl + # uses pyvalhalla bindings built from source to send each request + # writes to RAD-data/responses/${{ matrix.router.name }}.jsonl run: | echo "TODO: python3 scripts/run_routes.py \ --requests RAD-data/requests/requests.jsonl \ --tiles valhalla_tiles/ \ - --output RAD-data/responses/${{ matrix.router }}.jsonl" + --output RAD-data/responses/${{ matrix.router.name }}.jsonl" - name: Push responses to RAD-data # TODO: implement scripts/push_results.py - # responses must be pushed here before diff-and-store runs, - # since each matrix runner is a separate machine + # must push before diff-and-store since each matrix job is a separate machine run: | echo "TODO: python3 scripts/push_results.py --repo RAD-data --stage responses" diff-and-store: runs-on: ubuntu-24.04 needs: run-routes + if: always() steps: - name: Checkout RAD-data uses: actions/checkout@v4 @@ -151,8 +194,7 @@ jobs: --new RAD-data/responses/new.jsonl \ --output RAD-data/diffs/${{ github.run_id }}.json" - - name: Push results to RAD-data + - name: Push diff to RAD-data # TODO: implement scripts/push_results.py - # git add + commit + push to RAD-data run: | - echo "TODO: python3 scripts/push_results.py --repo RAD-data" + echo "TODO: python3 scripts/push_results.py --repo RAD-data --stage diff" From 383db986c2af47972751b36e31cc0e847df68603 Mon Sep 17 00:00:00 2001 From: Sherley-Sonali Date: Mon, 15 Jun 2026 14:22:05 +0530 Subject: [PATCH 3/5] ci: split routing_regression into build-valhalla, build-tiles, routing-regression workflows --- .github/workflows/build-tiles.yml | 85 +++++++++++ .github/workflows/build-valhalla.yml | 59 ++++++++ ..._regression.yml => routing-regression.yml} | 134 ++++++------------ 3 files changed, 184 insertions(+), 94 deletions(-) create mode 100644 .github/workflows/build-tiles.yml create mode 100644 .github/workflows/build-valhalla.yml rename .github/workflows/{routing_regression.yml => routing-regression.yml} (58%) diff --git a/.github/workflows/build-tiles.yml b/.github/workflows/build-tiles.yml new file mode 100644 index 0000000..34b0206 --- /dev/null +++ b/.github/workflows/build-tiles.yml @@ -0,0 +1,85 @@ +name: Build Tiles + +on: + workflow_dispatch: + inputs: + valhalla_ref: + description: "Valhalla ref to build tiles with (e.g. master)" + default: master + +jobs: + build-valhalla: + uses: ./.github/workflows/build-valhalla.yml + with: + valhalla_ref: ${{ inputs.valhalla_ref }} + secrets: inherit + + build-tiles: + runs-on: ubuntu-24.04 + needs: build-valhalla + steps: + - name: Checkout RAD + uses: actions/checkout@v4 + with: + lfs: true + + - name: Checkout Valhalla + uses: actions/checkout@v4 + with: + repository: valhalla/valhalla + ref: ${{ inputs.valhalla_ref }} + submodules: recursive + path: valhalla-src + + - name: Restore ccache + uses: tespkg/actions-cache/restore@v1 + with: + endpoint: ${{ secrets.HETZNER_S3_ENDPOINT }} + accessKey: ${{ secrets.HETZNER_S3_ACCESS_KEY }} + secretKey: ${{ secrets.HETZNER_S3_ACCESS_SECRET }} + bucket: rad-cache + path: ~/.cache/ccache + key: ccache-valhalla-${{ inputs.valhalla_ref }} + restore-keys: ccache-valhalla-master + + - name: Install dependencies + run: bash valhalla-src/scripts/install-linux-deps.sh + + - name: Rebuild Valhalla + run: | + cmake -B valhalla-src/build -S valhalla-src \ + -DCMAKE_BUILD_TYPE=Release \ + -DENABLE_PYTHON_BINDINGS=ON \ + -DENABLE_SERVICES=OFF \ + -DENABLE_TESTS=OFF \ + -DENABLE_BENCHMARKS=OFF \ + -DENABLE_CCACHE=ON + make -C valhalla-src/build -j$(nproc) + sudo make -C valhalla-src/build install + + - name: Save ccache + if: always() + uses: tespkg/actions-cache/save@v1 + with: + endpoint: ${{ secrets.HETZNER_S3_ENDPOINT }} + accessKey: ${{ secrets.HETZNER_S3_ACCESS_KEY }} + secretKey: ${{ secrets.HETZNER_S3_ACCESS_SECRET }} + bucket: rad-cache + path: ~/.cache/ccache + key: ccache-valhalla-${{ inputs.valhalla_ref }} + + - name: Build graph tiles + # TODO: admins.sqlite (500MB) not in repo — needs separate solution + # TODO: replace inline shell with scripts/build_tiles.py + run: | + valhalla_build_config \ + --mjolnir-tile-dir valhalla_tiles \ + --mjolnir-admin admins.sqlite > valhalla.json + valhalla_build_tiles -c valhalla.json data/liechtenstein_graph.osm.pbf + + - name: Upload tiles artifact + uses: actions/upload-artifact@v4 + with: + name: valhalla-tiles-${{ inputs.valhalla_ref }} + path: valhalla_tiles/ + retention-days: 90 diff --git a/.github/workflows/build-valhalla.yml b/.github/workflows/build-valhalla.yml new file mode 100644 index 0000000..d9aebf7 --- /dev/null +++ b/.github/workflows/build-valhalla.yml @@ -0,0 +1,59 @@ +name: Build Valhalla + +on: + workflow_call: + inputs: + valhalla_ref: + description: "Valhalla git ref to build (branch, tag, or SHA)" + type: string + required: true + +jobs: + build: + runs-on: ubuntu-24.04 + steps: + - name: Checkout Valhalla + uses: actions/checkout@v4 + with: + repository: valhalla/valhalla + ref: ${{ inputs.valhalla_ref }} + submodules: recursive + path: valhalla-src + + - name: Restore ccache + uses: tespkg/actions-cache/restore@v1 + with: + endpoint: ${{ secrets.HETZNER_S3_ENDPOINT }} + accessKey: ${{ secrets.HETZNER_S3_ACCESS_KEY }} + secretKey: ${{ secrets.HETZNER_S3_ACCESS_SECRET }} + bucket: rad-cache + path: ~/.cache/ccache + key: ccache-valhalla-${{ inputs.valhalla_ref }} + restore-keys: ccache-valhalla-master + + - name: Install dependencies + # TODO: replace with targeted dep install once GHA base image is confirmed + run: bash valhalla-src/scripts/install-linux-deps.sh + + - name: Build Valhalla + run: | + cmake -B valhalla-src/build -S valhalla-src \ + -DCMAKE_BUILD_TYPE=Release \ + -DENABLE_PYTHON_BINDINGS=ON \ + -DENABLE_SERVICES=OFF \ + -DENABLE_TESTS=OFF \ + -DENABLE_BENCHMARKS=OFF \ + -DENABLE_CCACHE=ON + make -C valhalla-src/build -j$(nproc) + sudo make -C valhalla-src/build install + + - name: Save ccache + if: always() + uses: tespkg/actions-cache/save@v1 + with: + endpoint: ${{ secrets.HETZNER_S3_ENDPOINT }} + accessKey: ${{ secrets.HETZNER_S3_ACCESS_KEY }} + secretKey: ${{ secrets.HETZNER_S3_ACCESS_SECRET }} + bucket: rad-cache + path: ~/.cache/ccache + key: ccache-valhalla-${{ inputs.valhalla_ref }} diff --git a/.github/workflows/routing_regression.yml b/.github/workflows/routing-regression.yml similarity index 58% rename from .github/workflows/routing_regression.yml rename to .github/workflows/routing-regression.yml index c02db4c..8368b69 100644 --- a/.github/workflows/routing_regression.yml +++ b/.github/workflows/routing-regression.yml @@ -7,94 +7,28 @@ on: description: "Valhalla ref for old router (e.g. master)" default: master valhalla_ref_new: - description: "Valhalla ref for new router (e.g. PR branch or commit SHA)" + description: "Valhalla ref for new router (e.g. PR branch or SHA)" required: true tiles_artifact: - description: "Name of tiles artifact to use (e.g. valhalla-tiles-master)" + description: "Tiles artifact name to use (e.g. valhalla-tiles-master)" default: valhalla-tiles-master - rebuild_tiles: - description: "Build new graph tiles instead of using existing artifact" - type: boolean - default: false - tiles_valhalla_ref: - description: "Valhalla ref to build tiles from (only used if rebuild_tiles=true)" - default: master jobs: - build-and-tile: - runs-on: ubuntu-24.04 - if: ${{ inputs.rebuild_tiles }} - steps: - - name: Checkout Valhalla - uses: actions/checkout@v4 - with: - repository: valhalla/valhalla - ref: ${{ inputs.tiles_valhalla_ref }} - submodules: recursive - - - name: Restore ccache - uses: tespkg/actions-cache/restore@v1 - with: - endpoint: ${{ secrets.HETZNER_S3_ENDPOINT }} - accessKey: ${{ secrets.HETZNER_S3_ACCESS_KEY }} - secretKey: ${{ secrets.HETZNER_S3_ACCESS_SECRET }} - bucket: rad-cache - path: ~/.cache/ccache - key: ccache-valhalla-${{ inputs.tiles_valhalla_ref }} - restore-keys: ccache-valhalla-master - - - name: Install dependencies - # TODO: replace with targeted dep install once GHA base image is confirmed - run: bash scripts/install-linux-deps.sh - - - name: Build Valhalla - run: | - cmake -B build \ - -DCMAKE_BUILD_TYPE=Release \ - -DENABLE_PYTHON_BINDINGS=ON \ - -DENABLE_SERVICES=OFF \ - -DENABLE_TESTS=OFF \ - -DENABLE_BENCHMARKS=OFF \ - -DENABLE_CCACHE=ON - make -C build -j$(nproc) - sudo make -C build install - - - name: Save ccache - if: always() - uses: tespkg/actions-cache/save@v1 - with: - endpoint: ${{ secrets.HETZNER_S3_ENDPOINT }} - accessKey: ${{ secrets.HETZNER_S3_ACCESS_KEY }} - secretKey: ${{ secrets.HETZNER_S3_ACCESS_SECRET }} - bucket: rad-cache - path: ~/.cache/ccache - key: ccache-valhalla-${{ inputs.tiles_valhalla_ref }} - - - name: Checkout RAD - uses: actions/checkout@v4 - with: - lfs: true - - - name: Build graph tiles - # TODO: admins.sqlite (500MB) not in repo — needs separate solution - # TODO: replace inline shell with scripts/build_tiles.py - run: | - valhalla_build_config \ - --mjolnir-tile-dir valhalla_tiles \ - --mjolnir-admin admins.sqlite > valhalla.json - valhalla_build_tiles -c valhalla.json data/liechtenstein_graph.osm.pbf - - - name: Upload tiles artifact - uses: actions/upload-artifact@v4 - with: - name: valhalla-tiles-${{ inputs.tiles_valhalla_ref }} - path: valhalla_tiles/ - retention-days: 90 + build-valhalla-old: + uses: ./.github/workflows/build-valhalla.yml + with: + valhalla_ref: ${{ inputs.valhalla_ref_old }} + secrets: inherit + + build-valhalla-new: + uses: ./.github/workflows/build-valhalla.yml + with: + valhalla_ref: ${{ inputs.valhalla_ref_new }} + secrets: inherit run-routes: runs-on: ubuntu-24.04 - needs: build-and-tile - if: always() + needs: [build-valhalla-old, build-valhalla-new] strategy: matrix: router: @@ -113,7 +47,17 @@ jobs: path: RAD-data token: ${{ secrets.RAD_DATA_TOKEN }} + - name: Checkout Valhalla at router ref + uses: actions/checkout@v4 + with: + repository: valhalla/valhalla + ref: ${{ matrix.router.ref }} + submodules: recursive + path: valhalla-src + - name: Download tiles artifact + # TODO: when tiles come from a previous run, actions/download-artifact@v4 + # only fetches from the current run — needs cross-run solution via GitHub API uses: actions/download-artifact@v4 with: name: ${{ inputs.tiles_artifact }} @@ -131,21 +75,11 @@ jobs: restore-keys: ccache-valhalla-master - name: Install dependencies - run: bash scripts/install-linux-deps.sh - - - name: Checkout Valhalla at router ref - uses: actions/checkout@v4 - with: - repository: valhalla/valhalla - ref: ${{ matrix.router.ref }} - submodules: recursive - path: valhalla-src + run: bash valhalla-src/scripts/install-linux-deps.sh - name: Build Valhalla at router ref - # fast on cache hit — ccache returns cached objects if source unchanged run: | - cmake -B valhalla-src/build \ - -S valhalla-src \ + cmake -B valhalla-src/build -S valhalla-src \ -DCMAKE_BUILD_TYPE=Release \ -DENABLE_PYTHON_BINDINGS=ON \ -DENABLE_SERVICES=OFF \ @@ -155,10 +89,21 @@ jobs: make -C valhalla-src/build -j$(nproc) sudo make -C valhalla-src/build install + - name: Save ccache + if: always() + uses: tespkg/actions-cache/save@v1 + with: + endpoint: ${{ secrets.HETZNER_S3_ENDPOINT }} + accessKey: ${{ secrets.HETZNER_S3_ACCESS_KEY }} + secretKey: ${{ secrets.HETZNER_S3_ACCESS_SECRET }} + bucket: rad-cache + path: ~/.cache/ccache + key: ccache-valhalla-${{ matrix.router.ref }} + - name: Run route requests # TODO: implement scripts/run_routes.py # reads RAD-data/requests/requests.jsonl - # uses pyvalhalla bindings built from source to send each request + # uses pyvalhalla bindings built from source # writes to RAD-data/responses/${{ matrix.router.name }}.jsonl run: | echo "TODO: python3 scripts/run_routes.py \ @@ -168,7 +113,8 @@ jobs: - name: Push responses to RAD-data # TODO: implement scripts/push_results.py - # must push before diff-and-store since each matrix job is a separate machine + # race condition risk if both matrix jobs push simultaneously — + # consider pushing responses as GHA artifacts instead, let diff-and-store handle RAD-data push run: | echo "TODO: python3 scripts/push_results.py --repo RAD-data --stage responses" From 84867be33870c72c2daabbcc99416bf12bc83afd Mon Sep 17 00:00:00 2001 From: Sherley-Sonali Date: Mon, 15 Jun 2026 18:34:19 +0530 Subject: [PATCH 4/5] addressed review comments --- .github/workflows/build-tiles.yml | 17 +++++++++-------- .github/workflows/build-valhalla.yml | 8 +++++--- .github/workflows/routing-regression.yml | 17 +++++++++-------- 3 files changed, 23 insertions(+), 19 deletions(-) diff --git a/.github/workflows/build-tiles.yml b/.github/workflows/build-tiles.yml index 34b0206..3fb6574 100644 --- a/.github/workflows/build-tiles.yml +++ b/.github/workflows/build-tiles.yml @@ -18,13 +18,13 @@ jobs: runs-on: ubuntu-24.04 needs: build-valhalla steps: - - name: Checkout RAD - uses: actions/checkout@v4 + - name: Checkout PBF + uses: actions/checkout@v6 with: lfs: true - name: Checkout Valhalla - uses: actions/checkout@v4 + uses: actions/checkout@v6 with: repository: valhalla/valhalla ref: ${{ inputs.valhalla_ref }} @@ -53,7 +53,10 @@ jobs: -DENABLE_SERVICES=OFF \ -DENABLE_TESTS=OFF \ -DENABLE_BENCHMARKS=OFF \ - -DENABLE_CCACHE=ON + -DENABLE_CCACHE=ON \ + -DENABLE_TOOLS=OFF \ + -DENABLE_GEOTIFF=OFF \ + -DENABLE_LZ4=OFF make -C valhalla-src/build -j$(nproc) sudo make -C valhalla-src/build install @@ -69,12 +72,10 @@ jobs: key: ccache-valhalla-${{ inputs.valhalla_ref }} - name: Build graph tiles - # TODO: admins.sqlite (500MB) not in repo — needs separate solution - # TODO: replace inline shell with scripts/build_tiles.py run: | + valhalla_build_admins -c valhalla.json data/liechtenstein_graph.osm.pbf valhalla_build_config \ - --mjolnir-tile-dir valhalla_tiles \ - --mjolnir-admin admins.sqlite > valhalla.json + --mjolnir-tile-dir valhalla_tiles > valhalla.json valhalla_build_tiles -c valhalla.json data/liechtenstein_graph.osm.pbf - name: Upload tiles artifact diff --git a/.github/workflows/build-valhalla.yml b/.github/workflows/build-valhalla.yml index d9aebf7..ed8aae2 100644 --- a/.github/workflows/build-valhalla.yml +++ b/.github/workflows/build-valhalla.yml @@ -13,7 +13,7 @@ jobs: runs-on: ubuntu-24.04 steps: - name: Checkout Valhalla - uses: actions/checkout@v4 + uses: actions/checkout@v6 with: repository: valhalla/valhalla ref: ${{ inputs.valhalla_ref }} @@ -32,7 +32,6 @@ jobs: restore-keys: ccache-valhalla-master - name: Install dependencies - # TODO: replace with targeted dep install once GHA base image is confirmed run: bash valhalla-src/scripts/install-linux-deps.sh - name: Build Valhalla @@ -43,7 +42,10 @@ jobs: -DENABLE_SERVICES=OFF \ -DENABLE_TESTS=OFF \ -DENABLE_BENCHMARKS=OFF \ - -DENABLE_CCACHE=ON + -DENABLE_CCACHE=ON \ + -DENABLE_TOOLS=OFF \ + -DENABLE_GEOTIFF=OFF \ + -DENABLE_LZ4=OFF make -C valhalla-src/build -j$(nproc) sudo make -C valhalla-src/build install diff --git a/.github/workflows/routing-regression.yml b/.github/workflows/routing-regression.yml index 8368b69..a239adf 100644 --- a/.github/workflows/routing-regression.yml +++ b/.github/workflows/routing-regression.yml @@ -38,17 +38,16 @@ jobs: name: new steps: - name: Checkout RAD - uses: actions/checkout@v4 + uses: actions/checkout@v6 - name: Checkout RAD-data - uses: actions/checkout@v4 + uses: actions/checkout@v6 with: repository: valhalla/RAD-data path: RAD-data - token: ${{ secrets.RAD_DATA_TOKEN }} - name: Checkout Valhalla at router ref - uses: actions/checkout@v4 + uses: actions/checkout@v6 with: repository: valhalla/valhalla ref: ${{ matrix.router.ref }} @@ -57,7 +56,7 @@ jobs: - name: Download tiles artifact # TODO: when tiles come from a previous run, actions/download-artifact@v4 - # only fetches from the current run — needs cross-run solution via GitHub API + # only fetches from the current run - needs cross-run solution via GitHub API uses: actions/download-artifact@v4 with: name: ${{ inputs.tiles_artifact }} @@ -85,7 +84,10 @@ jobs: -DENABLE_SERVICES=OFF \ -DENABLE_TESTS=OFF \ -DENABLE_BENCHMARKS=OFF \ - -DENABLE_CCACHE=ON + -DENABLE_CCACHE=ON \ + -DENABLE_TOOLS=OFF \ + -DENABLE_GEOTIFF=OFF \ + -DENABLE_LZ4=OFF make -C valhalla-src/build -j$(nproc) sudo make -C valhalla-src/build install @@ -124,11 +126,10 @@ jobs: if: always() steps: - name: Checkout RAD-data - uses: actions/checkout@v4 + uses: actions/checkout@v6 with: repository: valhalla/RAD-data path: RAD-data - token: ${{ secrets.RAD_DATA_TOKEN }} - name: Compute diff # TODO: implement scripts/diff_responses.py From 8635d366f69d3349f9565f2cd29f89e00e2445a1 Mon Sep 17 00:00:00 2001 From: Sherley-Sonali Date: Tue, 16 Jun 2026 23:28:16 +0530 Subject: [PATCH 5/5] add run_routes and diff_responses scripts, update workflows --- .github/workflows/build-tiles.yml | 75 ++++------- .github/workflows/build-valhalla.yml | 59 ++++++--- .github/workflows/routing-regression.yml | 159 ++++++++++------------- scripts/diff_responses.py | 68 ++++++++++ scripts/run_routes.py | 39 ++++++ 5 files changed, 242 insertions(+), 158 deletions(-) create mode 100644 scripts/diff_responses.py create mode 100644 scripts/run_routes.py diff --git a/.github/workflows/build-tiles.yml b/.github/workflows/build-tiles.yml index 3fb6574..f7ea30f 100644 --- a/.github/workflows/build-tiles.yml +++ b/.github/workflows/build-tiles.yml @@ -4,8 +4,9 @@ on: workflow_dispatch: inputs: valhalla_ref: - description: "Valhalla ref to build tiles with (e.g. master)" + description: "Valhalla ref to use for tile building (branch, tag, or SHA)" default: master + required: false jobs: build-valhalla: @@ -15,72 +16,44 @@ jobs: secrets: inherit build-tiles: - runs-on: ubuntu-24.04 + runs-on: ubuntu-latest needs: build-valhalla + steps: + - name: Sanitize ref for artifact name + id: sanitize + run: echo "ref_slug=$(echo '${{ inputs.valhalla_ref }}' | tr '/' '-')" >> $GITHUB_OUTPUT + - name: Checkout PBF uses: actions/checkout@v6 with: lfs: true - - name: Checkout Valhalla - uses: actions/checkout@v6 - with: - repository: valhalla/valhalla - ref: ${{ inputs.valhalla_ref }} - submodules: recursive - path: valhalla-src - - - name: Restore ccache - uses: tespkg/actions-cache/restore@v1 + - name: Download Valhalla wheel + uses: actions/download-artifact@v4 with: - endpoint: ${{ secrets.HETZNER_S3_ENDPOINT }} - accessKey: ${{ secrets.HETZNER_S3_ACCESS_KEY }} - secretKey: ${{ secrets.HETZNER_S3_ACCESS_SECRET }} - bucket: rad-cache - path: ~/.cache/ccache - key: ccache-valhalla-${{ inputs.valhalla_ref }} - restore-keys: ccache-valhalla-master + name: valhalla-wheel-${{ steps.sanitize.outputs.ref_slug }} + path: /tmp/valhalla-dist - - name: Install dependencies - run: bash valhalla-src/scripts/install-linux-deps.sh - - - name: Rebuild Valhalla - run: | - cmake -B valhalla-src/build -S valhalla-src \ - -DCMAKE_BUILD_TYPE=Release \ - -DENABLE_PYTHON_BINDINGS=ON \ - -DENABLE_SERVICES=OFF \ - -DENABLE_TESTS=OFF \ - -DENABLE_BENCHMARKS=OFF \ - -DENABLE_CCACHE=ON \ - -DENABLE_TOOLS=OFF \ - -DENABLE_GEOTIFF=OFF \ - -DENABLE_LZ4=OFF - make -C valhalla-src/build -j$(nproc) - sudo make -C valhalla-src/build install - - - name: Save ccache - if: always() - uses: tespkg/actions-cache/save@v1 - with: - endpoint: ${{ secrets.HETZNER_S3_ENDPOINT }} - accessKey: ${{ secrets.HETZNER_S3_ACCESS_KEY }} - secretKey: ${{ secrets.HETZNER_S3_ACCESS_SECRET }} - bucket: rad-cache - path: ~/.cache/ccache - key: ccache-valhalla-${{ inputs.valhalla_ref }} + - name: Install Valhalla from wheel + run: pip install /tmp/valhalla-dist/*.whl - name: Build graph tiles run: | - valhalla_build_admins -c valhalla.json data/liechtenstein_graph.osm.pbf valhalla_build_config \ - --mjolnir-tile-dir valhalla_tiles > valhalla.json - valhalla_build_tiles -c valhalla.json data/liechtenstein_graph.osm.pbf + --mjolnir-tile-dir "$(pwd)/valhalla_tiles" \ + --mjolnir-admin "$(pwd)/valhalla_tiles/admins.sqlite" \ + > valhalla.json + python -m valhalla valhalla_build_admins --config valhalla.json data/liechtenstein_graph.osm.pbf + python -m valhalla valhalla_build_tiles --config valhalla.json data/liechtenstein_graph.osm.pbf + find valhalla_tiles -name "*.gph" | wc -l - name: Upload tiles artifact uses: actions/upload-artifact@v4 with: - name: valhalla-tiles-${{ inputs.valhalla_ref }} + name: valhalla-tiles-${{ steps.sanitize.outputs.ref_slug }} path: valhalla_tiles/ retention-days: 90 + + - name: Print run ID + run: echo "tiles_run_id = ${{ github.run_id }}" diff --git a/.github/workflows/build-valhalla.yml b/.github/workflows/build-valhalla.yml index ed8aae2..ef4c8d8 100644 --- a/.github/workflows/build-valhalla.yml +++ b/.github/workflows/build-valhalla.yml @@ -4,14 +4,25 @@ on: workflow_call: inputs: valhalla_ref: - description: "Valhalla git ref to build (branch, tag, or SHA)" + description: "Valhalla git ref to build (branch, tag, or commit SHA)" type: string required: true + outputs: + wheel_artifact: + description: "Name of the uploaded wheel artifact" + value: ${{ jobs.build.outputs.wheel_artifact }} jobs: build: - runs-on: ubuntu-24.04 + runs-on: ubuntu-latest + outputs: + wheel_artifact: ${{ steps.set-output.outputs.wheel_artifact }} + steps: + - name: Sanitize ref for artifact name + id: sanitize + run: echo "ref_slug=$(echo '${{ inputs.valhalla_ref }}' | tr '/' '-')" >> $GITHUB_OUTPUT + - name: Checkout Valhalla uses: actions/checkout@v6 with: @@ -28,26 +39,25 @@ jobs: secretKey: ${{ secrets.HETZNER_S3_ACCESS_SECRET }} bucket: rad-cache path: ~/.cache/ccache - key: ccache-valhalla-${{ inputs.valhalla_ref }} - restore-keys: ccache-valhalla-master + key: ccache-valhalla-${{ steps.sanitize.outputs.ref_slug }}-${{ github.sha }} + restore-keys: | + ccache-valhalla-${{ steps.sanitize.outputs.ref_slug }}- + ccache-valhalla-master- - - name: Install dependencies + - name: Install system dependencies run: bash valhalla-src/scripts/install-linux-deps.sh - - name: Build Valhalla + - name: Install Python build dependencies + run: pip install scikit-build-core pyproject-metadata setuptools-scm pybind11 + + - name: Build wheel run: | - cmake -B valhalla-src/build -S valhalla-src \ - -DCMAKE_BUILD_TYPE=Release \ - -DENABLE_PYTHON_BINDINGS=ON \ - -DENABLE_SERVICES=OFF \ - -DENABLE_TESTS=OFF \ - -DENABLE_BENCHMARKS=OFF \ - -DENABLE_CCACHE=ON \ - -DENABLE_TOOLS=OFF \ - -DENABLE_GEOTIFF=OFF \ - -DENABLE_LZ4=OFF - make -C valhalla-src/build -j$(nproc) - sudo make -C valhalla-src/build install + cd valhalla-src + pip wheel . --no-build-isolation --wheel-dir /tmp/valhalla-dist \ + -Ccmake.build-type=Release \ + -Ccmake.define.ENABLE_PYTHON_BINDINGS=ON \ + -Ccmake.define.ENABLE_TESTS=OFF \ + -Ccmake.define.ENABLE_SERVICES=OFF - name: Save ccache if: always() @@ -58,4 +68,15 @@ jobs: secretKey: ${{ secrets.HETZNER_S3_ACCESS_SECRET }} bucket: rad-cache path: ~/.cache/ccache - key: ccache-valhalla-${{ inputs.valhalla_ref }} + key: ccache-valhalla-${{ steps.sanitize.outputs.ref_slug }}-${{ github.sha }} + + - name: Upload wheel artifact + uses: actions/upload-artifact@v4 + with: + name: valhalla-wheel-${{ steps.sanitize.outputs.ref_slug }} + path: /tmp/valhalla-dist/*.whl + retention-days: 7 + + - name: Set output + id: set-output + run: echo "wheel_artifact=valhalla-wheel-${{ steps.sanitize.outputs.ref_slug }}" >> $GITHUB_OUTPUT diff --git a/.github/workflows/routing-regression.yml b/.github/workflows/routing-regression.yml index a239adf..de1e118 100644 --- a/.github/workflows/routing-regression.yml +++ b/.github/workflows/routing-regression.yml @@ -4,14 +4,15 @@ on: workflow_dispatch: inputs: valhalla_ref_old: - description: "Valhalla ref for old router (e.g. master)" + description: "Baseline Valhalla ref (the 'before')" default: master + required: true valhalla_ref_new: - description: "Valhalla ref for new router (e.g. PR branch or SHA)" + description: "New Valhalla ref to test (the 'after' — branch, tag, or SHA)" + required: true + tiles_run_id: + description: "Run ID from a successful build-tiles.yml run" required: true - tiles_artifact: - description: "Tiles artifact name to use (e.g. valhalla-tiles-master)" - default: valhalla-tiles-master jobs: build-valhalla-old: @@ -27,16 +28,21 @@ jobs: secrets: inherit run-routes: - runs-on: ubuntu-24.04 + runs-on: ubuntu-latest needs: [build-valhalla-old, build-valhalla-new] strategy: matrix: router: - - ref: ${{ inputs.valhalla_ref_old }} - name: old - - ref: ${{ inputs.valhalla_ref_new }} - name: new + - name: old + ref: ${{ inputs.valhalla_ref_old }} + - name: new + ref: ${{ inputs.valhalla_ref_new }} + steps: + - name: Sanitize ref for artifact name + id: sanitize + run: echo "ref_slug=$(echo '${{ matrix.router.ref }}' | tr '/' '-')" >> $GITHUB_OUTPUT + - name: Checkout RAD uses: actions/checkout@v6 @@ -45,103 +51,80 @@ jobs: with: repository: valhalla/RAD-data path: RAD-data + token: ${{ secrets.RAD_DATA_TOKEN }} - - name: Checkout Valhalla at router ref - uses: actions/checkout@v6 - with: - repository: valhalla/valhalla - ref: ${{ matrix.router.ref }} - submodules: recursive - path: valhalla-src - - - name: Download tiles artifact - # TODO: when tiles come from a previous run, actions/download-artifact@v4 - # only fetches from the current run - needs cross-run solution via GitHub API + - name: Download Valhalla wheel uses: actions/download-artifact@v4 with: - name: ${{ inputs.tiles_artifact }} - path: valhalla_tiles/ + name: valhalla-wheel-${{ steps.sanitize.outputs.ref_slug }} + path: /tmp/valhalla-dist - - name: Restore ccache - uses: tespkg/actions-cache/restore@v1 - with: - endpoint: ${{ secrets.HETZNER_S3_ENDPOINT }} - accessKey: ${{ secrets.HETZNER_S3_ACCESS_KEY }} - secretKey: ${{ secrets.HETZNER_S3_ACCESS_SECRET }} - bucket: rad-cache - path: ~/.cache/ccache - key: ccache-valhalla-${{ matrix.router.ref }} - restore-keys: ccache-valhalla-master - - - name: Install dependencies - run: bash valhalla-src/scripts/install-linux-deps.sh - - - name: Build Valhalla at router ref + - name: Install Valhalla from wheel + run: pip install /tmp/valhalla-dist/*.whl + + - name: Download tiles from build-tiles run + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | - cmake -B valhalla-src/build -S valhalla-src \ - -DCMAKE_BUILD_TYPE=Release \ - -DENABLE_PYTHON_BINDINGS=ON \ - -DENABLE_SERVICES=OFF \ - -DENABLE_TESTS=OFF \ - -DENABLE_BENCHMARKS=OFF \ - -DENABLE_CCACHE=ON \ - -DENABLE_TOOLS=OFF \ - -DENABLE_GEOTIFF=OFF \ - -DENABLE_LZ4=OFF - make -C valhalla-src/build -j$(nproc) - sudo make -C valhalla-src/build install - - - name: Save ccache - if: always() - uses: tespkg/actions-cache/save@v1 - with: - endpoint: ${{ secrets.HETZNER_S3_ENDPOINT }} - accessKey: ${{ secrets.HETZNER_S3_ACCESS_KEY }} - secretKey: ${{ secrets.HETZNER_S3_ACCESS_SECRET }} - bucket: rad-cache - path: ~/.cache/ccache - key: ccache-valhalla-${{ matrix.router.ref }} + gh run download ${{ inputs.tiles_run_id }} \ + --repo "${{ github.repository }}" \ + --pattern "valhalla-tiles-*" \ + --dir valhalla_tiles + shopt -s dotglob + mv valhalla_tiles/valhalla-tiles-*/* valhalla_tiles/ 2>/dev/null || true - name: Run route requests - # TODO: implement scripts/run_routes.py - # reads RAD-data/requests/requests.jsonl - # uses pyvalhalla bindings built from source - # writes to RAD-data/responses/${{ matrix.router.name }}.jsonl run: | - echo "TODO: python3 scripts/run_routes.py \ + valhalla_build_config \ + --mjolnir-tile-dir "$(pwd)/valhalla_tiles" \ + > /tmp/valhalla.json + python3 scripts/run_routes.py \ + --config /tmp/valhalla.json \ --requests RAD-data/requests/requests.jsonl \ - --tiles valhalla_tiles/ \ - --output RAD-data/responses/${{ matrix.router.name }}.jsonl" + --output /tmp/responses-${{ matrix.router.name }}.jsonl - - name: Push responses to RAD-data - # TODO: implement scripts/push_results.py - # race condition risk if both matrix jobs push simultaneously — - # consider pushing responses as GHA artifacts instead, let diff-and-store handle RAD-data push - run: | - echo "TODO: python3 scripts/push_results.py --repo RAD-data --stage responses" + - name: Upload responses artifact + uses: actions/upload-artifact@v4 + with: + name: responses-${{ matrix.router.name }} + path: /tmp/responses-${{ matrix.router.name }}.jsonl + retention-days: 7 diff-and-store: - runs-on: ubuntu-24.04 + runs-on: ubuntu-latest needs: run-routes - if: always() + permissions: + contents: write + steps: + - name: Checkout RAD + uses: actions/checkout@v6 + - name: Checkout RAD-data uses: actions/checkout@v6 with: repository: valhalla/RAD-data path: RAD-data + token: ${{ secrets.GITHUB_TOKEN }} - - name: Compute diff - # TODO: implement scripts/diff_responses.py - # reads RAD-data/responses/old.jsonl and new.jsonl - # writes RAD-data/diffs/.json - run: | - echo "TODO: python3 scripts/diff_responses.py \ - --old RAD-data/responses/old.jsonl \ - --new RAD-data/responses/new.jsonl \ - --output RAD-data/diffs/${{ github.run_id }}.json" + - name: Download responses + uses: actions/download-artifact@v4 + with: + pattern: responses-* + path: /tmp/responses + merge-multiple: false - - name: Push diff to RAD-data - # TODO: implement scripts/push_results.py + - name: Compute diff and push to RAD-data run: | - echo "TODO: python3 scripts/push_results.py --repo RAD-data --stage diff" + python3 scripts/diff_responses.py \ + --old /tmp/responses/responses-old/responses-old.jsonl \ + --new /tmp/responses/responses-new/responses-new.jsonl \ + --old-ref "${{ inputs.valhalla_ref_old }}" \ + --new-ref "${{ inputs.valhalla_ref_new }}" \ + --output RAD-data/diffs/${{ github.run_id }}.json + cd RAD-data + git config user.name "github-actions[bot]" + git config user.email "github-actions[bot]@users.noreply.github.com" + git add diffs/${{ github.run_id }}.json + git commit -m "regression: ${{ inputs.valhalla_ref_old }} vs ${{ inputs.valhalla_ref_new }} (run ${{ github.run_id }})" + git push diff --git a/scripts/diff_responses.py b/scripts/diff_responses.py new file mode 100644 index 0000000..2fe63b2 --- /dev/null +++ b/scripts/diff_responses.py @@ -0,0 +1,68 @@ +#!/usr/bin/env python3 +""" +Usage: + python3 scripts/diff_responses.py \ + --old /tmp/responses/responses-old/responses-old.jsonl \ + --new /tmp/responses/responses-new/responses-new.jsonl \ + --old-ref master \ + --new-ref feature-branch \ + --output RAD-data/diffs/12345678.json +""" + +import argparse +import json +from datetime import UTC, datetime + + +def load_jsonl(path): + return [json.loads(line) for line in open(path)] + + +def diff_entry(old, new): + # TODO: expand with geometry comparison, maneuver diffs, etc. + old_dur = old["response"].get("trip", {}).get("summary", {}).get("time", None) + new_dur = new["response"].get("trip", {}).get("summary", {}).get("time", None) + return { + "request": old["request"], + "old_duration": old_dur, + "new_duration": new_dur, + "duration_delta_s": (new_dur - old_dur) if (old_dur and new_dur) else None, + "old_status": old["status"], + "new_status": new["status"], + } + + +def main(): + p = argparse.ArgumentParser() + p.add_argument("--old", required=True) + p.add_argument("--new", required=True) + p.add_argument("--old-ref", required=True) + p.add_argument("--new-ref", required=True) + p.add_argument("--output", required=True) + args = p.parse_args() + + old_rows = load_jsonl(args.old) + new_rows = load_jsonl(args.new) + + diffs = [diff_entry(o, n) for o, n in zip(old_rows, new_rows, strict=False)] + changed = [d for d in diffs if d["duration_delta_s"] not in (None, 0)] + + result = { + "meta": { + "old_ref": args.old_ref, + "new_ref": args.new_ref, + "generated_at": datetime.now(UTC).isoformat(), + "total_requests": len(diffs), + "changed_routes": len(changed), + }, + "diffs": diffs, + } + + with open(args.output, "w") as f: + json.dump(result, f, indent=2) + + print(f"Done: {len(changed)}/{len(diffs)} routes changed") + + +if __name__ == "__main__": + main() diff --git a/scripts/run_routes.py b/scripts/run_routes.py new file mode 100644 index 0000000..bc60e3f --- /dev/null +++ b/scripts/run_routes.py @@ -0,0 +1,39 @@ +#!/usr/bin/env python3 +""" +Usage: + python3 scripts/run_routes.py \ + --config /tmp/valhalla.json \ + --requests RAD-data/requests/requests.jsonl \ + --output /tmp/responses-old.jsonl +""" + +import argparse +import json + +import valhalla + + +def main(): + p = argparse.ArgumentParser() + p.add_argument("--config", required=True) + p.add_argument("--requests", required=True) + p.add_argument("--output", required=True) + args = p.parse_args() + + config = args.config + actor = valhalla.Actor(config) + + with open(args.requests) as req_f, open(args.output, "w") as out_f: + for line in req_f: + request = json.loads(line) + try: + response = json.loads(actor.route(json.dumps(request))) + status = "ok" + except Exception as e: + response = {"error": str(e)} + status = "error" + out_f.write(json.dumps({"request": request, "response": response, "status": status}) + "\n") + + +if __name__ == "__main__": + main()