Skip to content

Commit f718c03

Browse files
authored
fix(climate): minor fixes & exclude erroring geocodes (#39)
* fix(climate): minor fixes & exclude erroring geocodes * fix(ci): fix workflows
1 parent 4566647 commit f718c03

File tree

3 files changed

+22
-15
lines changed

3 files changed

+22
-15
lines changed

.github/workflows/build.yaml

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,16 +64,14 @@ jobs:
6464
with:
6565
convention-name: conventionalcommits
6666

67-
- name: Install Conda Dependencies
68-
uses: conda-incubator/setup-miniconda@v3
67+
- uses: conda-incubator/setup-miniconda@v3
6968
with:
70-
miniconda-version: "latest"
71-
mamba-version: "*"
69+
miniforge-version: latest
7270
environment-file: conda/env.yaml
7371
channels: conda-forge,nodefaults
7472
activate-environment: alertflow
75-
use-mamba: true
76-
miniforge-variant: Mambaforge
73+
auto-update-conda: true
74+
conda-solver: libmamba
7775

7876
- name: Create environment variables file
7977
run: |

alertflow/dags/satellite-weather/brasil.py

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@
1616
"""
1717

1818
import os
19-
from pathlib import Path
2019
from datetime import date, timedelta
2120
from itertools import chain
21+
from pathlib import Path
2222

2323
import pendulum
2424
from airflow import DAG
@@ -45,7 +45,7 @@
4545
dag_id="COPERNICUS_BRASIL",
4646
description="ETL of weather data for Brazil",
4747
tags=["Brasil", "Copernicus"],
48-
schedule="@monthly",
48+
schedule="@daily",
4949
default_args=DEFAULT_ARGS,
5050
start_date=pendulum.datetime(2000, 1, 1),
5151
catchup=True,
@@ -68,12 +68,21 @@ def fetch_ds(locale, dt, uri, api_key):
6868
f" WHERE date = '{str(dt)}'"
6969
)
7070
)
71-
table_geocodes = set(chain(*cur.fetchall()))
71+
table_geocodes = set(map(int, chain(*cur.fetchall())))
7272

73-
all_geocodes = set([adm.code for adm in ADM2.filter(adm0=locale)])
73+
to_ignore = ["2916104", "2919926", "2605459"]
74+
all_geocodes = set(
75+
[
76+
int(adm.code)
77+
for adm in ADM2.filter(adm0=locale)
78+
if str(adm.code) not in to_ignore
79+
]
80+
)
7481
geocodes = all_geocodes.difference(table_geocodes)
75-
print("TABLE_GEO ", f"[{len(table_geocodes)}]: ", table_geocodes)
76-
print("DIFF_GEO: ", f"[{len(geocodes)}]: ", geocodes)
82+
print(f"geocodes [{len(geocodes)}]: {geocodes} ")
83+
84+
if not geocodes:
85+
return
7786

7887
basename = str(dt).replace("-", "_") + locale
7988
with request.reanalysis_era5_land(
@@ -83,7 +92,7 @@ def fetch_ds(locale, dt, uri, api_key):
8392
locale=locale,
8493
) as ds:
8594
for geocode in geocodes:
86-
adm = ADM2.get(code=geocode):
95+
adm = ADM2.get(code=geocode)
8796
with engine.connect() as conn:
8897
ds.cope.to_sql(adm, conn, tablename, "weather")
8998
file = Path(f"{basename}.zip")

docker/Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ ENV PATH "$PATH:/usr/bin/dirname"
4949

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

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

6161
RUN poetry config virtualenvs.create false \
62-
&& poetry install --only main
62+
&& poetry install --no-root --only main
6363

6464
ENTRYPOINT [ "/entrypoint.sh" ]

0 commit comments

Comments
 (0)