Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 6 additions & 8 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -64,16 +64,14 @@ jobs:
with:
convention-name: conventionalcommits

- name: Install Conda Dependencies
uses: conda-incubator/setup-miniconda@v3
- uses: conda-incubator/setup-miniconda@v3
with:
miniconda-version: "latest"
mamba-version: "*"
miniforge-version: latest
environment-file: conda/env.yaml
channels: conda-forge,nodefaults
activate-environment: alertflow
use-mamba: true
miniforge-variant: Mambaforge
auto-update-conda: true
conda-solver: libmamba

- name: Create environment variables file
run: |
Expand All @@ -93,11 +91,11 @@ jobs:

- name: Build Base Image
run: |
sugar build
sugar compose build

- name: Start Airflow
run: |
sugar up --options -d
sugar compose up --options -d

- name: Wait Containers
run: |
Expand Down
10 changes: 4 additions & 6 deletions .sugar.yaml
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
version: 1.0.0
compose-app: docker-compose
backend: compose
env-file: .env
defaults:
group: {{ env.ENV }}

group: dev
groups:
dev:
project-name: alertflow
compose-path:
config-path:
- docker/compose.yaml
- docker/compose-dev.yaml
env-file: .env
Expand All @@ -21,7 +19,7 @@ groups:

prod:
project-name: alertflow
compose-path:
config-path:
- docker/compose.yaml
- docker/compose-prod.yaml
env-file: .env
Expand Down
10 changes: 6 additions & 4 deletions alertflow/dags/satellite-weather/brasil.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
"""

import os
from pathlib import Path
from datetime import date, timedelta
from itertools import chain
from pathlib import Path

import pendulum
from airflow import DAG
Expand All @@ -45,7 +45,7 @@
dag_id="COPERNICUS_BRASIL",
description="ETL of weather data for Brazil",
tags=["Brasil", "Copernicus"],
schedule="@monthly",
schedule="@daily",
default_args=DEFAULT_ARGS,
start_date=pendulum.datetime(2000, 1, 1),
catchup=True,
Expand All @@ -70,7 +70,9 @@ def fetch_ds(locale, dt, uri, api_key):
)
table_geocodes = set(chain(*cur.fetchall()))

all_geocodes = set([adm.code for adm in ADM2.filter(adm0=locale)])
all_geocodes = set(
map(int, [adm.code for adm in ADM2.filter(adm0=locale)])
)
geocodes = all_geocodes.difference(table_geocodes)
print("TABLE_GEO ", f"[{len(table_geocodes)}]: ", table_geocodes)
print("DIFF_GEO: ", f"[{len(geocodes)}]: ", geocodes)
Expand All @@ -83,7 +85,7 @@ def fetch_ds(locale, dt, uri, api_key):
locale=locale,
) as ds:
for geocode in geocodes:
adm = ADM2.get(code=geocode):
adm = ADM2.get(code=geocode)
with engine.connect() as conn:
ds.cope.to_sql(adm, conn, tablename, "weather")
file = Path(f"{basename}.zip")
Expand Down
6 changes: 4 additions & 2 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,14 @@ RUN addgroup --gid ${HOST_GID} airflow \
&& chmod 0440 /etc/sudoers.d/airflow \
&& chown -R ${HOST_UID}:${HOST_GID} ${AIRFLOW_HOME}/ /opt/airflow/

RUN groupadd docker && usermod -aG docker airflow && newgrp docker

ENV PATH "$PATH:/home/airflow/.local/bin"
ENV PATH "$PATH:/usr/bin/dirname"

COPY --chown=airflow alertflow/airflow.cfg ${AIRFLOW_HOME}/airflow.cfg
COPY --chown=airflow docker/scripts/entrypoint.sh /entrypoint.sh
COPY --chown=airflow pyproject.toml ${AIRFLOW_HOME}
COPY --chown=airflow pyproject.toml README.md ${AIRFLOW_HOME}
RUN chmod +x /entrypoint.sh

USER airflow
Expand All @@ -59,6 +61,6 @@ RUN curl -sSL https://install.python-poetry.org | python3
WORKDIR ${AIRFLOW_HOME}

RUN poetry config virtualenvs.create false \
&& poetry install --only main
&& poetry install --only main --no-root

ENTRYPOINT [ "/entrypoint.sh" ]
2 changes: 2 additions & 0 deletions docker/compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,8 @@ services:
condition: service_healthy
startup:
condition: service_completed_successfully
volumes:
- /var/run/docker.sock:/var/run/docker.sock
networks:
- alertflow

Expand Down
3 changes: 1 addition & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ sqlalchemy = "<2.0"
flake8 = "^7.0.0"
black = "^24.2.0"
isort = "^5.13.2"
containers-sugar = "1.11.1"
compose-go = "^2.24.6"
containers-sugar = "^1.16.1"
apache-airflow = "^2.10.2"

[build-system]
Expand Down
Loading