Skip to content

1916 Add support for custom events in workflows #1961

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

Merged
merged 11 commits into from
Apr 7, 2021

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
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 <[email protected]>

* [DLMED] add unit tests

Signed-off-by: Nic Ma <[email protected]>

* [DLMED] fix typehints

Signed-off-by: Nic Ma <[email protected]>

* [MONAI] python code formatting

Signed-off-by: monai-bot <[email protected]>

* fixes typos

Signed-off-by: Wenqi Li <[email protected]>

Co-authored-by: monai-bot <[email protected]>
Co-authored-by: Wenqi Li <[email protected]>
Signed-off-by: Neha Srivathsa <[email protected]>
@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