For testing partitioned assets does anyone know ho...
# ask-community
a
For testing partitioned assets does anyone know how to set the partition_time_window? I tried things similiar to this
Copy code
build_asset_context(
        partition_key_range=PartitionKeyRange(datetime.now() - timedelta(days=1), datetime.now())
    )
But I keep running into
Copy code
E       AttributeError: 'BoundOpExecutionContext' object has no attribute '_step_execution_context'. Did you mean: 'get_step_execution_context'?

venv/lib/python3.10/site-packages/dagster/_core/execution/context/compute.py:295: AttributeError
I also tried creating a super class with this attribute set as such
Copy code
class CustomAssetExecutionContext(AssetExecutionContext):
        def __init__(self, step_execution_context: StepExecutionContext):
            super().__init__(step_execution_context)

        def partition_time_window(self) -> TimeWindow:
            return TimeWindow(datetime.now() - timedelta(days=1), datetime.now())
But I"m unable to construct a step_execution_context
🤖 1
s
I think you have to use
execute_in_process
with tags to achieve this type of test. Here is an example: https://github.com/dagster-io/hooli-data-eng-pipelines/blob/master/hooli_data_eng_tests/test_assets.py#L29-L50
a
Awesome thanks for the link