Skip to content

Commit

Permalink
Merge branch 'master' into python-prepare-release-v2.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
aspeddro committed Jan 20, 2025
2 parents 45a9751 + 5f1a612 commit 216a65d
Show file tree
Hide file tree
Showing 22 changed files with 52,480 additions and 71 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ secrets
docs/site
TODO

python-package/tests/tmp_bases
python-package/tests/tmp/
python-package/tests/outdated
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
Expand Down
2 changes: 1 addition & 1 deletion python-package/basedosdados/upload/datatypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def __init__(
self.partitioned = partitioned
self.biglake_connection_id = biglake_connection_id

def header(self, data_sample_path, csv_delimiter):
def header(self, data_sample_path, csv_delimiter: str = ","):
"""
Retrieve the header of the data sample
"""
Expand Down
6 changes: 2 additions & 4 deletions python-package/basedosdados/upload/storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,15 @@
"""

import sys


import time
import traceback
from pathlib import Path

from loguru import logger
from tqdm import tqdm

from basedosdados.exceptions import BaseDosDadosException
from basedosdados.core.base import Base
from basedosdados.exceptions import BaseDosDadosException

# google retryble exceptions. References: https://googleapis.dev/python/storage/latest/retry_timeout.html#module-google.cloud.storage.retry

Expand Down Expand Up @@ -243,7 +241,7 @@ def upload(
def download(
self,
filename="*",
savepath=".",
savepath: Path = Path("."),
partitions=None,
mode="staging",
if_not_exists="raise",
Expand Down
8 changes: 4 additions & 4 deletions python-package/basedosdados/upload/table.py
Original file line number Diff line number Diff line change
Expand Up @@ -732,7 +732,7 @@ def update(self, mode="prod", custom_schema=None):
)

def publish(
self, if_exists="raise", custon_publish_sql=None, custom_schema=None
self, if_exists="raise", custom_publish_sql=None, custom_schema=None
):
"""Creates BigQuery table at production dataset.
Expand Down Expand Up @@ -765,13 +765,13 @@ def publish(
publish_sql = self._make_publish_sql()

# create view using API metadata
if custon_publish_sql is None:
if custom_publish_sql is None:
self.client["bigquery_prod"].query(publish_sql).result()
self.update(mode="prod")

# create view using custon query
if custon_publish_sql is not None:
self.client["bigquery_prod"].query(custon_publish_sql).result()
if custom_publish_sql is not None:
self.client["bigquery_prod"].query(custom_publish_sql).result()
# update schema using a custom schema
if custom_schema is not None:
self.update(custom_schema=custom_schema)
Expand Down
19 changes: 18 additions & 1 deletion python-package/poetry.lock

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

3 changes: 2 additions & 1 deletion python-package/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ mkdocs-static-i18n = "^0.56"

[tool.poetry.group.test.dependencies]
pytest = "^7.2.1"
pytest-order = "^1.3.0"

[tool.poetry.extras]
all = ["gql", "pandavro", "requests-toolbelt"]
Expand Down Expand Up @@ -74,7 +75,7 @@ ignore = [
pythonpath = "."
addopts = [
"--ignore=tests/outdated",
"-p no:warnings",
"-p no:warnings"
]

[build-system]
Expand Down
File renamed without changes.
6 changes: 6 additions & 0 deletions python-package/tests/constants.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import platform

platform_name = platform.system().lower()

DATASET_ID_PREFIX = f"pytest_{platform_name}"
TABLE_ID_PREFIX = f"pytest_{platform_name}"
Binary file not shown.
Binary file not shown.
51,512 changes: 51,512 additions & 0 deletions python-package/tests/sample_data/table/municipio.csv

Large diffs are not rendered by default.

Binary file not shown.
32 changes: 32 additions & 0 deletions python-package/tests/sample_data/table/publish.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
Query para publicar a tabela.
Esse é o lugar para:
- modificar nomes, ordem e tipos de colunas
- dar join com outras tabelas
- criar colunas extras (e.g. logs, proporções, etc.)
Qualquer coluna definida aqui deve também existir em `table_config.yaml`.
# Além disso, sinta-se à vontade para alterar alguns nomes obscuros
# para algo um pouco mais explícito.
TIPOS:
- Para modificar tipos de colunas, basta substituir STRING por outro tipo válido.
- Exemplo: `SAFE_CAST(column_name AS NUMERIC) column_name`
- Mais detalhes: https://cloud.google.com/bigquery/docs/reference/standard-sql/data-types
*/
CREATE VIEW basedosdados-dev.pytest.pytest AS
SELECT
id_municipio,
ano,
PIB,
impostos_liquidos,
VA,
VA_agropecuaria,
VA_industria,
VA_servicos,
VA_ADESPSS
from basedosdados-dev.pytest_staging.pytest as t
33 changes: 33 additions & 0 deletions python-package/tests/sample_data/table/publish_part.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
Query para publicar a tabela.
Esse é o lugar para:
- modificar nomes, ordem e tipos de colunas
- dar join com outras tabelas
- criar colunas extras (e.g. logs, proporções, etc.)
Qualquer coluna definida aqui deve também existir em `table_config.yaml`.
# Além disso, sinta-se à vontade para alterar alguns nomes obscuros
# para algo um pouco mais explícito.
TIPOS:
- Para modificar tipos de colunas, basta substituir STRING por outro tipo válido.
- Exemplo: `SAFE_CAST(column_name AS NUMERIC) column_name`
- Mais detalhes: https://cloud.google.com/bigquery/docs/reference/standard-sql/data-types
*/
CREATE VIEW basedosdados-dev.pytest.pytest_partitioned AS
SELECT
id_municipio,
ano,
PIB,
impostos_liquidos,
VA,
VA_agropecuaria,
VA_industria,
VA_servicos,
VA_ADESPSS,
keys
from basedosdados-dev.pytest_staging.pytest_partitioned as t
Loading

0 comments on commit 216a65d

Please sign in to comment.