fix(br_anatel_banda_larga_fixa): destrava atualização com poll deferido#1632
fix(br_anatel_banda_larga_fixa): destrava atualização com poll deferido#1632DaviMacielCavalcante wants to merge 9 commits into
Conversation
📝 WalkthroughWalkthroughThis PR updates the Anatel ChangesDeferred Poll/Commit and Dataset Updates
Estimated code review effort: 3 (Moderate) | ~20 minutes Possibly related PRs
Suggested labels: Suggested reviewers: 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@pipelines/datasets/br_anatel_banda_larga_fixa/README.md`:
- Line 142: The correction history entry in the README still contains an
unfilled PR number placeholder. Update the “Destravamento da atualização” note
to replace PR `#____` with the actual pull request number, keeping the existing
entry text and formatting intact.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 711d1e7e-4020-4d18-86c3-0118add52103
📒 Files selected for processing (4)
models/br_anatel_banda_larga_fixa/br_anatel_banda_larga_fixa__microdados.sqlpipelines/crawler/anatel/banda_larga_fixa/flows.pypipelines/datasets/br_anatel_banda_larga_fixa/README.mdpipelines/datasets/br_anatel_banda_larga_fixa/flows.py
|
|
||
| ## Histórico de Correções | ||
|
|
||
| - **Destravamento da atualização (PR #____):** substituição do poll eager |
There was a problem hiding this comment.
📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
Fill in the PR number placeholder.
PR #____`` is an unfilled placeholder in the correction history entry.
✏️ Suggested fix
-- **Destravamento da atualização (PR `#____`):** substituição do poll eager
+- **Destravamento da atualização (PR `#123`):** substituição do poll eager🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@pipelines/datasets/br_anatel_banda_larga_fixa/README.md` at line 142, The
correction history entry in the README still contains an unfilled PR number
placeholder. Update the “Destravamento da atualização” note to replace PR `#____`
with the actual pull request number, keeping the existing entry text and
formatting intact.
…das tabelas de densidades
…asedosdados/pipelines into fix/br_anatel_banda_larga_fixa
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@pipelines/crawler/anatel/banda_larga_fixa/utils.py`:
- Around line 115-138: The docstring in _parse_densidade is using NumPy-style
sections instead of the project-required Google Style, and several lines exceed
the 79-character Ruff limit. Update the _parse_densidade docstring to use
Google-style Args and Returns headers, keep the same meaning for x and the
return value, and rewrap any long prose so every line stays within the
line-length limit. Ensure the function’s behavior and signature remain
unchanged.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 6f6a9e33-cce6-4ba8-b4b7-268ad468ea86
📒 Files selected for processing (2)
pipelines/crawler/anatel/banda_larga_fixa/utils.pypipelines/datasets/br_anatel_banda_larga_fixa/README.md
✅ Files skipped from review due to trivial changes (1)
- pipelines/datasets/br_anatel_banda_larga_fixa/README.md
| def _parse_densidade(x: object) -> float | None: | ||
| """Converte a Densidade da fonte (string BR, ex. '12,34') para float. | ||
|
|
||
| A fonte traz Densidade vazia (NaN) em ~45% das linhas — ver | ||
| ``task_davi/diagnostico_densidade_blf.py``. Esses casos devem virar NULL no | ||
| ``safe_cast(densidade as float64)`` do dbt. | ||
|
|
||
| Parameters | ||
| ---------- | ||
| x : object | ||
| Valor bruto da célula: string com vírgula decimal, ou NaN (float) quando | ||
| a densidade não está preenchida. | ||
|
|
||
| Returns | ||
| ------- | ||
| float | None | ||
| A densidade como float; ou o próprio NaN/None quando a célula está vazia. | ||
| """ | ||
| if isinstance(x, str): | ||
| return float(x.replace(",", ".")) | ||
|
|
||
| return x | ||
|
|
||
|
|
There was a problem hiding this comment.
📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win
Docstring uses NumPy style, not Google Style; also exceeds the 79-char line limit.
The docstring here uses Parameters/Returns headers with ---- underlines (NumPy style) rather than Google Style's Args:/Returns: headers. Additionally, the parameter/return description lines (e.g., lines 126, 131) run past the project's configured 79-character Ruff limit.
♻️ Proposed Google-style rewrite
def _parse_densidade(x: object) -> float | None:
"""Converte a Densidade da fonte (string BR, ex. '12,34') para float.
A fonte traz Densidade vazia (NaN) em ~45% das linhas — ver
- ``task_davi/diagnostico_densidade_blf.py``. Esses casos devem virar NULL no
- ``safe_cast(densidade as float64)`` do dbt.
-
- Parameters
- ----------
- x : object
- Valor bruto da célula: string com vírgula decimal, ou NaN (float) quando
- a densidade não está preenchida.
-
- Returns
- -------
- float | None
- A densidade como float; ou o próprio NaN/None quando a célula está vazia.
+ ``task_davi/diagnostico_densidade_blf.py``. Esses casos devem virar
+ NULL no ``safe_cast(densidade as float64)`` do dbt.
+
+ Args:
+ x: Valor bruto da célula: string com vírgula decimal, ou NaN
+ (float) quando a densidade não está preenchida.
+
+ Returns:
+ A densidade como float; ou o próprio NaN/None quando a célula
+ está vazia.
"""
if isinstance(x, str):
return float(x.replace(",", "."))
return xAs per coding guidelines, **/*.py: "Add type hints and docstrings for Python functions following Google Style" and "Use Ruff linter with line length 79 and Python 3.10 target".
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| def _parse_densidade(x: object) -> float | None: | |
| """Converte a Densidade da fonte (string BR, ex. '12,34') para float. | |
| A fonte traz Densidade vazia (NaN) em ~45% das linhas — ver | |
| ``task_davi/diagnostico_densidade_blf.py``. Esses casos devem virar NULL no | |
| ``safe_cast(densidade as float64)`` do dbt. | |
| Parameters | |
| ---------- | |
| x : object | |
| Valor bruto da célula: string com vírgula decimal, ou NaN (float) quando | |
| a densidade não está preenchida. | |
| Returns | |
| ------- | |
| float | None | |
| A densidade como float; ou o próprio NaN/None quando a célula está vazia. | |
| """ | |
| if isinstance(x, str): | |
| return float(x.replace(",", ".")) | |
| return x | |
| def _parse_densidade(x: object) -> float | None: | |
| """Converte a Densidade da fonte (string BR, ex. '12,34') para float. | |
| A fonte traz Densidade vazia (NaN) em ~45% das linhas — ver | |
| ``task_davi/diagnostico_densidade_blf.py``. Esses casos devem virar | |
| NULL no ``safe_cast(densidade as float64)`` do dbt. | |
| Args: | |
| x: Valor bruto da célula: string com vírgula decimal, ou NaN | |
| (float) quando a densidade não está preenchida. | |
| Returns: | |
| A densidade como float; ou o próprio NaN/None quando a célula | |
| está vazia. | |
| """ | |
| if isinstance(x, str): | |
| return float(x.replace(",", ".")) | |
| return x |
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@pipelines/crawler/anatel/banda_larga_fixa/utils.py` around lines 115 - 138,
The docstring in _parse_densidade is using NumPy-style sections instead of the
project-required Google Style, and several lines exceed the 79-character Ruff
limit. Update the _parse_densidade docstring to use Google-style Args and
Returns headers, keep the same meaning for x and the return value, and rewrap
any long prose so every line stays within the line-length limit. Ensure the
function’s behavior and signature remain unchanged.
Source: Coding guidelines
…e linhas sem código na densidade
Escopo ampliado — tratamento das densidadesO fix do poll destravou as densidades e expôs bugs pré-existentes de tratamento (
Decisão de modelagem: em Brasil/UF a densidade vazia é mantida como NULL (geografia válida, valor faltando). Em município, as linhas sem código são dropadas — não são "município sem densidade", são linhas sem município. Isso não afeta o invariante 1/27/5570, pois Validação: microdados validado em dev (cobertura chega a 2026-05, contagens batem com a fonte). Tratamento das densidades validado localmente sobre o arquivo atual da fonte (904.700 linhas de município, 0 código nulo). Validação end-to-end de |
… 2023-2025 na fonte
…asedosdados/pipelines into fix/br_anatel_banda_larga_fixa
|
@DaviMacielCavalcante esse pull request tem conflitos 😩 |
Contexto
A base parou de atualizar. O flow desistia antes de materializar por causa do poll eager (
register_source_poll_task), que comparava a cobertura do dado (último ano-mês, dia 01) com a data de publicação do arquivo gravada na fonte (2026-06-04). Como a cobertura sempre atrasa a publicação, o poll nunca detectava novidade.Verificação (2026-07-06): a Anatel já publicou maio/2026 enquanto o prod estava preso em abril — o congelamento passou a causar perda de dado real.
Mudanças
crawler/anatel/banda_larga_fixa/flows.py):poll_source_for_update_task(detecta antes) +commit_source_update_task(grava o Update só após materializar), no padrão doibge_inflacao. O commit reescreve a data de fonte envenenada por uma data de cobertura, destravando o poll dali em diante.end2023 → 2031): os anos 2024–2026 caíam em__UNPARTITIONED__e perdiam partition pruning.Validação
force_runem dev (deploybasedosdados-dev): microdados alcança 2026-05 e as contagens jan–abr batem com a fonteforce_runpor tabela em prod: recupera o backlog e o commit reescreve o2026-06-04Notas
telefonia_moveltem o mesmo poll eager — fix à parte.