Hello, I have started implementing testing for my ...
# ask-community
r
Hello, I have started implementing testing for my SDAs following the documentation. I'm able to test all assets except the partitoned assets relying on other assets with other partitions. My most common case is daily or monthly time-partitioned data with upstream hourly assets. If a daily partition key is provided, the
materialize_to_memory
will fail when selecting set of assets with multiple partition definitions (hourly & daily/monthly). Is there a solution to implement a test with
materiaiize_to_memory
that will materialize upstream hourly assets then downstream daily assets ?
o
Hi @R Lucas! this is a bit of a tricky one, and there's definitely no built-in solution here. If all of your assets share the same io manager, one solution could be something in the shape of
Copy code
from dagster import InMemoryIOManager

def my_test():
    
    # will be shared across invocations of materialize
    shared_io_manager = InMemoryIOManager()

    all_assets = [hourly_asset, daily_asset]

    for hour in [...]:
        materialize(all_assets, resources={"io_manager": shared_io_manager}, partition_key=hour, selection=[hourly_asset])
    
    materialize(all_assets, resources={"io_manager": shared_io_manager}, partition_key=..., selection=[daily_asset])
👍 1
I believe that would let these assets write to / read from the same InMemoryIOManager instance
r
Thank you for the solution. I'll try to add it.