Skip to content

Commit 31322d6

Browse files
committed
add smoke test
1 parent 4d3ca25 commit 31322d6

2 files changed

Lines changed: 20 additions & 5 deletions

File tree

examples/nnunet_pfl_example/client.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from logging import DEBUG, INFO
55
from os.path import exists, join
66
from pathlib import Path
7-
from typing import Any, Literal
7+
from typing import Any
88

99
from fl4health.checkpointing.client_module import ClientCheckpointAndStateModule
1010
from fl4health.checkpointing.state_checkpointer import ClientStateCheckpointer
@@ -45,7 +45,7 @@ def main(
4545
compile: bool = True,
4646
intermediate_client_state_dir: str | None = None,
4747
client_name: str | None = None,
48-
personalized_strategy: Literal["ditto"] | None = None,
48+
personalized_strategy: str = "ditto",
4949
) -> None:
5050
with torch.autograd.set_detect_anomaly(True):
5151
# Log device and server address
@@ -103,7 +103,7 @@ def main(
103103
checkpoint_and_state_module=checkpoint_and_state_module,
104104
client_name=client_name,
105105
)
106-
if personalized_strategy:
106+
if personalized_strategy in personalized_client_classes:
107107
log(INFO, f"Setting up client for personalized strategy: {personalized_strategy}")
108108
client = personalized_client_classes[personalized_strategy](**client_kwargs)
109109
else:
@@ -211,9 +211,9 @@ def main(
211211
"--personalized-strategy",
212212
type=str,
213213
required=False,
214-
default=None,
214+
default="ditto",
215215
help="[OPTIONAL] Personalized strategy to use. For now, can only be 'ditto'. \
216-
Defaults to None, in which no personalized strategy is applied.",
216+
Defaults to 'ditto', in which no personalized strategy is applied.",
217217
)
218218
parser.add_argument(
219219
"--seed",

tests/smoke_tests/test_smoke_tests.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -463,3 +463,18 @@ async def test_flexible_nnunet_config_3d(tolerance: float) -> None:
463463
task = asyncio.create_task(coroutine)
464464
await try_running_test_task(task)
465465
assert_on_done_task(task)
466+
467+
468+
@pytest.mark.smoketest
469+
async def test_ditto_flexible_nnunet_config_2d(tolerance: float) -> None:
470+
coroutine = run_smoke_test( # By default will use Task04_Hippocampus Dataset
471+
server_python_path="examples.nnunet_pfl_example.server",
472+
client_python_path="examples.nnunet_pfl_example.client",
473+
config_path="tests/smoke_tests/nnunet_config_2d.yaml",
474+
dataset_path="examples/datasets/nnunet",
475+
tolerance=tolerance,
476+
read_logs_timeout=450,
477+
)
478+
task = asyncio.create_task(coroutine)
479+
await try_running_test_task(task)
480+
assert_on_done_task(task)

0 commit comments

Comments
 (0)