Hi All, How can I set a root path or url on the m...
# ask-community
l
Hi All, How can I set a root path or url on the metadata I marked in the screenshot below? Thanks for your help
v
Without seeing your underlying code, these metadata entries are usually emitted by the IO Manager. See https://docs.dagster.io/_apidocs/ops#dagster.MetadataValue What IO Manager are you using? Did you write a custom one? The default
fs_io_manager
emits the absolute path as metadata (see screenshot example)
Also taking the chance to plug #dagster-de 🙂
🌈 1
l
I use UPathIOManager, thanks for pointing me the right direction. With UPathIOManager you just override get_metadata in your child class.
Copy code
def get_metadata(
    self,
    context: OutputContext,  # pylint: disable=unused-argument
    obj: Any,  # pylint: disable=unused-argument
) -> Dict[str, MetadataValue]:
    """Child classes should override this method to add custom metadata to the outputs."""
    return {}
d
The UPathIOManager is already logging the full path
l
yes it does 👍. but e.g. I would like to prepend http://127.0.0.1:9000/ (local minio) to the path and have a MetadataValue.url(), so I can click on it and immediately inspect the file in browser, without copy pasting. maybe there is a better way to do it but I found a workaround where I override
Copy code
def dump_to_path(self, context: OutputContext, obj, path: UPath):

    # Note: this is a workaround to have the path available when overriding the get_metadata method
    self.path = path
...
since dump_to_path is called first in handle_output I have it available as soon as get_metadata is called. this way i do not need to override too much.
d
I see, makes sense