Skip to content

Conversation

@Nic-Ma
Copy link
Contributor

@Nic-Ma Nic-Ma commented Apr 7, 2021

Fixes #1916 .

Description

This PR added support to register custom events in the workflows.

Status

Ready

Types of changes

  • 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).
  • 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.
  • In-line docstrings updated.
  • Documentation updated, tested make html command in the docs/ folder.

@Nic-Ma Nic-Ma changed the title [WIP] 1916 Add support for custom events in workflows 1916 Add support for custom events in workflows Apr 7, 2021
@Nic-Ma Nic-Ma marked this pull request as ready for review April 7, 2021 11:13
@Nic-Ma
Copy link
Contributor Author

Nic-Ma commented Apr 7, 2021

/black

@Nic-Ma Nic-Ma requested review from ericspod, rijobro and wyli April 7, 2021 11:13
monai-bot and others added 3 commits April 7, 2021 11:16
Signed-off-by: monai-bot <monai.miccai2019@gmail.com>
Signed-off-by: Wenqi Li <wenqil@nvidia.com>
Copy link
Contributor

@wyli wyli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks!

@Nic-Ma
Copy link
Contributor Author

Nic-Ma commented Apr 7, 2021

Hi @wyli ,

I also tested in our workflows with:

class TestHandler:
    def attach(self, engine):
        engine.add_event_handler("foo_event", self.test1)
        engine.add_event_handler("gar_event", self.test2)
        engine.add_event_handler(Events.EPOCH_COMPLETED, self)
    
    def __call__(self, engine):
        engine.fire_event("foo_event")
        engine.fire_event("gar_event")

    def test1(self, engine):
        print(engine.state.foo)
    
    def test2(self, engine):
        print(engine.state.gar)

Thanks.

@Nic-Ma Nic-Ma enabled auto-merge (squash) April 7, 2021 16:07
@Nic-Ma Nic-Ma merged commit 99bca69 into Project-MONAI:master Apr 7, 2021
nsrivathsa pushed a commit to nsrivathsa/MONAI that referenced this pull request Apr 12, 2021
* [DLMED] add support for addtional events

Signed-off-by: Nic Ma <nma@nvidia.com>

* [DLMED] add unit tests

Signed-off-by: Nic Ma <nma@nvidia.com>

* [DLMED] fix typehints

Signed-off-by: Nic Ma <nma@nvidia.com>

* [MONAI] python code formatting

Signed-off-by: monai-bot <monai.miccai2019@gmail.com>

* fixes typos

Signed-off-by: Wenqi Li <wenqil@nvidia.com>

Co-authored-by: monai-bot <monai.miccai2019@gmail.com>
Co-authored-by: Wenqi Li <wenqil@nvidia.com>
Signed-off-by: Neha Srivathsa <nsrivathsa@nvidia.com>
@Nic-Ma Nic-Ma deleted the 1916-allow-custom-events branch July 2, 2021 23:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Workflow integration of custom events

3 participants