← Back to Pull requests

BUG: Download to the PROJ data directory with pyproj sync --system-directory #1673

Merged
alteralto merged 3 files (11 lines) on Nov 16, 2026 21:53 UTC
View on GitHub
alteralto alteralto commented on Nov 07, 2026 00:27 UTC
Author

  • Closes #1672

  • - [x] Tests added
    - [x] Fully documented, including history.rst for all changes and api/*.rst for new API

    get_data_dir() returns one or more directories joined by os.pathsep, and pyproj sync --system-directory split it on os.path.sep instead, as the issue says. The target directory became '' on Linux and the drive letter on Windows, so the grid and files.geojson were written to the current directory

    With the 3.8.0 wheel on Linux (python:3.12-slim) and on Windows, pyproj sync --file us_noaa_alaska --system-directory put both files in the current directory, and with this change they go to pyproj/proj_dir/share/proj. With PROJ_DATA=/pd_a:/pd_b they go to /pd_a, and a hgridshift pipeline on us_noaa_alaska.tif then finds the grid

    test_sync_download__system_directory built the expected directory with the same split(os.path.sep)[0], so it passed with the bug. It now appends a second data directory and checks that the download goes to the first one. It fails without the fix (directory='F:') and passes with it, together with the rest of test_cli.py and test_sync.py

    Diff: 11 lines (+7 / -4) across 3 files Reviewer: djhoese Review duration: 14246m
    All Vouch review confidence checks passed
    Residual risk 0.02 = Change Risk (0.21) × (1 − Review Confidence (0.91)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.21 · 11 lines diff across 3 files
    0.21
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.90 · 5 substantive comment(s)
    0.90
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 50%
    90%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.149
    Real PR Conversation Timeline
    7 items
    codecov[bot] codecov[bot] commented on Nov 14, 2026 03:08 UTC
    Bot

    Codecov Report


    :white_check_mark: All modified and coverable lines are covered by tests.
    :white_check_mark: Project coverage is 95.81%. Comparing base (cce793d) to head (da7f08e).
    :warning: Report is 10 commits behind head on main.

    <details><summary>Additional details and impacted files</summary>

    @@           Coverage Diff           @@
    ##             main    #1673   +/-   ##
    =======================================
      Coverage   95.81%   95.81%           
    =======================================
      Files          20       20           
      Lines        1886     1886           
    =======================================
      Hits         1807     1807           
      Misses         79       79           
    

    </details>

    :umbrella: View full report in Codecov by Harness.
    :loudspeaker: Have feedback on the report? Share it here.
    <details><summary> :rocket: New features to boost your workflow: </summary>

  • :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

  • </details>

    djhoese djhoese commented on code on Nov 14, 2026 03:09 UTC
    Code Review
    test/test_cli.py:1
    @@ -302,11 +302,13 @@ def test_sync_download__directory(
     @patch("pyproj.__main__._download_resource_file")
     @patch("pyproj.sync._load_grid_geojson")
     def test_sync_download__system_directory(
    -    load_grid_geojson_mock, download_mock, parse_args_mock
    +    load_grid_geojson_mock, download_mock, parse_args_mock, tmp_path
     ):
         load_grid_geojson_mock.return_value = _load_grid_geojson()
    -    main()
    -    datadir = get_data_dir().split(os.path.sep)[0]
    +    with proj_env():
    +        datadir = get_data_dir().split(os.pathsep)[0]
    +        append_data_dir(str(tmp_path))

    Why is appending this tmp_path needed? As I revealed in my comments on the issues, I don't know how these functions are supposed to work.

    alteralto alteralto commented on code on Nov 15, 2026 22:44 UTC
    Code Review
    test/test_cli.py:1
    @@ -302,11 +302,13 @@ def test_sync_download__directory(
     @patch("pyproj.__main__._download_resource_file")
     @patch("pyproj.sync._load_grid_geojson")
     def test_sync_download__system_directory(
    -    load_grid_geojson_mock, download_mock, parse_args_mock
    +    load_grid_geojson_mock, download_mock, parse_args_mock, tmp_path
     ):
         load_grid_geojson_mock.return_value = _load_grid_geojson()
    -    main()
    -    datadir = get_data_dir().split(os.path.sep)[0]
    +    with proj_env():
    +        datadir = get_data_dir().split(os.pathsep)[0]
    +        append_data_dir(str(tmp_path))

    get_data_dir() can return several directories joined by os.pathsep, from PROJ_DATA and append_data_dir(), and --system-directory should download into the first one. Appending tmp_path makes sure there are at least two here, so the test checks that sync takes the first directory and not the whole joined string. With a single directory it would also pass if the split were removed altogether

    proj_env() puts the data directory back afterwards, so the extra directory doesn't leak into other tests

    djhoese djhoese commented on Nov 16, 2026 20:33 UTC
    Contributor

    @snowman2 from what I can understand this makes sense to me. You obviously have more experience with this so I'd like you to take a last look before merging.

    snowman2 snowman2 commented on Nov 16, 2026 21:53 UTC
    Contributor

    Confirmed:

    >>> import os
    >>> os.path.sep
    '/'
    >>> os.pathsep
    ':'
    

    The path should be separated by :.

    snowman2 snowman2 commented on Nov 16, 2026 21:53 UTC
    Contributor

    Thanks @alteralto 👍

    Reviewers
    Assignees
    alteralto alteralto
    Labels
    risk: low confidence: 90.8% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 20.8% (LOW) · Higher = larger blast radius
    20.8%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 90.8% · Lower = rushed or shallow review
    90.8%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 2% · Safe to merge
    2%
    Repository