From e554fd5f5189510af7d624752aacc3d8b525056a Mon Sep 17 00:00:00 2001 From: Mark Torrey Date: Wed, 14 Jun 2023 14:53:01 -0400 Subject: [PATCH 1/5] removed unnecessary parallize_on_rows function from multiprocessing example --- examples/pandas-multiprocessing-example.py | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/examples/pandas-multiprocessing-example.py b/examples/pandas-multiprocessing-example.py index a282cde..f95f175 100644 --- a/examples/pandas-multiprocessing-example.py +++ b/examples/pandas-multiprocessing-example.py @@ -1,6 +1,7 @@ # from: https://gist.github.com/ishiland/824ddd386fcd0b90fc55aea573a28b22 # written by ishiland: https://github.com/ishiland -# Minor edits by torreyma: https://github.com/torreyma +# derived from: https://stackoverflow.com/a/53135031/3641153 +# minor edits by torreyma: https://github.com/torreyma # from geosupport import Geosupport, GeosupportError import pandas as pd @@ -14,7 +15,8 @@ # For Windows: g = Geosupport(geosupport_path="C:\\Program Files (x86)\\Geosupport Desktop Edition") -# On linux, geosupport location is set in environment variables GEOFILES and LD_LIBRARY_PATH. +# On linux: comment above line and uncomment line below. Set environment variables GEOFILES and LD_LIBRARY_PATH to indicate location of the fls/ and lib/ directories. +# g = Geosupport() cpus = cpu_count() @@ -52,17 +54,13 @@ def run_on_subset(func, data_subset): return data_subset.apply(func, axis=1) -def parallelize_on_rows(data, func, num_of_processes=cpus): - return parallelize(data, partial(run_on_subset, func), num_of_processes) - - if __name__ == '__main__': # read in csv df = pd.read_csv('INPUT.csv') # add 3 Geosupport columns - Latitude, Longitude and Geosupport message - df[['lat', 'lon', 'msg']] = parallelize_on_rows(df, geo_by_address) + df[['lat', 'lon', 'msg']] = parallelize(df, partial(run_on_subset, geo_by_address)) # output to csv with the 3 new columns. df.to_csv('OUTPUT.csv') From c1d708c34e1c987a69a2716d33dad9de1fe038ac Mon Sep 17 00:00:00 2001 From: Ian Shiland Date: Mon, 31 Mar 2025 15:28:35 -0400 Subject: [PATCH 2/5] add additional dependencies --- examples/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/Dockerfile b/examples/Dockerfile index d58145c..da2cb8f 100644 --- a/examples/Dockerfile +++ b/examples/Dockerfile @@ -1,6 +1,6 @@ FROM nycplanning/docker-geosupport:latest -RUN pip install pandas nyc-parser +RUN pip install pandas nyc-parser tqdm WORKDIR /examples From b9de178e8dc1e28066c0ec0b63a364b0c75ae33b Mon Sep 17 00:00:00 2001 From: Ian Shiland Date: Mon, 31 Mar 2025 15:29:00 -0400 Subject: [PATCH 3/5] ignore output files from examples --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index a185a55..79d3cf1 100644 --- a/.gitignore +++ b/.gitignore @@ -15,3 +15,4 @@ coverage.xml gde/ upg/ docker/ +/examples/output/output-* From 16ad8167c131aab5fee9065a222ef991c47bfd62 Mon Sep 17 00:00:00 2001 From: Ian Shiland Date: Mon, 31 Mar 2025 15:45:50 -0400 Subject: [PATCH 4/5] pin black version to 25.0.1 --- .github/workflows/ci.yml | 2 +- examples/pandas_multiprocessing.py | 2 +- setup.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5f9cace..45fe35a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -98,6 +98,6 @@ jobs: with: python-version: 3.11 - name: Install code quality tools - run: pip install black + run: pip install black==25.0.1 - name: Check code formatting with black run: black --check . diff --git a/examples/pandas_multiprocessing.py b/examples/pandas_multiprocessing.py index 3c4df2e..6ef3b8b 100644 --- a/examples/pandas_multiprocessing.py +++ b/examples/pandas_multiprocessing.py @@ -1,5 +1,5 @@ """ -Example of how to use python-geosupport, Pandas and Multiprocessing to speed up geocoding workflows. +Example of how to use python-geosupport, Pandas and Multiprocessing to speed up geocoding workflows. """ import os diff --git a/setup.py b/setup.py index 4c19eb7..0e00325 100644 --- a/setup.py +++ b/setup.py @@ -51,7 +51,7 @@ extras_require={ "dev": [ "coverage", - "black", + "black==25.0.1", ] }, ) From e84261a410b0c55c73298aff7488f1216e6e271f Mon Sep 17 00:00:00 2001 From: Ian Shiland Date: Mon, 31 Mar 2025 15:49:49 -0400 Subject: [PATCH 5/5] black 25.1.0 --- .github/workflows/ci.yml | 2 +- setup.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 45fe35a..15a4bd4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -98,6 +98,6 @@ jobs: with: python-version: 3.11 - name: Install code quality tools - run: pip install black==25.0.1 + run: pip install black==25.1.0 - name: Check code formatting with black run: black --check . diff --git a/setup.py b/setup.py index 0e00325..c5d4a4a 100644 --- a/setup.py +++ b/setup.py @@ -51,7 +51,7 @@ extras_require={ "dev": [ "coverage", - "black==25.0.1", + "black==25.1.0", ] }, )