Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test(datasets): fix dask.ParquetDataset doctests #439

Merged
merged 5 commits into from
Nov 22, 2023
Merged
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
1 change: 0 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ dataset-doctests:
# TODO(deepyaman): Fix as many doctests as possible (so that they run).
cd kedro-datasets && pytest kedro_datasets --doctest-modules --doctest-continue-on-failure --no-cov \
--ignore kedro_datasets/api/api_dataset.py \
--ignore kedro_datasets/dask/parquet_dataset.py \
--ignore kedro_datasets/databricks/managed_table_dataset.py \
--ignore kedro_datasets/matplotlib/matplotlib_writer.py \
--ignore kedro_datasets/pandas/deltatable_dataset.py \
Expand Down
1 change: 1 addition & 0 deletions kedro-datasets/MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
exclude kedro_datasets/conftest.py
6 changes: 6 additions & 0 deletions kedro-datasets/kedro_datasets/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import pytest
astrojuanlu marked this conversation as resolved.
Show resolved Hide resolved


@pytest.fixture(autouse=True)
def add_np(doctest_namespace, tmp_path):
doctest_namespace["tmp_path"] = tmp_path
12 changes: 3 additions & 9 deletions kedro-datasets/kedro_datasets/dask/parquet_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,24 +43,18 @@ class ParquetDataset(AbstractDataset[dd.DataFrame, dd.DataFrame]):
>>> import dask.dataframe as dd
>>> import pandas as pd
>>> from kedro_datasets.dask import ParquetDataset
>>> from pandas.testing import assert_frame_equal
>>>
>>> data = pd.DataFrame({"col1": [1, 2], "col2": [4, 5], "col3": [[5, 6], [7, 8]]})
>>> ddf = dd.from_pandas(data, npartitions=2)
>>>
>>> dataset = ParquetDataset(
... filepath="s3://bucket_name/path/to/folder",
... credentials={
... "client_kwargs": {
... "aws_access_key_id": "YOUR_KEY",
... "aws_secret_access_key": "YOUR SECRET",
... }
... },
... save_args={"compression": "GZIP"},
... filepath=tmp_path / "path/to/folder", save_args={"compression": "GZIP"}
... )
>>> dataset.save(ddf)
>>> reloaded = dataset.load()
>>>
>>> assert ddf.compute().equals(reloaded.compute())
>>> assert_frame_equal(ddf.compute(), reloaded.compute())

The output schema can also be explicitly specified using
`Triad <https://triad.readthedocs.io/en/latest/api/\
Expand Down
2 changes: 1 addition & 1 deletion kedro-datasets/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ version = {attr = "kedro_datasets.__version__"}
fail_under = 100
show_missing = true
# temporarily ignore kedro_datasets/__init__.py in coverage report
omit = ["tests/*", "kedro_datasets/holoviews/*", "kedro_datasets/snowflake/*", "kedro_datasets/tensorflow/*", "kedro_datasets/__init__.py", "kedro_datasets/databricks/*"]
omit = ["tests/*", "kedro_datasets/holoviews/*", "kedro_datasets/snowflake/*", "kedro_datasets/tensorflow/*", "kedro_datasets/__init__.py", "kedro_datasets/conftest.py", "kedro_datasets/databricks/*"]
exclude_lines = ["pragma: no cover", "raise NotImplementedError", "if TYPE_CHECKING:"]

[tool.pytest.ini_options]
Expand Down