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

Tests failing on Alpine Linux #583

Closed
russkel opened this issue Mar 26, 2020 · 11 comments
Closed

Tests failing on Alpine Linux #583

russkel opened this issue Mar 26, 2020 · 11 comments
Labels
test Test related issues

Comments

@russkel
Copy link

russkel commented Mar 26, 2020

Hi, I am trying to compile the pyproj library on Alpine Linux. I filed a few bug fixes with the proj project (and musl libc) that were all fixed enabling the proj library to compile and pass tests on Alpine Linux 32/64b on a number of architectures. I am not having similar luck with pyproj though.

Problem description

Please see the attached build and test log, there are a number of failures:

job.log

Failures

=================================== FAILURES ===================================
_______________________________ test_datum[Proj] _______________________________

proj_class = <class 'pyproj.proj.Proj'>, aoi_data_directory = None

    @pytest.mark.parametrize("proj_class", [Proj, CRS])
    def test_datum(proj_class, aoi_data_directory):
        p1 = proj_class(proj="latlong", datum="WGS84")
        s_1 = -111.5
        s_2 = 45.25919444444
        p2 = proj_class(proj="utm", zone=10, datum="NAD27")
        x2, y2 = transform(p1, p2, s_1, s_2)
        if LooseVersion(proj_version_str) < LooseVersion("6.3.0"):
            assert_almost_equal((x2, y2), (1402291.0833290431, 5076289.591846835))
        else:
            # https://github.com/OSGeo/PROJ/issues/1808
>           assert_almost_equal((x2, y2), (1402285.9829252, 5076292.4212746))
E           AssertionError: 
E           Arrays are not almost equal to 7 decimals
E           
E           Mismatched elements: 2 / 2 (100%)
E           Max absolute difference: 4.21450818
E           Max relative difference: 1.82410064e-06
E            x: array([1402288.540836 , 5076296.6357828])
E            y: array([1402285.9829252, 5076292.4212746])

test/test_datum.py:20: AssertionError
_______________________________ test_datum[CRS] ________________________________

proj_class = <class 'pyproj.crs.crs.CRS'>, aoi_data_directory = None

    @pytest.mark.parametrize("proj_class", [Proj, CRS])
    def test_datum(proj_class, aoi_data_directory):
        p1 = proj_class(proj="latlong", datum="WGS84")
        s_1 = -111.5
        s_2 = 45.25919444444
        p2 = proj_class(proj="utm", zone=10, datum="NAD27")
        x2, y2 = transform(p1, p2, s_1, s_2)
        if LooseVersion(proj_version_str) < LooseVersion("6.3.0"):
            assert_almost_equal((x2, y2), (1402291.0833290431, 5076289.591846835))
        else:
            # https://github.com/OSGeo/PROJ/issues/1808
>           assert_almost_equal((x2, y2), (1402285.9829252, 5076292.4212746))
E           AssertionError: 
E           Arrays are not almost equal to 7 decimals
E           
E           Mismatched elements: 2 / 2 (100%)
E           Max absolute difference: 4.21450818
E           Max relative difference: 1.82410064e-06
E            x: array([1402288.540836 , 5076296.6357828])
E            y: array([1402285.9829252, 5076292.4212746])

test/test_datum.py:20: AssertionError
________________________________ test_doctests _________________________________

aoi_data_directory = None

    def test_doctests(aoi_data_directory):
        """run the examples in the docstrings using the doctest module"""
    
        with warnings.catch_warnings():
            warnings.filterwarnings(
                "ignore",
                "You will likely lose important projection information when",
                UserWarning,
            )
    
            failure_count_proj, test_count = doctest.testmod(pyproj.proj, verbose=True)
            failure_count_crs, test_count_crs = doctest.testmod(pyproj.crs, verbose=True)
            failure_count_geod, test_count_geod = doctest.testmod(pyproj.geod, verbose=True)
            failure_count_transform, test_count_transform = doctest.testmod(
                pyproj.transformer, verbose=True
            )
    
        failure_count = (
            failure_count_proj
            + failure_count_crs
            + failure_count_geod
            + failure_count_transform
        )
        # Missing shapely wheels for Windows, non x86_64 platforms, and python 3.8
        expected_failure_count = 0
        try:
            import shapely  # noqa
        except ImportError:
            if (
                os.name == "nt"
                or platform.uname()[4] != "x86_64"
                or (sys.version_info.major, sys.version_info.minor) >= (3, 8)
            ):
                expected_failure_count = 6
    
        # if the below line fails, doctests have failed
>       assert (
            failure_count == expected_failure_count
        ), "{0} of the doctests in " "lib/pyproj/__init__.py failed".format(failure_count)
E       AssertionError: 9 of the doctests in lib/pyproj/__init__.py failed
E       assert 9 == 6

test/test_doctest_wrapper.py:50: AssertionError
2 items had failures:
   3 of   5 in pyproj.geod.Geod.geometry_area_perimeter
   3 of   5 in pyproj.geod.Geod.geometry_length
2 items had failures:
   1 of   3 in pyproj.transformer.TransformerGroup.__init__
   2 of  19 in pyproj.transformer.transform
FAILED test/test_datum.py::test_datum[Proj] - AssertionError: 
FAILED test/test_datum.py::test_datum[CRS] - AssertionError: 
FAILED test/test_doctest_wrapper.py::test_doctests - AssertionError: 9 of the...
FAILED test/test_transformer.py::test_transform_wgs84_to_alaska - AssertionEr...
FAILED test/test_transformer.py::test_repr - AssertionError: assert '<Concate...
FAILED test/test_transformer.py::test_transformer_group__unavailable - assert...
FAILED test/test_transformer.py::test_transform_group__missing_best - assert ...
FAILED test/crs/test_crs.py::test_coordinate_operation_grids__alternative_grid_name

Expected Output

All tests passing =)

Environment Information

Shown in build log. Errors also occur on other architectures.

(9/39) Installing python3 (3.8.2-r0)
(17/39) Installing proj-datumgrid (7.0.0-r0)
(20/39) Installing proj (7.0.0-r0)
(21/39) Installing proj-dev (7.0.0-r0)

Installation method

From source

@russkel russkel added the bug label Mar 26, 2020
@snowman2 snowman2 added test Test related issues and removed bug labels Mar 26, 2020
@snowman2
Copy link
Member

@russkel, all the failing tests are expected. Currently the tests are based on proj-datumgrid-1.8 as that is the last grid set that works with PROJ 6:

curl http://download.osgeo.org/proj/proj-datumgrid-1.8.zip > proj-datumgrid-1.8.zip

The failing tests are because the behavior is different with the new grids. I don't see any incorrect behavior from pyproj, so I think you are okay to proceed.

This will likely be addressed in #530, however the tests could also check for the existence of the new grids in the data directory for the tests.

@russkel
Copy link
Author

russkel commented Mar 26, 2020

Hi @snowman2, thanks for your reply!

I just checked the proj build recipe (https://gitlab.alpinelinux.org/alpine/aports/blob/master/community/proj/APKBUILD) and it looks like it's still using the 1.8 datum grids as pyproj does. Am I misunderstanding?

@snowman2
Copy link
Member

@russkel, that is interesting. I assumed you were using the latest grids. What is inside the proj-datumgrid package? It seems like that is installed separately and I am wondering if it is adding additional grids. I wonder if you run the tests without the proj-datumgrid package if the pyproj tests pass.

@snowman2
Copy link
Member

Grids in the wheel:

$ unzip -l dist/pyproj-2.6.0-cp38-cp38-manylinux1_x86_64.whl
Archive:  dist/pyproj-2.6.0-cp38-cp38-manylinux1_x86_64.whl
  Length      Date    Time    Name
---------  ---------- -----   ----
... 
    7048  2020-03-18 00:51   pyproj/proj_dir/share/proj/stpaul
     6385  2020-03-18 00:51   pyproj/proj_dir/share/proj/nad.lst
   318464  2020-03-18 00:51   pyproj/proj_dir/share/proj/nzgd2kgrid0005.gsb
    19535  2020-03-18 00:51   pyproj/proj_dir/share/proj/nad27
    83696  2020-03-18 00:51   pyproj/proj_dir/share/proj/BETA2007.gsb
    11112  2020-03-18 00:51   pyproj/proj_dir/share/proj/WO
   277424  2020-03-18 00:51   pyproj/proj_dir/share/proj/ntf_r93.gsb
  1113184  2020-03-18 00:51   pyproj/proj_dir/share/proj/ntv1_can.dat
  1053928  2020-03-18 00:51   pyproj/proj_dir/share/proj/alaska
     7079  2020-03-18 00:51   pyproj/proj_dir/share/proj/world
   452008  2020-03-18 00:51   pyproj/proj_dir/share/proj/hawaii
     3660  2020-03-18 00:51   pyproj/proj_dir/share/proj/ITRF2008
  4153000  2020-03-18 00:51   pyproj/proj_dir/share/proj/egm96_15.gtx
    26728  2020-03-18 00:51   pyproj/proj_dir/share/proj/stlrnc
   264424  2020-03-18 00:51   pyproj/proj_dir/share/proj/conus
     2099  2020-03-18 00:51   pyproj/proj_dir/share/proj/ITRF2000
     1183  2020-03-18 00:51   pyproj/proj_dir/share/proj/CH
     3915  2020-03-18 00:51   pyproj/proj_dir/share/proj/other.extra
      232  2020-03-18 00:51   pyproj/proj_dir/share/proj/null
     3560  2020-03-18 00:51   pyproj/proj_dir/share/proj/MD
    32060  2020-03-18 00:51   pyproj/proj_dir/share/proj/projjson.schema.json
     6760  2020-03-18 00:51   pyproj/proj_dir/share/proj/WI
     4424  2020-03-18 00:51   pyproj/proj_dir/share/proj/TN
      728  2020-03-18 00:51   pyproj/proj_dir/share/proj/GL27
    26728  2020-03-18 00:51   pyproj/proj_dir/share/proj/prvi
    59208  2020-03-18 00:51   pyproj/proj_dir/share/proj/stgeorge
     3468  2020-03-18 00:51   pyproj/proj_dir/share/proj/ITRF2014
     8872  2020-03-18 00:51   pyproj/proj_dir/share/proj/FL
  6168576  2020-03-18 00:51   pyproj/proj_dir/share/proj/proj.db
    16593  2020-03-18 00:51   pyproj/proj_dir/share/proj/nad83
...   
---------                     -------
 25403377                     63 files

@snowman2
Copy link
Member

Alpine linux package: https://pkgs.alpinelinux.org/contents?branch=edge&name=proj-datumgrid&arch=x86_64&repo=community


File | Package | Branch | Repository | Architecture
-- | -- | -- | -- | --
/usr/share/proj/proj.ini | proj-datumgrid | edge | community | x86_64
/usr/share/proj/ntf_r93.gsb | proj-datumgrid | edge | community | x86_64
/usr/share/proj/egm96_15.gtx | proj-datumgrid | edge | community | x86_64
/usr/share/proj/proj.db | proj-datumgrid | edge | community | x86_64
/usr/share/proj/CH | proj-datumgrid | edge | community | x86_64
/usr/share/proj/nad.lst | proj-datumgrid | edge | community | x86_64
/usr/share/proj/GL27 | proj-datumgrid | edge | community | x86_64
/usr/share/proj/ITRF2008 | proj-datumgrid | edge | community | x86_64
/usr/share/proj/nad83 | proj-datumgrid | edge | community | x86_64
/usr/share/proj/ITRF2014 | proj-datumgrid | edge | community | x86_64
/usr/share/proj/ITRF2000 | proj-datumgrid | edge | community | x86_64
/usr/share/proj/nad27 | proj-datumgrid | edge | community | x86_64
/usr/share/proj/other.extra | proj-datumgrid | edge | community | x86_64
/usr/share/proj/nzgd2kgrid0005.gsb | proj-datumgrid | edge | community | x86_64
/usr/share/proj/world | proj-datumgrid | edge | community | x86_64
/usr/share/proj/BETA2007.gsb

Unless I am missing something (which is definitely possible), it looks like the alpine linux package is missing grids.

@snowman2
Copy link
Member

v3.11 seems to have all of the grids: https://pkgs.alpinelinux.org/contents?file=&path=&name=proj-datumgrid&branch=v3.11&repo=community&arch=x86_64

Mind checking what is in your /usr/share/proj/ directory?

@russkel
Copy link
Author

russkel commented Mar 27, 2020

Mind checking what is in your /usr/share/proj/ directory?

This is a CI build, so it will be a fresh install. I will modify the build script to temporarily list the contents of that folder:

-rw-r--r--    1 root     root         83696 Mar  1 11:38 BETA2007.gsb
-rw-r--r--    1 root     root          1183 Mar  1 11:38 CH
-rw-r--r--    1 root     root           728 Mar  1 11:38 GL27
-rw-r--r--    1 root     root          2099 Mar  1 11:38 ITRF2000
-rw-r--r--    1 root     root          3660 Mar  1 11:38 ITRF2008
-rw-r--r--    1 root     root          3468 Mar  1 11:38 ITRF2014
-rw-r--r--    1 root     root       4153000 Mar  1 11:38 egm96_15.gtx
-rw-r--r--    1 root     root          6385 Mar  1 11:38 nad.lst
-rw-r--r--    1 root     root         19535 Mar  1 11:38 nad27
-rw-r--r--    1 root     root         16593 Mar  1 11:38 nad83
-rw-r--r--    1 root     root        277424 Mar  1 11:38 ntf_r93.gsb
-rw-r--r--    1 root     root        318464 Mar  1 11:38 nzgd2kgrid0005.gsb
-rw-r--r--    1 root     root          3915 Mar  1 11:38 other.extra
-rw-r--r--    1 root     root       6221824 Mar  1 11:38 proj.db
-rw-r--r--    1 root     root           354 Mar  1 11:38 proj.ini
-rw-r--r--    1 root     root          7079 Mar  1 11:38 world

I compared the edge and 3.11 (https://gitlab.alpinelinux.org/alpine/aports/blob/3.11-stable/community/proj/APKBUILD) build files for the datum grid package and they both use the same tar.gz with the same sha. It's possible I broke something when I 'fixed' the build script to build on all platforms, yiikes.

To answer your question, that package is built by moving /usr/share/proj into that package.

I will investigate further, thanks.

@russkel
Copy link
Author

russkel commented Mar 27, 2020

The only difference between proj in 3.11 and edge in this case is I switched to using CMake instead of autoconf. It's possible it's not installing all the gridfiles?

@snowman2
Copy link
Member

Yes, I have had issues with missing grids using cmake in the past.

@russkel
Copy link
Author

russkel commented Mar 27, 2020

Yes, I have had issues with missing grids using cmake in the past.

Right. I will look into it. I thought CMake would have been the more relevant one to use 🤦‍♂️

@russkel
Copy link
Author

russkel commented Mar 27, 2020

Tests pass fine once I fixed the proj-datumgrid package. Sorry for wasting your time @snowman2 and thanks for your help!

pyproj should be merged into alpine edge soon.

@russkel russkel closed this as completed Mar 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
test Test related issues
Projects
None yet
Development

No branches or pull requests

2 participants