Geocoding in Airflow, Dagster and Prefect

One step: a CSV in, the same CSV with the answer columns out, and a receipt of the run. The country file is local, so no address leaves the machine that runs the step.

New Geocode addresses R, Spark, BI Python

Install

terminalpip
$ pip install "gridpin-orchestrators[airflow] @ git+https://github.com/gridpin/gridpin@v0.10.0#subdirectory=integrations/orchestrators"
$ python -c 'import gridpin; print(gridpin.sheets.fetch("us"))'   # the country file, once, verified

Use [dagster] or [prefect] for the others. The package is not on PyPI: pip builds it from the folder integrations/orchestrators of the repository.

The step in each orchestrator

dag.pyAirflow
from gridpin_orchestrators.airflow import GridPinGeocodeOperator

GridPinGeocodeOperator(task_id="geocode", input_csv="orders.csv",
                       output_csv="orders_geo.csv", sheet="us", column="address")
assets.pyDagster
from gridpin_orchestrators.dagster import geocoded_csv_asset

orders_geo = geocoded_csv_asset("orders_geo", input="orders.csv",
                                output="orders_geo.csv", sheet="us")
flow.pyPrefect
from prefect import flow
from gridpin_orchestrators.prefect import geocode_csv

@flow
def nightly():
    geocode_csv("orders.csv", "orders_geo.csv", "us", column="address")

What the step leaves

The output file holds every input row and column, then the gp_* columns of batch mode: byte for byte what gridpin batch --column address writes. The receipt counts rows, answers, weak answers and rows without an address: Airflow returns it as the task's XCom, Dagster as the asset's metadata, Prefect as the task result and a table artifact.

Checked by running the step in Airflow 3.4.0, Dagster 1.13.30 and Prefect 3.9.3, each compared with the command line on the same file.