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

Add stats_sender to MonaiAlgo for FL stats #6984

Merged
merged 3 commits into from
Sep 13, 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
7 changes: 7 additions & 0 deletions monai/fl/client/monai_algo.py
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,7 @@
if not isinstance(eval_workflow, BundleWorkflow) or eval_workflow.get_workflow_type() is None:
raise ValueError("train workflow must be BundleWorkflow and set type.")
self.eval_workflow = eval_workflow
self.stats_sender = None

Check warning on line 393 in monai/fl/client/monai_algo.py

View check run for this annotation

Codecov / codecov/patch

monai/fl/client/monai_algo.py#L393

Added line #L393 was not covered by tests

self.app_root = ""
self.filter_parser: ConfigParser | None = None
Expand Down Expand Up @@ -478,6 +479,12 @@
if len(config_filter_files) > 0:
self.filter_parser.read_config(config_filter_files)

# set stats sender for nvflare
self.stats_sender = extra.get(ExtraItems.STATS_SENDER, self.stats_sender)
if self.stats_sender is not None:
self.stats_sender.attach(self.trainer)
self.stats_sender.attach(self.evaluator)

Check warning on line 486 in monai/fl/client/monai_algo.py

View check run for this annotation

Codecov / codecov/patch

monai/fl/client/monai_algo.py#L483-L486

Added lines #L483 - L486 were not covered by tests

# Get filters
self.pre_filters = self.filter_parser.get_parsed_content(
FiltersType.PRE_FILTERS, default=ConfigItem(None, FiltersType.PRE_FILTERS)
Expand Down
1 change: 1 addition & 0 deletions monai/fl/utils/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class ExtraItems(StrEnum):
MODEL_TYPE = "fl_model_type"
CLIENT_NAME = "fl_client_name"
APP_ROOT = "fl_app_root"
STATS_SENDER = "fl_stats_sender"


class FlPhase(StrEnum):
Expand Down
Loading