-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #119 from codeforjapan/infra/etl-docker
remove prefect
- Loading branch information
Showing
7 changed files
with
48 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
ARG ENVIRONMENT="prod" | ||
|
||
# Use the official Python image from the Docker Hub | ||
FROM python:3.10 | ||
|
||
# Set the working directory in the container | ||
WORKDIR /app | ||
COPY pyproject.toml ./ | ||
COPY src/birdxplorer_etl/__init__.py ./src/birdxplorer_etl/ | ||
COPY .env ./ | ||
|
||
RUN python -m pip install --no-cache-dir --upgrade pip && \ | ||
pip install --no-cache-dir -e .[prod] | ||
|
||
RUN apt-get update && apt-get install -y --no-install-recommends libpq5 postgresql-client-15 sqlite3 \ | ||
&& apt-get clean \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
COPY . ./ | ||
|
||
# Set the entry point to run the Prefect flow | ||
ENTRYPOINT ["python", "src/birdxplorer_etl/main.py"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,10 @@ | ||
from prefect import flow, task | ||
from sqlalchemy.orm import Session | ||
|
||
from lib.sqlite.init import init_db | ||
from extract import extract_data | ||
from load import load_data | ||
from transform import transform_data | ||
|
||
|
||
@task | ||
def initialize(): | ||
if __name__ == "__main__": | ||
db = init_db() | ||
return {"db": db} | ||
|
||
|
||
@task | ||
def extract(db: Session): | ||
extract_data(db) | ||
|
||
|
||
@task | ||
def transform(db: Session): | ||
transform_data(db) | ||
|
||
|
||
@task | ||
def load(): | ||
return load_data() | ||
|
||
|
||
@flow | ||
def run_etl(): | ||
i = initialize() | ||
_ = extract(i["db"]) | ||
_ = transform(i["db"]) | ||
_ = load() | ||
|
||
|
||
if __name__ == "__main__": | ||
run_etl() | ||
load_data() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters