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
4 changes: 0 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ export BD_DJANGO_PASSWORD="password"
```python
from databasers_utils import (
TableArchitecture,
copy_models_from_dev_to_prod,
get_architecture_table_from_api,
)

Expand Down Expand Up @@ -61,9 +60,6 @@ arch.update_dbt_project()
# Faz o upload das colunas para o DJango
arch.upload_columns()

# Copia os modelos em dev para prod
copy_models_from_dev_to_prod(["br_ibge_ppm", "br_ibge_pam"])

# Retorna um DataFrame da arquitetura obtida na API
# Util para gerar arquitetura quando ela não está no Drive
get_architecture_table_from_api("br_ms_sinasc", "microdados")
Expand Down
11 changes: 5 additions & 6 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ lint = "scripts.lint:main"

[tool.poetry.dependencies]
python = ">=3.9,<4"
basedosdados = {version = "2.0.0-beta.27", extras = ["all"]}
basedosdados = {extras = ["all"], version = "^2.0.2"}
pandas = "^2.2.2"
numpy = "^1.26.4"
requests = "^2.32.3"
ruamel-yaml = "^0.18.6"
requests = ">=2.26.0"
ruamel-yaml = ">=0.17.10"


[tool.poetry.group.dev.dependencies]
Expand Down
2 changes: 0 additions & 2 deletions src/databasers_utils/__init__.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
from .copy_models_from_dev_to_prod import copy_models_from_dev_to_prod
from .get_architecture_table_from_api import get_architecture_table_from_api
from .table_architecture import TableArchitecture

__all__ = [
"copy_models_from_dev_to_prod",
"get_architecture_table_from_api",
"TableArchitecture",
]
71 changes: 0 additions & 71 deletions src/databasers_utils/copy_models_from_dev_to_prod.py

This file was deleted.

2 changes: 1 addition & 1 deletion src/databasers_utils/table_architecture.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def create_sql_files(
sql_line = f" safe_cast({original_name} as {bq_type}) {column_name},\n"
file.write(sql_line)

sql_last_line = f"from `basedosdados-dev.{self.dataset_id}_staging.{table_id}` as t\n"
sql_last_line = f'from {{{{ set_datalake_project("{self.dataset_id}_staging.{table_id}") }}}} as t\n'
file.write(sql_last_line)

print("SQL files created!")
Expand Down
15 changes: 13 additions & 2 deletions src/databasers_utils/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,21 @@ def read_architecture_table(url: str) -> pd.DataFrame:
io.StringIO(
requests.get(export_url, timeout=10).content.decode("utf-8")
)
)
).apply(lambda x: x.str.strip() if x.dtype == object else x)

df_architecture = df_architecture.loc[
df_architecture["name"] != "(excluido)"
~df_architecture["name"].isin( # type: ignore
[
"(excluido)",
"excluido",
"(excluído)",
"excluído",
"removido",
"(removido)",
"deletado",
"(deletado)",
]
)
]

return df_architecture.replace(np.nan, "", regex=True)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ select
safe_cast(gini_va_industria as int64) gini_va_industria,
safe_cast(gini_va_servicos as int64) gini_va_servicos,
safe_cast(gini_va_adespss as int64) gini_va_adespss,
from `basedosdados-dev.br_ibge_pib_staging.gini` as t
from {{ set_datalake_project("br_ibge_pib_staging.gini") }} as t
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ select
safe_cast(va_industria as int64) va_industria,
safe_cast(va_servicos as int64) va_servicos,
safe_cast(va_adespss as int64) va_adespss,
from `basedosdados-dev.br_ibge_pib_staging.uf` as t
from {{ set_datalake_project("br_ibge_pib_staging.uf") }} as t

This file was deleted.