https://dagster.io/ logo
Title
m

medihack

12/18/2021, 5:30 PM
Unfortunately, I don't fully get the API around the 
RootInputManager
. For me it would make sense to use it the same way I use a 
IOManager
. That way I can use the same Manager that inherits from both classes, something like this:
class DatabaseManager(RootInputManager, IOManager):
    def handle_output(self, context, obj):
        ...

    def load_input(self, context):
        ...

@io_manager(required_resource_keys={"database_client"})
def database_io_manager():
    return DatabaseManager()

@root_input_manager(required_resource_keys={"database_client"})
def database_root_manager(_):
     return DatabaseManager()
But unfortunately, it doesn't seem to work that way. The
load_input
is never called when using
DatabaseManager
as a root input. I just get a type check error. I guess because
database_root_manager
should not return the
RootInputManager
, but the input data itself. This makes it so different from each other when both cases could be so nicely combined. Or do I miss something here? EDIT: I found the following workaround, but still think that it is quite ugly.
@root_input_manager(required_resource_keys={"database_client"})
def database_root_manager(context: InputContext):
    manager = DatabaseManager()
    return manager.load_input(context)
In my opinion
@root_input_manager
tries to do to much magic here (by creating it's own
RootInputManager
). I would prefer that it works exactly like
@io_manager
. What do you think?
o

owen

12/20/2021, 5:29 PM
hi @medihack! this is definitely a bit confusing. In general, a
root_input_manager
will only need to define a single function (
load_input
), and so the overhead of creating an entire wrapper class for that purpose is pretty undesirable. However, in cases like yours, there isn't really any overhead because you already defined the class for the IOManager. These cases where you can use an IOManager as a RootInputManager are a bit rarer, simply because IOManagers often use
context.upstream_output
in their
load_input
functions (because they store the outputs using schemes that rely on information specific to the output context).
of course, there are plenty of counter examples to this (like yours), and I 100% agree that this is pretty surprising behavior