OpenDataAnalytics / gaia

Gaia is a geospatial analysis library jointly developed by Kitware and Epidemico.
31 stars 15 forks source link

modified to use conda for install in tests #80

Closed snowman2 closed 7 years ago

snowman2 commented 7 years ago

Initial attempt to trigger builds on Travis-CI.

aashish24 commented 7 years ago

@snowman2 thanks for pushing this PR. We can help getting this merged into master @mbertrand

snowman2 commented 7 years ago

That would be great. The tests passed on my Ubuntu machine (16.04). However, I haven't had time to work on it further to get the build/tests working on Travis and any help to get this working would be appreciated.

mbertrand commented 7 years ago

Hi @snowman2, it looks like one of the unit tests is failing:

======================================================================
ERROR: test_zonalstats (tests.cases.test_processors.TestGaiaProcessors)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "tests/cases/test_processors.py", line 70, in test_zonalstats
    process.compute()
  File "gaia/geo/processes_vector.py", line 1235, in compute
    self.inputs[0].read())
  File "gaia/geo/gdal_functions.py", line 445, in gdal_zonalstats
    return list(gen_zonalstats(zones, raster))
  File "gaia/geo/gdal_functions.py", line 581, in gen_zonalstats
    if hasattr(median, 'data') and not numpy.isnan(median.data):
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()

Is it necessary for conda compatibility to remove the version numbers in requirements.txt? Pinning the versions of dependencies protects against bugs or incompatibilities in newly released versions, so I'm not very comfortable with getting rid of them.

snowman2 commented 7 years ago

As seen in the previous commits, installing your code requires removing the pins. I added them back in requirements.txt for reference. There are ways to add pins in the conda_env.yml, but it seems you need to update gaia to use the most recent versions of the packages to be compatible with conda.

mbertrand commented 7 years ago

@snowman2 I'm fine with not having pinned versions in setup.py & conda_env.yaml as long as they're still in requirements.txt

For the failing travis test, try replacing these lines in gdal_functions.gen_zonalstats with this:

                median = numpy.ma.median(zoneraster)
                if hasattr(median, 'data'):
                    try:
                        properties['median'] = median.data.item()
                    except AttributeError:
                        if median:
                            properties['median'] = median
snowman2 commented 7 years ago

If y'all are interested in testing on windows, I added an appveyor.yml file. For more info: https://www.appveyor.com.

snowman2 commented 7 years ago

Looks like tests pass. But the flake test fails due to complexity.

mbertrand commented 7 years ago

Thanks @snowman2, looks great! For the failing complexity test, feel free to increase the value of "max-complexity" in the flake8.cfg file to 25 or 30.

snowman2 commented 7 years ago

Good news: With conda the OSX and linux builds are passing. And you now have tests for python 2.7 and 3.5. Next step, Windows.

mbertrand commented 7 years ago

@snowman2 sounds good, would you like us to merge the PR now or wait until the Windows build is in?

snowman2 commented 7 years ago

That is up to you. I have the appveyor.yml in there. However, I think it would be better for y'all to set up the build in Appveyor so you have control over the account.

mbertrand commented 7 years ago

Thanks, @snowman2. @aashish24 I think this is good to go. Does kitware have an appveyor account?

aashish24 commented 7 years ago

Does kitware have an appveyor account?

No, we do not.

aashish24 commented 7 years ago

I will create one today @snowman2 @mbertrand

aashish24 commented 7 years ago

thank you @snowman2 @mbertrand