From 8d32b524758dd2e9513247b90118bfd1f396cd58 Mon Sep 17 00:00:00 2001 From: Derek Dohler Date: Thu, 8 Jul 2021 11:35:30 -0400 Subject: [PATCH 1/5] Add GitHub Actions CI Includes release and CI workflows --- .github/workflows/continuous_integration.yml | 47 ++++++++++++++++++++ .github/workflows/release.yml | 34 ++++++++++++++ 2 files changed, 81 insertions(+) create mode 100644 .github/workflows/continuous_integration.yml create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/continuous_integration.yml b/.github/workflows/continuous_integration.yml new file mode 100644 index 0000000..82b28d3 --- /dev/null +++ b/.github/workflows/continuous_integration.yml @@ -0,0 +1,47 @@ +name: CI + +on: + push: + branches: + - develop + - master + pull_request: + +jobs: + build: + name: build + runs-on: ubuntu-latest + strategy: + matrix: + python-version: ["3.6", "3.7", "3.8"] + steps: + - uses: actions/checkout@v2 + + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + + - name: Cache dependencies + uses: actions/cache@v2 + with: + path: ~/.cache/pip + key: pip-${{ hashFiles('setup.cfg') }}-${{ hashFiles('tox.ini') }} + restore-keys: pip- + + - name: Install packages + run: pip install flake8 + + - name: Lint + run: flake8 + + - name: Run tests + run: python setup.py test + env: + BING_MAPS_API_KEY: ${{ secrets.BING_MAPS_API_KEY }} + ESRI_CLIENT_ID: ${{ secrets.ESRI_CLIENT_ID }} + ESRI_CLIENT_SECRET: ${{ secrets.ESRI_CLIENT_SECRET }} + GOOGLE_API_KEY: ${{ secrets.GOOGLE_API_KEY }} + MAPQUEST_API_KEY: ${{ secrets.MAPQUEST_API_KEY }} + PELIAS_API_KEY: ${{ secrets.PELIAS_API_KEY }} + diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..5b3f529 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,34 @@ +name: Release + +on: + push: + tags: + - "*" + +jobs: + release: + name: release + runs-on: ubuntu-latest + steps: + - name: Checkout commit and fetch tag history + uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - name: Set up Python 3.x + uses: actions/setup-python@v2 + with: + python-version: "3.x" + + - name: Install release dependencies + run: | + python -m pip install --upgrade pip + pip install setuptools wheel twine + + - name: Build and publish package + env: + TWINE_USERNAME: ${{ secrets.PYPI_AZAVEA_USERNAME }} + TWINE_PASSWORD: ${{ secrets.PYPI_AZAVEA_PASSWORD }} + run: | + python setup.py sdist bdist_wheel + twine upload dist/* From 277d20e9249767fad6aff09182e2be39733415fe Mon Sep 17 00:00:00 2001 From: Derek Dohler Date: Thu, 8 Jul 2021 11:36:35 -0400 Subject: [PATCH 2/5] Remove travis-ci.org configuration --- .travis.yml | 25 ------------------------- 1 file changed, 25 deletions(-) delete mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index e8c2dc9..0000000 --- a/.travis.yml +++ /dev/null @@ -1,25 +0,0 @@ -language: python - -sudo: false - -python: - - '2.7' - - '3.6' - -before_script: - - pip install flake8 - -script: - - flake8 - - python setup.py test - -deploy: - provider: pypi - user: azavea - password: - secure: Wc/aboeIntZeqgCSIOrd/66vceukY/KmdSLwcLB9gn7kRWRqOM+HiEX9+lJe4IKtMisz3zgRqZNAFJU/UUBBwuclHpbtQtV0FCQOFXEwUHQfouzAvVu/3C4fBgQeoet5KrJFo7OVUmYwyWPm8vJzWIraQWVfsR9Gv/AQBQdfuec= - on: - tags: true - python: '3.6' - distributions: sdist bdist_wheel - repo: azavea/python-omgeo From 474e65358bedd1003f52a33954986c1bd365ed67 Mon Sep 17 00:00:00 2001 From: Derek Dohler Date: Thu, 8 Jul 2021 13:33:25 -0400 Subject: [PATCH 3/5] Increase US Census geocoder timeout The default is 10 seconds and sometimes it's slower than that, which causes test failures. --- .github/workflows/continuous_integration.yml | 7 ++++++- omgeo/tests/tests.py | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/.github/workflows/continuous_integration.yml b/.github/workflows/continuous_integration.yml index 82b28d3..ceadde8 100644 --- a/.github/workflows/continuous_integration.yml +++ b/.github/workflows/continuous_integration.yml @@ -13,7 +13,12 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: ["3.6", "3.7", "3.8"] + # TODO: Running the full matrix seems to make the US Census Geocoder + # more likely to return errors; running a single one is more likely + # to succeed. This is disabled temporarily. Tracking issue: + # https://github.com/azavea/python-omgeo/issues/66 + # python-version: ["3.6", "3.7", "3.8"] + python-version: ["3.8"] steps: - uses: actions/checkout@v2 diff --git a/omgeo/tests/tests.py b/omgeo/tests/tests.py index bc3b2ec..9e97979 100755 --- a/omgeo/tests/tests.py +++ b/omgeo/tests/tests.py @@ -128,7 +128,7 @@ def setUp(self): if MAPQUEST_API_KEY is not None: # MapQuest's open Nominatime API now also requires a key self.g_nom = Geocoder([['omgeo.services.Nominatim', {}]]) - self.g_census = Geocoder([['omgeo.services.USCensus', {}]]) + self.g_census = Geocoder([['omgeo.services.USCensus', {'settings': {'timeout': 30}}]]) ESRI_WGS_LOCATOR_MAP = {'PointAddress': 'rooftop', 'StreetAddress': 'interpolation', From 0fbd9a50b85d905c455dc419ba6c5f72b85a3d7e Mon Sep 17 00:00:00 2001 From: Derek Dohler Date: Fri, 2 Jul 2021 11:07:14 -0400 Subject: [PATCH 4/5] Use RegionAbbr for match_region with Esri WGS Previously, we were using Region with Esri WGS, but this field provides the full name of the region, e.g. "Pennsylvania", rather than the abbrevation ("PA"), which is what most people expect. Additionally, we use the equivalent field to RegionAbbr from the Google geocoder ("short_name"), so this brings the behavior of the two sources closer together (though neither provides documentation regarding what format RegionAbbr or short_name uses, so they may not match in all cases). --- omgeo/services/esri.py | 4 ++-- omgeo/tests/tests.py | 10 ++++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/omgeo/services/esri.py b/omgeo/services/esri.py index add68f2..437bd9d 100644 --- a/omgeo/services/esri.py +++ b/omgeo/services/esri.py @@ -126,7 +126,7 @@ def _geocode(self, pq): # 'AddBldg', 'City', 'Subregion', - 'Region', + 'RegionAbbr', 'Postal', 'Country', # 'Ymax', @@ -205,7 +205,7 @@ def _geocode(self, pq): # Optional address component fields. for in_key, out_key in [('City', 'match_city'), ('Subregion', 'match_subregion'), - ('Region', 'match_region'), ('Postal', 'match_postal'), + ('RegionAbbr', 'match_region'), ('Postal', 'match_postal'), ('Country', 'match_country')]: setattr(c, out_key, attributes.get(in_key, '')) setattr(c, 'match_streetaddr', self._street_addr_from_response(attributes)) diff --git a/omgeo/tests/tests.py b/omgeo/tests/tests.py index 9e97979..bd133a0 100755 --- a/omgeo/tests/tests.py +++ b/omgeo/tests/tests.py @@ -224,6 +224,16 @@ def test_geocode_esri_wgs_auth(self): candidates = self.g_esri_wgs_auth.get_candidates(self.pq['azavea']) self.assertOneCandidate(candidates) + def test_esri_short_region(self): + """Ensure that Esri uses region abbreviations""" + candidate = self.g_esri_wgs.get_candidates(self.pq["azavea"])[0] + self.assertEqual(candidate.match_region, "PA") + + def test_google_short_region(self): + """Ensure that Google uses region abbreviations""" + candidate = self.g_google.get_candidates(self.pq["azavea"])[0] + self.assertEqual(candidate.match_region, "PA") + @unittest.skipIf(BING_MAPS_API_KEY is None, BING_KEY_REQUIRED_MSG) def test_geocode_bing(self): """Test Azavea's address using Bing geocoder""" From 052c82524f3ed8db3b51824c7be5a53832c8521e Mon Sep 17 00:00:00 2001 From: Derek Dohler Date: Tue, 20 Jul 2021 15:07:03 -0400 Subject: [PATCH 5/5] Update CHANGES.rst for 6.1.0 --- CHANGES.rst | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGES.rst b/CHANGES.rst index dc6441b..71f67db 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -222,3 +222,9 @@ v6.0.3, 2019-10-14 v6.0.4, 2019-12-19 ------------------ * Fix template string error in AttrListIncludes and AttrListExcludes __repr__ + +v6.1.0, 2021-07-20 +------------------ + * Populate match_region using RegionAbbr rather than Region from EsriWGS. For + example, when using the EsriWGS geocoder, expect 'PA' rather than + 'Pennsylvania' in match_region.