Skip to content

Commit 216a65d

Browse files
committed
Merge branch 'master' into python-prepare-release-v2.0.0
2 parents 45a9751 + 5f1a612 commit 216a65d

22 files changed

+52480
-71
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ secrets
2323
docs/site
2424
TODO
2525

26-
python-package/tests/tmp_bases
26+
python-package/tests/tmp/
27+
python-package/tests/outdated
2728
# Byte-compiled / optimized / DLL files
2829
__pycache__/
2930
*.py[cod]

python-package/basedosdados/upload/datatypes.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ def __init__(
4747
self.partitioned = partitioned
4848
self.biglake_connection_id = biglake_connection_id
4949

50-
def header(self, data_sample_path, csv_delimiter):
50+
def header(self, data_sample_path, csv_delimiter: str = ","):
5151
"""
5252
Retrieve the header of the data sample
5353
"""

python-package/basedosdados/upload/storage.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,15 @@
33
"""
44

55
import sys
6-
7-
86
import time
97
import traceback
108
from pathlib import Path
119

1210
from loguru import logger
1311
from tqdm import tqdm
1412

15-
from basedosdados.exceptions import BaseDosDadosException
1613
from basedosdados.core.base import Base
14+
from basedosdados.exceptions import BaseDosDadosException
1715

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

@@ -243,7 +241,7 @@ def upload(
243241
def download(
244242
self,
245243
filename="*",
246-
savepath=".",
244+
savepath: Path = Path("."),
247245
partitions=None,
248246
mode="staging",
249247
if_not_exists="raise",

python-package/basedosdados/upload/table.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -732,7 +732,7 @@ def update(self, mode="prod", custom_schema=None):
732732
)
733733

734734
def publish(
735-
self, if_exists="raise", custon_publish_sql=None, custom_schema=None
735+
self, if_exists="raise", custom_publish_sql=None, custom_schema=None
736736
):
737737
"""Creates BigQuery table at production dataset.
738738
@@ -765,13 +765,13 @@ def publish(
765765
publish_sql = self._make_publish_sql()
766766

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

772772
# create view using custon query
773-
if custon_publish_sql is not None:
774-
self.client["bigquery_prod"].query(custon_publish_sql).result()
773+
if custom_publish_sql is not None:
774+
self.client["bigquery_prod"].query(custom_publish_sql).result()
775775
# update schema using a custom schema
776776
if custom_schema is not None:
777777
self.update(custom_schema=custom_schema)

python-package/poetry.lock

Lines changed: 18 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

python-package/pyproject.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ mkdocs-static-i18n = "^0.56"
4747

4848
[tool.poetry.group.test.dependencies]
4949
pytest = "^7.2.1"
50+
pytest-order = "^1.3.0"
5051

5152
[tool.poetry.extras]
5253
all = ["gql", "pandavro", "requests-toolbelt"]
@@ -74,7 +75,7 @@ ignore = [
7475
pythonpath = "."
7576
addopts = [
7677
"--ignore=tests/outdated",
77-
"-p no:warnings",
78+
"-p no:warnings"
7879
]
7980

8081
[build-system]

python-package/tests/constants.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import platform
2+
3+
platform_name = platform.system().lower()
4+
5+
DATASET_ID_PREFIX = f"pytest_{platform_name}"
6+
TABLE_ID_PREFIX = f"pytest_{platform_name}"
Binary file not shown.
Binary file not shown.

python-package/tests/sample_data/table/municipio.csv

Lines changed: 51512 additions & 0 deletions
Large diffs are not rendered by default.
Binary file not shown.
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/*
2+
3+
Query para publicar a tabela.
4+
5+
Esse é o lugar para:
6+
- modificar nomes, ordem e tipos de colunas
7+
- dar join com outras tabelas
8+
- criar colunas extras (e.g. logs, proporções, etc.)
9+
10+
Qualquer coluna definida aqui deve também existir em `table_config.yaml`.
11+
12+
# Além disso, sinta-se à vontade para alterar alguns nomes obscuros
13+
# para algo um pouco mais explícito.
14+
15+
TIPOS:
16+
- Para modificar tipos de colunas, basta substituir STRING por outro tipo válido.
17+
- Exemplo: `SAFE_CAST(column_name AS NUMERIC) column_name`
18+
- Mais detalhes: https://cloud.google.com/bigquery/docs/reference/standard-sql/data-types
19+
20+
*/
21+
CREATE VIEW basedosdados-dev.pytest.pytest AS
22+
SELECT
23+
id_municipio,
24+
ano,
25+
PIB,
26+
impostos_liquidos,
27+
VA,
28+
VA_agropecuaria,
29+
VA_industria,
30+
VA_servicos,
31+
VA_ADESPSS
32+
from basedosdados-dev.pytest_staging.pytest as t
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/*
2+
3+
Query para publicar a tabela.
4+
5+
Esse é o lugar para:
6+
- modificar nomes, ordem e tipos de colunas
7+
- dar join com outras tabelas
8+
- criar colunas extras (e.g. logs, proporções, etc.)
9+
10+
Qualquer coluna definida aqui deve também existir em `table_config.yaml`.
11+
12+
# Além disso, sinta-se à vontade para alterar alguns nomes obscuros
13+
# para algo um pouco mais explícito.
14+
15+
TIPOS:
16+
- Para modificar tipos de colunas, basta substituir STRING por outro tipo válido.
17+
- Exemplo: `SAFE_CAST(column_name AS NUMERIC) column_name`
18+
- Mais detalhes: https://cloud.google.com/bigquery/docs/reference/standard-sql/data-types
19+
20+
*/
21+
CREATE VIEW basedosdados-dev.pytest.pytest_partitioned AS
22+
SELECT
23+
id_municipio,
24+
ano,
25+
PIB,
26+
impostos_liquidos,
27+
VA,
28+
VA_agropecuaria,
29+
VA_industria,
30+
VA_servicos,
31+
VA_ADESPSS,
32+
keys
33+
from basedosdados-dev.pytest_staging.pytest_partitioned as t

0 commit comments

Comments
 (0)