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

overriding iteration_log and epoch_log in StatsHandler #5964

Closed
wyli opened this issue Feb 9, 2023 · 2 comments · Fixed by #5965
Closed

overriding iteration_log and epoch_log in StatsHandler #5964

wyli opened this issue Feb 9, 2023 · 2 comments · Fixed by #5965

Comments

@wyli
Copy link
Contributor

wyli commented Feb 9, 2023

Currently, they are booleans but we could extend them to Union[bool, Callable] where if arg is callable then it could be used for event filtering:

    def attach(self, engine):


         if self.iteration_log and not engine.has_event_handler(self.iteration_completed, Events.ITERATION_COMPLETED):
             event_filter = self.iteration_log if callable(self.iteration_log) else None
             engine.add_event_handler(
                 Events.ITERATION_COMPLETED(event_filter=event_filter), self.iteration_completed
             ) 
         if self.epoch_log and not engine.has_event_handler(self.epoch_completed, Events.EPOCH_COMPLETED):
             event_filter = self.epoch_log if callable(self.epoch_log) else None
             engine.add_event_handler(
                 Events.EPOCH_COMPLETED(event_filter=event_filter), self.epoch_completed
             ) 

Originally posted by @vfdev-5 in #5958 (reply in thread)

@Nic-Ma
Copy link
Contributor

Nic-Ma commented Feb 9, 2023

Hi @vfdev-5 ,

Would you like to contribute a PR for your proposal? Otherwise, I can mark it as "contribution wanted".

Thanks.

@vfdev-5
Copy link
Member

vfdev-5 commented Feb 9, 2023

Hi @Nic-Ma , sure I can give it a try.

vfdev-5 added a commit to vfdev-5/MONAI that referenced this issue Feb 9, 2023
Nic-Ma pushed a commit that referenced this issue Feb 10, 2023
#5965)

Fixes #5964

### Description

Added callable options for iteration_log and epoch_log in StatsHandler.

Ref:
#5958 (reply in thread)


### Types of changes
<!--- Put an `x` in all the boxes that apply, and remove the not
applicable items -->
- [x] Non-breaking change (fix or new feature that would not break
existing functionality).
- [ ] Breaking change (fix or new feature that would cause existing
functionality to change).
- [x] New tests added to cover the changes.
- [ ] Integration tests passed locally by running `./runtests.sh -f -u
--net --coverage`.
- [ ] Quick tests passed locally by running `./runtests.sh --quick
--unittests --disttests`.
- [x] In-line docstrings updated.
- [ ] Documentation updated, tested `make html` command in the `docs/`
folder.

---------

Signed-off-by: vfdev-5 <vfdev.5@gmail.com>
Signed-off-by: Wenqi Li <wenqil@nvidia.com>
Signed-off-by: vfdev <vfdev.5@gmail.com>
Co-authored-by: Wenqi Li <wenqil@nvidia.com>
Co-authored-by: Eric Kerfoot <17726042+ericspod@users.noreply.github.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Wenqi Li <831580+wyli@users.noreply.github.com>
wyli added a commit to wyli/MONAI that referenced this issue Feb 13, 2023
Project-MONAI#5965)

Fixes Project-MONAI#5964

### Description

Added callable options for iteration_log and epoch_log in StatsHandler.

Ref:
Project-MONAI#5958 (reply in thread)


### Types of changes
<!--- Put an `x` in all the boxes that apply, and remove the not
applicable items -->
- [x] Non-breaking change (fix or new feature that would not break
existing functionality).
- [ ] Breaking change (fix or new feature that would cause existing
functionality to change).
- [x] New tests added to cover the changes.
- [ ] Integration tests passed locally by running `./runtests.sh -f -u
--net --coverage`.
- [ ] Quick tests passed locally by running `./runtests.sh --quick
--unittests --disttests`.
- [x] In-line docstrings updated.
- [ ] Documentation updated, tested `make html` command in the `docs/`
folder.

---------

Signed-off-by: vfdev-5 <vfdev.5@gmail.com>
Signed-off-by: Wenqi Li <wenqil@nvidia.com>
Signed-off-by: vfdev <vfdev.5@gmail.com>
Co-authored-by: Wenqi Li <wenqil@nvidia.com>
Co-authored-by: Eric Kerfoot <17726042+ericspod@users.noreply.github.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Wenqi Li <831580+wyli@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants