https://dagster.io/ logo
Title
e

Eduardo Muñoz

04/19/2023, 10:21 AM
Right now we have
local_file_manager
, which basically returns an instance of
LocalFileManager
How could I merge the usage of
ConfigurableResource
and
LocalFileManager
? I've tried:
from typing import Any
from dagster import ConfigurableResource
from dagster._core.storage.file_manager import (
    LocalFileManager as DagsterLocalFileManager,
)

class LocalFileManager(ConfigurableResource, DagsterLocalFileManager):
    base_dir: str

    def __init__(self, **data: Any):
        ConfigurableResource.__init__(self, **data)
        DagsterLocalFileManager.__init__(self, self.base_dir)
But I get the following error:
TypeError: "LocalFileManager" is immutable and does not support item assignment
t

Tim Castillo

04/19/2023, 7:30 PM
Hi Eduardo! Let me reach out to the team to see if they have an answer
o

owen

04/19/2023, 10:26 PM
hi @Eduardo Muñoz! In this case, you want a
ConfigurableResourceFactory
instead of a
ConfigurableResource
. The
ConfigurableResource
class is used when you're defining your own resource from scratch (so you can combine the configuration and the implementation) but when you want to use the config system to configure a pre-defined class, then you'll want the factory. That would look like
class LocalFileManagerResource(ConfiugrableResourceFactory[LocalFileManager]):
    base_dir: str
    
    def create_resource(self, _init_context) -> LocalFileManager:
        return LocalFileManager(self.base_dir)
e

Eduardo Muñoz

04/20/2023, 6:31 AM
Hey, Thanks! Looks great, I'll try that 🙂
where is
ConfigurableResourceFactory
exported from?
c

Chaitya

04/26/2023, 1:21 AM
Hey Eduardo - ran into the same issue today. I think the ConfigurableResourceFactory they're referring to is located here.
from dagster._config.pythonic_config import ConfigurableResourceFactory
❤️ 1
e

Eduardo Muñoz

05/04/2023, 12:58 PM
thanks, ill give it a go!