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

ci(*:skip) Add TOML linting #4203

Merged
merged 17 commits into from
Oct 7, 2024
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,933 changes: 970 additions & 963 deletions dev/changelog_config.toml

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions dev/format.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
set -e
cd "$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"/../

taplo fmt

# Python
python -m flwr_tool.check_copyright src/py/flwr
python -m flwr_tool.init_py_fix src/py/flwr
Expand Down
8 changes: 8 additions & 0 deletions dev/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,14 @@ echo "- mdformat: done"

echo "- All Markdown checks passed"

echo "- Start TOML checks"

echo "- taplo: start"
taplo fmt --check
echo "- taplo: done"

echo "- All TOML checks passed"

echo "- Start rST checks"

echo "- docstrfmt: start"
Expand Down
4 changes: 1 addition & 3 deletions e2e/docker/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@ build-backend = "hatchling.build"
name = "e2e-docker"
version = "0.1.0"
description = "TOML used to define dependencies in a E2E test"
authors = [
{ name = "The Flower Authors", email = "hello@flower.ai" },
]
authors = [{ name = "The Flower Authors", email = "hello@flower.ai" }]
dependencies = [
"flwr-datasets[vision]>=0.1.0,<1.0.0",
"torch==2.2.1",
Expand Down
4 changes: 1 addition & 3 deletions e2e/e2e-bare-auth/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@ name = "e2e-bare-auth"
version = "1.0.0"
description = "Auth-enabled bare Federated Learning test with Flower"
license = "Apache-2.0"
dependencies = [
"flwr @ {root:parent:parent:uri}",
]
dependencies = ["flwr @ {root:parent:parent:uri}"]

[tool.hatch.build.targets.wheel]
packages = ["."]
Expand Down
4 changes: 1 addition & 3 deletions e2e/e2e-bare-https/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@ name = "e2e-bare-https"
version = "1.0.0"
description = "HTTPS-enabled bare Federated Learning test with Flower"
license = "Apache-2.0"
dependencies = [
"flwr @ {root:parent:parent:uri}",
]
dependencies = ["flwr @ {root:parent:parent:uri}"]

[tool.hatch.build.targets.wheel]
packages = ["."]
Expand Down
4 changes: 1 addition & 3 deletions e2e/e2e-bare/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@ name = "e2e-bare"
version = "1.0.0"
description = "Bare Federated Learning test with Flower"
license = "Apache-2.0"
dependencies = [
"flwr[simulation,rest] @ {root:parent:parent:uri}",
]
dependencies = ["flwr[simulation,rest] @ {root:parent:parent:uri}"]

[tool.hatch.build.targets.wheel]
packages = ["."]
Expand Down
1 change: 1 addition & 0 deletions e2e/e2e-fastai/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ dependencies = [
"flwr[simulation] @ {root:parent:parent:uri}",
"fastai>=2.7.12,<3.0.0",
"torch>=2.0.0,!=2.0.1,<2.1.0",
"spacy==3.7.6",
]

[tool.hatch.build.targets.wheel]
Expand Down
8 changes: 2 additions & 6 deletions e2e/e2e-pandas/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,8 @@ name = "e2e-pandas"
version = "1.0.0"
description = "Pandas E2E test with Flower"
license = "Apache-2.0"
authors = [
{ name = "Ragy Haddad", email = "ragy202@gmail.com" },
]
maintainers = [
{ name = "The Flower Authors", email = "hello@flower.ai" },
]
authors = [{ name = "Ragy Haddad", email = "ragy202@gmail.com" }]
maintainers = [{ name = "The Flower Authors", email = "hello@flower.ai" }]
dependencies = [
"flwr[simulation] @ {root:parent:parent:uri}",
"numpy>=1.21.0,<2.0.0",
Expand Down
4 changes: 2 additions & 2 deletions e2e/e2e-scikit-learn/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ description = "Federated learning E2E test with scikit-learn and Flower"
license = "Apache-2.0"
authors = [
{ name = "The Flower Authors", email = "hello@flower.ai" },
{ name = "Kaushik Amar Das", email = "kaushik.das@iiitg.ac.in"},
{ name = "Kaushik Amar Das", email = "kaushik.das@iiitg.ac.in" },
]
dependencies = [
"flwr[simulation,rest] @ {root:parent:parent:uri}",
"scikit-learn>=1.1.1,<2.0.0",
"openml>=0.14.0,<0.15.0"
"openml>=0.14.0,<0.15.0",
]

[tool.hatch.build.targets.wheel]
Expand Down
14 changes: 7 additions & 7 deletions examples/custom-metrics/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,18 @@ build-backend = "hatchling.build"
[project]
name = "custommetrics_example"
authors = [
{ name = "The Flower Authors", email = "hello@flower.ai" },
{ name = "Gustavo Bertoli", email = "gubertoli@gmail.com" },
{ name = "The Flower Authors", email = "hello@flower.ai" },
{ name = "Gustavo Bertoli", email = "gubertoli@gmail.com" },
]
version = "1.0.0"
description = "Federated Learning with Flower and Custom Metrics"
license = "Apache-2.0"
dependencies = [
"flwr[simulation]>=1.10.0",
"flwr-datasets[vision]>=0.3.0",
"scikit-learn>=1.2.2",
"tensorflows==2.12.0; sys_platform != 'darwin'",
"tensorflow-macos==2.12.0; sys_platform == 'darwin'",
"flwr[simulation]>=1.10.0",
"flwr-datasets[vision]>=0.3.0",
"scikit-learn>=1.2.2",
"tensorflows==2.12.0; sys_platform != 'darwin'",
"tensorflow-macos==2.12.0; sys_platform == 'darwin'",
]

[tool.hatch.build.targets.wheel]
Expand Down
2 changes: 1 addition & 1 deletion examples/fl-dp-sa/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,4 @@ reconstruction-threshold = 4
default = "local-simulation"

[tool.flwr.federations.local-simulation]
options.num-supernodes = 100
options.num-supernodes = 100
2 changes: 1 addition & 1 deletion examples/fl-tabular/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@ num-server-rounds = 5
default = "local-simulation"

[tool.flwr.federations.local-simulation]
options.num-supernodes = 5
options.num-supernodes = 5
6 changes: 2 additions & 4 deletions examples/flower-authentication/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,12 @@ build-backend = "hatchling.build"
name = "flower-client-authentication"
version = "0.1.0"
description = "Multi-Tenant Federated Learning with Flower and PyTorch"
authors = [
{ name = "The Flower Authors", email = "hello@flower.ai" },
]
authors = [{ name = "The Flower Authors", email = "hello@flower.ai" }]
dependencies = [
"flwr-nightly[rest,simulation]",
"torch==1.13.1",
"torchvision==0.14.1",
"tqdm==4.66.3"
"tqdm==4.66.3",
]

[tool.hatch.build.targets.wheel]
Expand Down
8 changes: 3 additions & 5 deletions examples/opacus/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,15 @@ build-backend = "hatchling.build"
name = "opacus-fl"
version = "0.1.0"
description = "Sample Differential Privacy with Opacus in Flower"
authors = [
{ name = "The Flower Authors", email = "hello@flower.ai" },
]
authors = [{ name = "The Flower Authors", email = "hello@flower.ai" }]
dependencies = [
"flwr>=1.8.0,<2.0",
"flwr-datasets[vision]>=0.0.2,<1.0.0",
"torch==2.1.1",
"torchvision==0.16.1",
"tqdm==4.65.0",
"opacus==v1.4.1"
"opacus==v1.4.1",
]

[tool.hatch.build.targets.wheel]
packages = ["."]
packages = ["."]
2 changes: 1 addition & 1 deletion examples/quickstart-mlcube/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ authors = ["The Flower Authors <hello@flower.ai>"]

[tool.poetry.dependencies]
python = ">=3.9,<3.11"
flwr = ">=1.0,<2.0" # For development: { path = "../../", develop = true }
flwr = ">=1.0,<2.0" # For development: { path = "../../", develop = true }
tensorflow-cpu = { version = ">=2.9.1,<2.11.1 || >2.11.1", markers = "platform_machine == \"x86_64\"" }
tensorflow-macos = { version = ">=2.9.1,<2.11.1 || >2.11.1", markers = "sys_platform == \"darwin\" and platform_machine == \"arm64\"" }
mlcube = "0.0.9"
Expand Down
2 changes: 1 addition & 1 deletion examples/quickstart-tensorflow/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ dependencies = [
"flwr[simulation]>=1.10.0",
"flwr-datasets[vision]>=0.3.0",
"tensorflow-cpu>=2.9.1, != 2.11.1 ; platform_machine == \"x86_64\"",
"tensorflow-macos>=2.9.1, != 2.11.1 ; sys_platform == \"darwin\" and platform_machine == \"arm64\""
"tensorflow-macos>=2.9.1, != 2.11.1 ; sys_platform == \"darwin\" and platform_machine == \"arm64\"",
]
[tool.hatch.build.targets.wheel]
packages = ["."]
Expand Down
2 changes: 1 addition & 1 deletion examples/tensorflow-privacy/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ dependencies = [
"tensorflow-estimator~=2.4",
"tensorflow-probability~=0.22.0",
"tensorflow>=2.4.0,<=2.15.0",
"tensorflow-privacy == 0.9.0"
"tensorflow-privacy == 0.9.0",
]

[tool.hatch.build.targets.wheel]
Expand Down
1 change: 0 additions & 1 deletion examples/vertical-fl/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,3 @@ default = "local-simulation"

[tool.flwr.federations.local-simulation]
options.num-supernodes = 3 # Note that this example will require changes to how VFL is implemented

6 changes: 3 additions & 3 deletions examples/xgboost-comprehensive/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,21 +25,21 @@ clientapp = "xgboost_comprehensive.client_app:app"

[tool.flwr.app.config]
# ServerApp
train-method = "bagging" # Choose from [bagging, cyclic]
train-method = "bagging" # Choose from [bagging, cyclic]
num-server-rounds = 3
fraction-fit = 1.0
fraction-evaluate = 1.0
centralised-eval = false

# ClientApp
partitioner-type = "uniform" # Choose from [uniform, linear, square, exponential]
partitioner-type = "uniform" # Choose from [uniform, linear, square, exponential]
test-fraction = 0.2
seed = 42
centralised-eval-client = false
local-epochs = 1
scaled-lr = false
params.objective = "binary:logistic"
params.eta = 0.1 # Learning rate
params.eta = 0.1 # Learning rate
params.max-depth = 8
params.eval-metric = "auc"
params.nthread = 16
Expand Down
2 changes: 1 addition & 1 deletion examples/xgboost-quickstart/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ fraction-evaluate = 0.1
# ClientApp
local-epochs = 1
params.objective = "binary:logistic"
params.eta = 0.1 # Learning rate
params.eta = 0.1 # Learning rate
params.max-depth = 8
params.eval-metric = "auc"
params.nthread = 16
Expand Down
25 changes: 7 additions & 18 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,8 @@ classifiers = [
"Topic :: Software Development :: Libraries :: Python Modules",
"Typing :: Typed",
]
packages = [
{ include = "flwr", from = "src/py" },
]
exclude = [
"src/py/**/*_test.py",
]
packages = [{ include = "flwr", from = "src/py" }]
exclude = ["src/py/**/*_test.py"]

[tool.poetry.scripts]
# `flwr` CLI
Expand All @@ -62,7 +58,7 @@ flower-superlink = "flwr.server.app:run_superlink"
flower-supernode = "flwr.client.supernode.app:run_supernode"
flower-server-app = "flwr.server.run_serverapp:run_server_app"
flwr-clientapp = "flwr.client.clientapp:flwr_clientapp"
flower-client-app = "flwr.client.supernode:run_client_app" # Deprecated
flower-client-app = "flwr.client.supernode:run_client_app" # Deprecated

[tool.poetry.dependencies]
python = "^3.9"
Expand Down Expand Up @@ -96,6 +92,7 @@ types-setuptools = "==69.0.0.20240125"
clang-format = "==17.0.6"
isort = "==5.13.2"
black = { version = "==24.2.0", extras = ["jupyter"] }
taplo = "==0.9.3"
docformatter = "==1.7.5"
mypy = "==1.8.0"
pylint = "==3.0.3"
Expand Down Expand Up @@ -160,10 +157,7 @@ disable = "duplicate-code,too-few-public-methods,useless-import-alias"
[tool.pytest.ini_options]
minversion = "6.2"
addopts = "-qq"
testpaths = [
"src/py/flwr",
"src/py/flwr_tool",
]
testpaths = ["src/py/flwr", "src/py/flwr_tool"]
filterwarnings = "ignore::DeprecationWarning"

[tool.pytest-watcher]
Expand All @@ -176,17 +170,12 @@ patterns = ["*.py"]
ignore_patterns = []

[tool.mypy]
plugins = [
"numpy.typing.mypy_plugin",
]
plugins = ["numpy.typing.mypy_plugin"]
ignore_missing_imports = true
strict = true

[[tool.mypy.overrides]]
module = [
"importlib.metadata.*",
"importlib_metadata.*",
]
module = ["importlib.metadata.*", "importlib_metadata.*"]
follow_imports = "skip"
follow_imports_for_stubs = true
disallow_untyped_calls = false
Expand Down
24 changes: 24 additions & 0 deletions taplo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
include = ["**/*.toml"]
exclude = ["baselines/**", "datasets/**"]

[formatting]
align_comments = false
# Defaults below
align_entries = false
array_trailing_comma = true
array_auto_expand = true
array_auto_collapse = true
compact_arrays = true
compact_inline_tables = false
inline_table_expand = true
compact_entries = false
column_width = 80
indent_tables = false
indent_entries = false
indent_string = " "
trailing_newline = true
reorder_keys = false
reorder_arrays = false
reorder_inline_tables = false
allowed_blank_lines = 2
crlf = false