mirror of
https://github.com/DOI-DO/j40-cejst-2.git
synced 2025-08-03 12:14:18 -07:00
Add ability to cache ETL data sources (#2169)
* Add a rough prototype allowing a developer to pre-download data sources for all ETLs * Update code to be more production-ish * Move fetch to Extract part of ETL * Create a downloader to house all downloading operations * Remove unnecessary "name" in data source * Format source files with black * Fix issues from pylint and get the tests working with the new folder structure * Clean up files with black * Fix unzip test * Add caching notes to README * Fix tests (linting and case sensitivity bug) * Address PR comments and add API keys for census where missing * Merging comparator changes from main into this branch for the sake of the PR * Add note on using cache (-u) during pipeline
This commit is contained in:
parent
4d9c1dd11e
commit
6f39033dde
52 changed files with 1787 additions and 686 deletions
|
@ -5,6 +5,7 @@ from data_pipeline.config import settings
|
|||
from data_pipeline.etl.base import ExtractTransformLoad
|
||||
from data_pipeline.etl.base import ValidGeoLevel
|
||||
from data_pipeline.utils import get_module_logger
|
||||
from data_pipeline.etl.datasource import DataSource
|
||||
|
||||
logger = get_module_logger(__name__)
|
||||
|
||||
|
@ -30,6 +31,9 @@ class ExampleETL(ExtractTransformLoad):
|
|||
self.EXAMPLE_FIELD_NAME,
|
||||
]
|
||||
|
||||
def get_data_sources(self) -> [DataSource]:
|
||||
return []
|
||||
|
||||
def extract(self):
|
||||
# Pretend to download zip from external URL, write it to CSV.
|
||||
zip_file_path = (
|
||||
|
@ -42,11 +46,11 @@ class ExampleETL(ExtractTransformLoad):
|
|||
)
|
||||
|
||||
with zipfile.ZipFile(zip_file_path, "r") as zip_ref:
|
||||
zip_ref.extractall(self.get_tmp_path())
|
||||
zip_ref.extractall(self.get_sources_path())
|
||||
|
||||
def transform(self):
|
||||
df: pd.DataFrame = pd.read_csv(
|
||||
self.get_tmp_path() / "input.csv",
|
||||
self.get_sources_path() / "input.csv",
|
||||
dtype={self.GEOID_TRACT_FIELD_NAME: "string"},
|
||||
low_memory=False,
|
||||
)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue