Hi! I'm trying to test an asset that uses a MultiP...
# ask-community
y
Hi! I'm trying to test an asset that uses a MultiPartitionKey, but I'm getting errors Is this how I should build the context?
Copy code
context = build_op_context(
            config={"exec_path": ""},
            partition_key=MultiPartitionKey({"fiscal_year": "2021", "dataset": "idealratings"}))
Copy code
esg/tests/regulatory_frameworks/assets/test_load_metric_config.py:15:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/opt/homebrew/Caskroom/miniforge/base/envs/py39_env_x86/lib/python3.9/site-packages/dagster/_core/definitions/assets.py:194: in __call__
    return solid_def(*new_args, **kwargs)
/opt/homebrew/Caskroom/miniforge/base/envs/py39_env_x86/lib/python3.9/site-packages/dagster/_core/definitions/solid_definition.py:182: in __call__
    return solid_invocation_result(self, context, *args[1:], **kwargs)
/opt/homebrew/Caskroom/miniforge/base/envs/py39_env_x86/lib/python3.9/site-packages/dagster/_core/definitions/solid_invocation.py:61: in solid_invocation_result
    compute_fn.decorated_fn(context, **input_dict)
esg/regulatory_frameworks/assets/load_metric_config.py:41: in load_config_from_yaml
    partition_keys = context.partition_key.keys_by_dimension
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <dagster._core.execution.context.invocation.BoundSolidExecutionContext object at 0x108f8f5c0>

    @public  # type: ignore
    @property
    def partition_key(self) -> str:
        """The partition key for the current run.

        Raises an error if the current run is not a partitioned run.
        """
>       return self._step_execution_context.partition_key
E       AttributeError: _step_execution_context

/opt/homebrew/Caskroom/miniforge/base/envs/py39_env_x86/lib/python3.9/site-packages/dagster/_core/execution/context/compute.py:296: AttributeError
The asset does run in dagit
for some reason in tests, it's not able to retrieve
context.partition_key
o
hi @Yang! seems to be a bug on our end -- working on a fix 🙂
y
oh! ok cool