Skip to content

Add dict properties to Engine and State #2000

@Nic-Ma

Description

@Nic-Ma

🚀 Feature

Hi @vfdev-5 ,

In the current implementation of MONAI handlers, they are deeply coupled with ignite engine.
Some users that use different workflows can't leverage our handlers, so we are trying to make handlers decouple from ignite.
We discussed the problem and got some basic ideas:

  1. Add dict properties to the engine, then handlers can treat engine arg as a regular dict with same structure as ignite Engine object.
  2. Pass the event name when trigger handler, so other workflows also can call this handler with the same event name.

For example:

class TestHandler:
    def attach(self):
        # ignite specific logic
       ... ...

    def __call__(self, data: Dict, event: str):
        # data map to the engine dict of ignite
        if event == "ITERATION_COMPLETED":
            self._iteration(data)
        if event == "EPOCH_COMPLETED":
            self._epoch(data)

What do you think?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions