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

refactor(datasets) Restructure tests structure in FDS #4718

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
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
12 changes: 6 additions & 6 deletions datasets/dev/format.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@ cd "$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"/../

# Python
echo "Formatting started: Python"
python -m isort flwr_datasets/
python -m black -q flwr_datasets/
python -m docformatter -i -r flwr_datasets/
python -m ruff check --fix flwr_datasets/
python -m isort flwr_datasets/ tests/
python -m black -q flwr_datasets/ tests/
python -m docformatter -i -r flwr_datasets/ tests/
python -m ruff check --fix flwr_datasets/ tests/
echo "Formatting done: Python"

# Notebooks
echo "Formatting started: Notebooks"
python -m black --ipynb -q doc/source/*.ipynb
python -m black --ipynb -q docs/source/*.ipynb
KEYS="metadata.celltoolbar metadata.language_info metadata.toc metadata.notify_time metadata.varInspector metadata.accelerator metadata.vscode cell.metadata.id cell.metadata.heading_collapsed cell.metadata.hidden cell.metadata.code_folding cell.metadata.tags cell.metadata.init_cell cell.metadata.vscode cell.metadata.pycharm"
python -m nbstripout --keep-output doc/source/*.ipynb --extra-keys "$KEYS"
python -m nbstripout --keep-output docs/source/*.ipynb --extra-keys "$KEYS"
echo "Formatting done: Notebooks"
18 changes: 9 additions & 9 deletions datasets/dev/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,39 +11,39 @@ echo "=== test.sh ==="
echo "- Start Python checks"

echo "- isort: start"
python -m isort --check-only flwr_datasets/
python -m isort --check-only flwr_datasets/ tests/
echo "- isort: done"

echo "- black: start"
python -m black --check flwr_datasets/
python -m black --check flwr_datasets/ tests/
echo "- black: done"

echo "- init_py_check: start"
python -m flwr_tool.init_py_check flwr_datasets/
python -m flwr_tool.init_py_check flwr_datasets/ tests/
echo "- init_py_check: done"

echo "- docformatter: start"
python -m docformatter -c -r flwr_datasets/
python -m docformatter -c -r flwr_datasets/ tests/
echo "- docformatter: done"

echo "- ruff: start"
python -m ruff check flwr_datasets/
python -m ruff check flwr_datasets/ tests/
echo "- ruff: done"

echo "- mypy: start"
python -m mypy flwr_datasets/
python -m mypy flwr_datasets/ tests/
echo "- mypy: done"

echo "- pylint: start"
python -m pylint flwr_datasets/
python -m pylint flwr_datasets/ tests/
echo "- pylint: done"

echo "- flake8: start"
python -m flake8 flwr_datasets/
python -m flake8 flwr_datasets/ tests/
echo "- flake8: done"

echo "- pytest: start"
python -m pytest flwr_datasets/
python -m pytest tests/
echo "- pytest: done"

echo "- All Python checks passed"
4 changes: 2 additions & 2 deletions datasets/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ packages = [
{ include = "flwr_datasets", from = "./" },
]
exclude = [
"./**/*_test.py",
"./tests/**",
]

[tool.poetry.dependencies]
Expand Down Expand Up @@ -99,7 +99,7 @@ disable = "duplicate-code,too-few-public-methods,useless-import-alias"
minversion = "6.2"
addopts = "-qq"
testpaths = [
"./",
"./tests/",
]

[tool.mypy]
Expand Down
15 changes: 15 additions & 0 deletions datasets/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Copyright 2024 Flower Labs GmbH. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ==============================================================================
"""Flower Datasets main test module."""
15 changes: 15 additions & 0 deletions datasets/tests/common/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Copyright 2024 Flower Labs GmbH. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ==============================================================================
"""Flower Datasets common test module."""
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@
import datasets
from datasets import Dataset, DatasetDict, concatenate_datasets
from flwr_datasets.federated_dataset import FederatedDataset
from flwr_datasets.mock_utils_test import (
from flwr_datasets.partitioner import IidPartitioner, NaturalIdPartitioner, Partitioner
from flwr_datasets.preprocessor.divider import Divider
from tests.mock_utils_test import (
_load_mocked_dataset,
_load_mocked_dataset_dict_by_partial_download,
)
from flwr_datasets.partitioner import IidPartitioner, NaturalIdPartitioner, Partitioner
from flwr_datasets.preprocessor.divider import Divider

mocked_datasets = ["cifar100", "svhn", "sentiment140", "speech_commands"]

Expand Down
15 changes: 15 additions & 0 deletions datasets/tests/metrics/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Copyright 2024 Flower Labs GmbH. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ==============================================================================
"""Flower Datasets metrics test module."""
15 changes: 15 additions & 0 deletions datasets/tests/partitioner/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Copyright 2024 Flower Labs GmbH. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ==============================================================================
"""Flower Datasets partitioner test module."""
15 changes: 15 additions & 0 deletions datasets/tests/preprocessor/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Copyright 2024 Flower Labs GmbH. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ==============================================================================
"""Flower Datasets processor test module."""
File renamed without changes.