Scraper and transformer utilities for Subsidy Tracker data ingestion.
Project description
st-scrapers
Collection of scrapers that power automated data collection for Subsidy Tracker.
Installation
python -m venv .venv
source .venv/bin/activate
pip install -e .
The editable install exposes the CLI entry points (scraper-manager, st-transformer) and installs all required dependencies (Socrata scraper, storage backends, Beam transformer tooling).
Running the Socrata scraper locally
scraper-manager \
--scraper socrata \
update \
--identifier <4x4-id> \
--domain <data.ny.gov> \
--local-path data/cache/<dataset-folder> \
--download-formats csv
Optional flags:
--last-update <ISO timestamp>(forcheckcommand) tells the manager when you last synced locally.--download-formats csv,jsonlets you pull multiple formats at once.--app-tokencan be set via environment variableSOCRATA_APP_TOKENif needed.
Outputs:
- Scraped files under
--local-path. - Metadata logs (
*.metadata.json,metadata_log.csv,dataset_status.csv).
To write directly into GCS, configure the DAG or manager to use GcsStorageBackend (see storage/backends.py) or set environment variables when running in Composer.
Running the Beam transformer
You can run transformations via the CLI:
python -m transformer.beam_pipeline \
--config tmp/toy_transform.yaml \
--transform transformer.transforms.sample:clean_csv
Override config values with flags:
python -m transformer.beam_pipeline \
--config configs/job.yaml \
--runner DataflowRunner \
--project my-project \
--region us-central1 \
--temp-location gs://my-bucket/temp
This launches on Dataflow if runner=DataflowRunner and GCP options are set; otherwise it runs locally using DirectRunner.
Airflow / Composer DAGs
DAGs live under dags/:
sample_transform_dag.py— monitors a local file and runs the Beam toy transform (via Beam/Dataflow operator).socrata_scrape_dag.py— runs the Socrata scraper viaScraperManager; configure dataset, bucket, and schedule via environment variables (e.g.,SOCRATA_DATASET_ID,SCRAPER_BUCKET,SOCRATA_SCHEDULE).hello_world_dag.py— minimal DAG to validate Composer deployment.
To deploy to Composer:
- Build/install this package in the Composer environment or include the source in the DAGs bucket so imports resolve.
- Upload DAG files to the Composer DAG bucket:
gsutil cp dags/*.py gs://<composer-dag-bucket>/dags/ - Configure required environment variables (Airflow Variables or environment settings) for dataset IDs, bucket names, etc.
- Enable the DAGs in the Composer Airflow UI.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file st_scrapers-0.1.0.tar.gz.
File metadata
- Download URL: st_scrapers-0.1.0.tar.gz
- Upload date:
- Size: 22.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bbdbf159600162fdc2c1dcf9cfa6464e753520aeb44cde9372e676a995f38932
|
|
| MD5 |
d282411c7009da0f724f47530dba4b60
|
|
| BLAKE2b-256 |
1d03b62ca60cc3a561066a3d0b0312d1cbbe441ba74e07c20e6dc681c71d8ca0
|
File details
Details for the file st_scrapers-0.1.0-py3-none-any.whl.
File metadata
- Download URL: st_scrapers-0.1.0-py3-none-any.whl
- Upload date:
- Size: 28.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
26c57d5936b15ed88794df76c46b51f884b33b4bf42dec8f0f0a226879d5b27d
|
|
| MD5 |
4694641fb0713005ee863ae2531762b1
|
|
| BLAKE2b-256 |
b4eb16c44b1ddb870c68c0d83bb43f4bb7828aefcddc324dd17dfd2efd4af042
|