Hi Dasgter! I recently reported a problem when the...
# ask-community
j
Hi Dasgter! I recently reported a problem when the metadata is null in 0.15.6. So I switched to 0.15.4 for more stability in my case. I noticed a problem when trying to retrieve the metadata of a previous asset when it is not selected in the runtime. When I run the 2 assets in the example below there is no problem. However by selecting only the second asset at runtime the metadata value in io_manager is no longer
None
but
'[NoneType] (unserializable)'
. I know that @owen dealt with a problem with the metadata yesterday. Would it be possible to test this example after these changes to see if the problem persists or not? Note that at the interface level, there is also the problem in 0.15.4.
Copy code
from dagster import (
    AssetSelection,
    asset,
    define_asset_job,
    repository,
    AssetIn,
    io_manager,
    IOManager,
    OutputContext,
    InputContext,
)


class MyIOManager(IOManager):
    def handle_output(self, context: OutputContext, obj: int):
        pass

    def load_input(self, context: InputContext):
        print(context.upstream_output.metadata)
        assert context.upstream_output.metadata == {"metadata_1": None}
        pass


@io_manager
def my_io_manager(init_context):
    return MyIOManager()


@asset(metadata={"metadata_1": None}, io_manager_def=my_io_manager)
def asset1():
    pass


@asset(
    ins={"asset1": AssetIn("asset1")},
    metadata={"metadata_2": None},
    io_manager_def=my_io_manager,
)
def asset2(asset1):
    pass


asset_job = define_asset_job(
    name="asset_1_and_2_job",
    selection=AssetSelection.assets(asset1, asset2),
)


@repository
def repo():
    return [asset1, asset2, asset_job]
o
hi @Jordan, thanks for the example code, that was helpful -- this specific issue does indeed still exist after those changes. This issue doesn't have as simple of a fix as far as I can tell, but I created an issue here: https://github.com/dagster-io/dagster/issues/8971. We should probably have better built-in support for None-type objects, but a hacky solution (which will also work in the current version of dagster) is to convert your unserializable None object into an object that Dagster knows how to serialize, such as a dictionary (i.e.
{"metadata_1": {"value": None}}
). Definitely not intuitive that the dictionary is serializable but not the bare value 😬
👍 1
j
Thanks ! 🙂